Skip to content

Commit 752d31e

Browse files
authored
Merge pull request #22 from back4app/cleanup-files
Cleanup files screen
2 parents 5ab913d + 5020363 commit 752d31e

File tree

2 files changed

+38
-59
lines changed

2 files changed

+38
-59
lines changed

src/dashboard/Settings/GeneralSettings.react.js

Lines changed: 36 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ let ManageAppFields = ({
181181
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
182182
label={<Label
183183
text='Clean up app'
184-
description={<span>This will delete any files that <br/>are not referenced by any objects.</span>} />}
184+
description={<span>This will delete any files that are not referenced by any objects.
185+
(Don't use the feature if you have Arrays of Files,<br/>or Files inside Object columns!)
186+
</span>} />}
185187
input={<FormButton
186188
onClick={cleanUpFiles}
187189
value='Clean Up Files'/>} />
@@ -190,61 +192,6 @@ let ManageAppFields = ({
190192
color={cleanUpMessageColor}>
191193
<div>{cleanUpFilesMessage}</div>
192194
</FormNote> : null}
193-
<Field
194-
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
195-
label={<Label
196-
text='Export app data'
197-
description={'We firmly believe in data portability.'} />}
198-
//TODO: Add export progress view when designs are ready.
199-
input={<FormButton
200-
onClick={exportData}
201-
value='Export Data'/>} />
202-
{exportDataMessage ? <FormNote
203-
show={true}
204-
color={exportMessageColor}>
205-
<div>{exportDataMessage}</div>
206-
</FormNote> : null}
207-
{migrateAppField}
208-
<Field
209-
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
210-
label={<Label
211-
text='Clone app'
212-
description={<span>Choose what you want to carry over <br/>and create a copy of this Parse app.</span>} />}
213-
input={<FormButton
214-
value='Clone this app'
215-
onClick={cloneApp} />
216-
} />
217-
{cloneAppMessage ? <FormNote
218-
show={true}
219-
color='green'>
220-
<div>{cloneAppMessage} Check out the progress on your <Link to={{ pathname: '/apps' }}>apps page</Link>!</div>
221-
</FormNote> : null}
222-
{!isCollaborator ? <Field
223-
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
224-
label={<Label
225-
text='Transfer app'
226-
description={<span>Give an existing collaborator <br/>ownership over this app.</span>} />
227-
}
228-
input={<FormButton
229-
value='Transfer this app'
230-
color='red'
231-
disabled={!hasCollaborators}
232-
onClick={transferApp} />
233-
} /> : null}
234-
{transferAppMessage ? <FormNote
235-
color='green'>
236-
{transferAppMessage}
237-
</FormNote> : null}
238-
{!isCollaborator ? <Field
239-
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
240-
label={<Label
241-
text='Delete app'
242-
description={<span>Completely remove any trace <br/>of this app's existence.</span>} />}
243-
input={<FormButton
244-
color='red'
245-
value='Delete this app'
246-
onClick={deleteApp} />
247-
} /> : null}
248195
</Fieldset>);
249196
}
250197

@@ -284,6 +231,7 @@ export default class GeneralSettings extends DashboardView {
284231
newConnectionString: '',
285232

286233
removedCollaborators: [],
234+
showPurgeFilesModal: false,
287235
};
288236
}
289237

@@ -553,7 +501,7 @@ export default class GeneralSettings extends DashboardView {
553501
return promise;
554502
}}
555503
renderForm={({ changes, fields, setField, resetFields }) => {
556-
let isCollaborator = AccountManager.currentUser().email !== this.props.initialFields.owner_email;
504+
//let isCollaborator = AccountManager.currentUser().email !== this.props.initialFields.owner_email;
557505
return <div className={styles.settings_page}>
558506
<AppInformationFields
559507
appName={fields.appName}
@@ -576,6 +524,37 @@ export default class GeneralSettings extends DashboardView {
576524
viewerEmail={AccountManager.currentUser().email}
577525
addCollaborator={setCollaborators.bind(undefined, setField)}
578526
removeCollaborator={setCollaborators.bind(undefined, setField)}/>
527+
<ManageAppFields
528+
mongoURL={fields.mongoURL}
529+
isCollaborator={AccountManager.currentUser().email !== this.props.initialFields.owner_email}
530+
hasCollaborators={fields.collaborators.length > 0}
531+
appSlug={this.context.currentApp.slug}
532+
cleanUpFiles={() => this.setState({showPurgeFilesModal: true})}
533+
cleanUpFilesMessage={this.state.cleanupFilesMessage}
534+
cleanUpMessageColor={this.state.cleanupNoteColor} />
535+
{this.state.showPurgeFilesModal ? <Modal
536+
type={Modal.Types.INFO}
537+
icon='down-outline'
538+
iconSize={40}
539+
title='Clean Orphan Files'
540+
subtitle={'The files without DB references will be removed!'}
541+
confirmText='Purge Files'
542+
cancelText='Cancel'
543+
buttonsInCenter={true}
544+
onCancel={() => this.setState({showPurgeFilesModal: false})}
545+
onConfirm={() => this.context.currentApp.cleanUpFiles().then(result => {
546+
this.setState({
547+
cleanupFilesMessage: 'All set! Your files will be deleted soon.',
548+
cleanupNoteColor: 'orange',
549+
showPurgeFilesModal: false,
550+
});
551+
}).fail((e) => {
552+
this.setState({
553+
cleanupFilesMessage: e.error,
554+
cleanupNoteColor: 'red',
555+
showPurgeFilesModal: false,
556+
});
557+
})} /> : null }
579558
</div>;
580559
}} />
581560
<Toolbar section='Settings' subsection='General' />

src/lib/ParseApp.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ export default class ParseApp {
340340
}
341341

342342
cleanUpFiles() {
343-
let path = '/apps/' + this.slug + '/cleanup_files';
344-
return AJAX.put(path);
343+
let path = '/apps/' + this.slug + '/orphan_files';
344+
return AJAX.post(path);
345345
}
346346

347347
normalizePath(path) {

0 commit comments

Comments
 (0)