Skip to content

Commit

Permalink
Fix some linting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Rainville committed Oct 8, 2019
1 parent 66de05b commit ccbb7a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Large diffs are not rendered by default.

54 changes: 31 additions & 23 deletions client/src/containers/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Editor extends Component {

this.handleCancelKeyDown = this.handleCancelKeyDown.bind(this);
this.handleClose = this.handleClose.bind(this);
this.handleDelete = this.handleDelete.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleAction = this.handleAction.bind(this);
this.handleLoadingSuccess = this.handleLoadingSuccess.bind(this);
Expand Down Expand Up @@ -51,30 +52,11 @@ class Editor extends Component {

break;
case 'action_delete':
// Customise message based on usage
let message = i18n._t('AssetAdmin.CONFIRMDELETE', 'Are you sure you want to delete this record?');
if (this.props.file && this.props.file.inUseCount > 0) {
message = i18n.sprintf(
i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_SINGLE_CONFIRM',
'This file is currently used in %s place(s), are you sure you want to delete it?'
),
this.props.file.inUseCount
);
message += '\n\n';
message += i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_WARNING',
'Ensure files are removed from content areas prior to deleting them,'
+ ' otherwise they will appear as broken links.'
);
}
// eslint-disable-next-line no-alert
if (confirm(message)) {
this.props.actions.unsavedForms.removeFormChanged('AssetAdmin.EditForm');
this.props.onDelete([data.ID]);
}
this.handleDelete(event, data);
event.preventDefault();

break;
default:
break;
}
}
Expand Down Expand Up @@ -114,6 +96,32 @@ class Editor extends Component {
}
}

handleDelete(event, data) {
// Customise message based on usage
let message = i18n._t('AssetAdmin.CONFIRMDELETE', 'Are you sure you want to delete this record?');
if (this.props.file && this.props.file.inUseCount > 0) {
message = i18n.sprintf(
i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_SINGLE_CONFIRM',
'This file is currently used in %s place(s), are you sure you want to delete it?'
),
this.props.file.inUseCount
);
message += '\n\n';
message += i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_WARNING',
'Ensure files are removed from content areas prior to deleting them,'
+ ' otherwise they will appear as broken links.'
);
}
// eslint-disable-next-line no-alert
if (confirm(message)) {
this.props.actions.unsavedForms.removeFormChanged('AssetAdmin.EditForm');
this.props.onDelete([data.ID]);
}
event.preventDefault();
}

openModal() {
this.setState({
openModal: true,
Expand All @@ -137,7 +145,7 @@ class Editor extends Component {

downloadFile() {
function downloadURI(uri, name) {
const link = document.createElement("a");
const link = document.createElement('a');
link.download = name;
link.href = uri;
link.target = '_blank';
Expand Down

0 comments on commit ccbb7a4

Please sign in to comment.