Skip to content

Commit a80a87b

Browse files
authored
Merge pull request #23 from back4app/purgelogs
Purgelogs
2 parents 622ace2 + 5f70b72 commit a80a87b

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

src/dashboard/Settings/GeneralSettings.react.js

+46-3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ let ManageAppFields = ({
107107
cleanUpFiles,
108108
cleanUpFilesMessage,
109109
cleanUpMessageColor = 'orange',
110+
cleanUpSystemLog,
111+
cleanUpSystemLogMessage,
110112
exportData,
111113
exportDataMessage,
112114
exportMessageColor = 'orange',
@@ -181,7 +183,7 @@ let ManageAppFields = ({
181183
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
182184
label={<Label
183185
text='Clean up app'
184-
description={<span>This will delete any files that are not referenced by any objects.
186+
description={<span>This will delete any files that are not referenced by any objects.
185187
(Don't use the feature if you have Arrays of Files,<br/>or Files inside Object columns!)
186188
</span>} />}
187189
input={<FormButton
@@ -192,6 +194,20 @@ let ManageAppFields = ({
192194
color={cleanUpMessageColor}>
193195
<div>{cleanUpFilesMessage}</div>
194196
</FormNote> : null}
197+
<Field
198+
labelWidth={DEFAULT_SETTINGS_LABEL_WIDTH}
199+
label={<Label
200+
text='Clean up log'
201+
description={<span>This will purge your System Log.
202+
</span>} />}
203+
input={<FormButton
204+
onClick={cleanUpSystemLog}
205+
value='Clean Up System Log'/>} />
206+
{cleanUpSystemLogMessage ? <FormNote
207+
show={true}
208+
color={cleanUpMessageColor}>
209+
<div>{cleanUpSystemLogMessage}</div>
210+
</FormNote> : null}
195211
</Fieldset>);
196212
}
197213

@@ -202,6 +218,7 @@ export default class GeneralSettings extends DashboardView {
202218
this.subsection = 'General';
203219

204220
this.state = {
221+
cleanupSystemLogMessage: '',
205222
cleanupFilesMessage: '',
206223
cleanupNoteColor: '',
207224

@@ -232,6 +249,7 @@ export default class GeneralSettings extends DashboardView {
232249

233250
removedCollaborators: [],
234251
showPurgeFilesModal: false,
252+
showPurgeSystemLogModal: false
235253
};
236254
}
237255

@@ -347,7 +365,7 @@ export default class GeneralSettings extends DashboardView {
347365
{this.state.migrationWarnings.map(warning => <FormNote key={warning}show={true} color='orange'>{warning}</FormNote>)}
348366
</FormModal>
349367

350-
368+
351369

352370
let deleteAppModal = <FormModal
353371
title='Delete App'
@@ -531,7 +549,9 @@ export default class GeneralSettings extends DashboardView {
531549
appSlug={this.context.currentApp.slug}
532550
cleanUpFiles={() => this.setState({showPurgeFilesModal: true})}
533551
cleanUpFilesMessage={this.state.cleanupFilesMessage}
534-
cleanUpMessageColor={this.state.cleanupNoteColor} />
552+
cleanUpMessageColor={this.state.cleanupNoteColor}
553+
cleanUpSystemLog={() => this.setState({showPurgeSystemLogModal: true})}
554+
cleanUpSystemLogMessage={this.state.cleanupSystemLogMessage} />
535555
{this.state.showPurgeFilesModal ? <Modal
536556
type={Modal.Types.INFO}
537557
icon='down-outline'
@@ -555,6 +575,29 @@ export default class GeneralSettings extends DashboardView {
555575
showPurgeFilesModal: false,
556576
});
557577
})} /> : null }
578+
{this.state.showPurgeSystemLogModal ? <Modal
579+
type={Modal.Types.INFO}
580+
icon='down-outline'
581+
iconSize={40}
582+
title='Clean System Log'
583+
subtitle={'The System log will be removed!'}
584+
confirmText='Purge System Log'
585+
cancelText='Cancel'
586+
buttonsInCenter={true}
587+
onCancel={() => this.setState({showPurgeSystemLogModal: false})}
588+
onConfirm={() => this.context.currentApp.cleanUpSystemLog().then(result => {
589+
this.setState({
590+
cleanupSystemLogMessage: 'Your System log was deleted.',
591+
cleanupNoteColor: 'orange',
592+
showPurgeSystemLogModal: false,
593+
});
594+
}).fail((e) => {
595+
this.setState({
596+
cleanupSystemLogMessage: e.error,
597+
cleanupNoteColor: 'red',
598+
showPurgeSystemLogModal: false,
599+
});
600+
})} /> : null }
558601
</div>;
559602
}} />
560603
<Toolbar section='Settings' subsection='General' />

src/lib/ParseApp.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,11 @@ export default class ParseApp {
344344
return AJAX.post(path);
345345
}
346346

347+
cleanUpSystemLog() {
348+
let path = '/parse-app/' + this.slug + '/purge-logs';
349+
return AJAX.post(path);
350+
}
351+
347352
normalizePath(path) {
348353
path = path.replace(/([^:\s])\/+/g, '$1/');
349354
return path;
@@ -490,7 +495,7 @@ export default class ParseApp {
490495
//TODO: this currently works because everything that uses collaborators
491496
// happens to re-render after this call anyway, but really the collaborators
492497
// should be updated properly in a store or AppsManager or something
493-
this.settings.fields.fields.collaborators =
498+
this.settings.fields.fields.collaborators =
494499
Array.isArray(this.settings.fields.fields.collaborators) ?
495500
this.settings.fields.fields.collaborators : [];
496501
this.settings.fields.fields.collaborators.unshift(data);

0 commit comments

Comments
 (0)