Skip to content

Commit

Permalink
Merge branch '2.0' into 2
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Aug 22, 2023
2 parents 1d567e0 + a5676ad commit 5dea8dc
Show file tree
Hide file tree
Showing 19 changed files with 234 additions and 74 deletions.
4 changes: 2 additions & 2 deletions client/dist/js/TinyMCE_sslink-file.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/dist/js/TinyMCE_ssmedia.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/dist/js/bundle.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions client/lang/src/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@
"AssetAdmin.BACK": "Back",
"AssetAdmin.BACK_DESCRIPTION": "Navigate up a level",
"AssetAdmin.BULK_ACTIONS_CONFIRM": "Are you sure you want to %s these files?",
"AssetAdmin.BULK_ACTIONS_ARCHIVE": "Archive",
"AssetAdmin.BULK_ACTIONS_ARCHIVE_ITEMS_CONFIRM": "You're about to archive %s file(s) which may be used in your site's content. Carefully check the file usage on the files before archiving the file(s).",
"AssetAdmin.BULK_ACTIONS_ARCHIVE_FAIL_02": "%s folders/files were successfully archived, but %s files were not able to be archived.",
"AssetAdmin.BULK_ACTIONS_ARCHIVE_FOLDER_CONFIRM": "Are you sure you want to archive this folder?",
"AssetAdmin.BULK_ACTIONS_ARCHIVE_FOLDERS_CONFIRM": "Are you sure you want to archive these folders?",
"AssetAdmin.BULK_ACTIONS_ARCHIVE_SUCCESS_02": "%s folders/files were successfully archived.",
"AssetAdmin.BULK_ACTIONS_ARCHIVE_WARNING": "Ensure files are removed from content areas prior to archiving them, otherwise they will appear as broken links.",
"AssetAdmin.BULK_ACTIONS_DELETE": "Delete",
"AssetAdmin.BULK_ACTIONS_DELETE_CONFIRM": "Are you sure you want to delete these files?",
"AssetAdmin.BULK_ACTIONS_DELETE_FAIL": "%s folders/files were successfully archived, but %s files were not able to be archived.",
"AssetAdmin.BULK_ACTIONS_DELETE_FAIL_02": "%s folders/files were successfully deleted, but %s files were not able to be deleted.",
"AssetAdmin.BULK_ACTIONS_DELETE_FOLDER": "These folders contain files which are currently in use, you must move or delete their contents before you can delete the folder.",
"AssetAdmin.BULK_ACTIONS_DELETE_FOLDER_CONFIRM": "Are you sure you want to delete this folder?",
"AssetAdmin.BULK_ACTIONS_DELETE_FOLDERS_CONFIRM": "Are you sure you want to delete these folders?",
"AssetAdmin.BULK_ACTIONS_DELETE_ITEMS_CONFIRM": "You're about to delete %s file(s) which may be used in your site's content. Carefully check the file usage on the files before deleting the file(s).",
"AssetAdmin.BULK_ACTIONS_DELETE_MULTI_CONFIRM": "There are %s files currently in use, are you sure you want to delete these files?",
"AssetAdmin.BULK_ACTIONS_DELETE_SINGLE_CONFIRM": "This file is currently in use in %s places, are you sure you want to delete it?",
"AssetAdmin.BULK_ACTIONS_DELETE_SUCCESS": "%s folders/files were successfully archived.",
"AssetAdmin.BULK_ACTIONS_DELETE_SUCCESS_02": "%s folders/files were successfully deleted.",
"AssetAdmin.BULK_ACTIONS_DELETE_WARNING": "Ensure files are removed from content areas prior to deleting them, otherwise they will appear as broken links.",
"AssetAdmin.BULK_ACTIONS_PLACEHOLDER": "Select an action...",
"AssetAdmin.CANCEL": "Cancel",
"AssetAdmin.CONFIRMDELETE": "Are you sure you want to delete this record?",
"AssetAdmin.CONFIRM_FILE_ARCHIVE": "Confirm archive",
"AssetAdmin.CONFIRM_FILE_DELETION": "Confirm deletion",
"AssetAdmin.CREATED": "First uploaded",
"AssetAdmin.DELETE": "Delete",
"AssetAdmin.DIM": "Dimensions",
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/UploadField/UploadField.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class UploadField extends Component {

handleFailedUpload(file, response) {
const statusCodeMessage = file.xhr && file.xhr.status
? getStatusCodeMessage(file.xhr.status)
? getStatusCodeMessage(file.xhr.status, file.xhr)
: '';
this.props.actions.uploadField.failUpload(
this.props.id,
Expand Down
12 changes: 12 additions & 0 deletions client/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ export default {
items.every(item => item && item.canDelete)
),
},
// Archive is the same as Delete just with a different label and icon
// There is logic to choose which bulk-action to use in Gallery.js
{
value: 'archive',
label: i18n._t('AssetAdmin.BULK_ACTIONS_ARCHIVE', 'Archive'),
className: 'font-icon-box',
destructive: true,
callback: null, // defined in <Gallery> for now
canApply: (items) => (
items.every(item => item && item.canDelete)
),
},
{
value: 'edit',
label: i18n._t('AssetAdmin.BULK_ACTIONS_EDIT', 'Edit'),
Expand Down
21 changes: 16 additions & 5 deletions client/src/containers/AssetAdmin/AssetAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,21 +356,31 @@ class AssetAdmin extends Component {
})
.then((resultItems) => {
const successes = resultItems.filter((result) => result).length;
const { archiveFiles } = this.props.sectionConfig;
if (successes !== ids.length) {
let transKey = 'AssetAdmin.BULK_ACTIONS_DELETE_FAIL_02';
let transDefault = '%s folders/files were successfully deleted, but %s files were not able to be deleted.';
if (archiveFiles) {
transKey = 'AssetAdmin.BULK_ACTIONS_ARCHIVE_FAIL_02';
transDefault = '%s folders/files were successfully archived, but %s files were not able to be archived.';
}
this.props.actions.toasts.error(
i18n.sprintf(
i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_FAIL',
'%s folders/files were successfully deleted, but %s files were not able to be deleted.'
),
i18n._t(transKey, transDefault),
successes,
ids.length - successes
)
);
} else {
let transKey = 'AssetAdmin.BULK_ACTIONS_DELETE_SUCCESS_02';
let transDefault = '%s folders/files were successfully deleted.';
if (archiveFiles) {
transKey = 'AssetAdmin.BULK_ACTIONS_ARCHIVE_SUCCESS_02';
transDefault = '%s folders/files were successfully archived.';
}
this.props.actions.toasts.success(
i18n.sprintf(
i18n._t('AssetAdmin.BULK_ACTIONS_DELETE_SUCCESS', '%s folders/files were successfully deleted.'),
i18n._t(transKey, transDefault),
successes
)
);
Expand Down Expand Up @@ -673,6 +683,7 @@ class AssetAdmin extends Component {

render() {
const { folder, folderId, query, getUrl, type, maxFiles, toolbarChildren, SearchComponent, BulkDeleteConfirmationComponent } = this.props;
const { archiveFiles } = this.props.sectionConfig;

const showBackButton = Boolean(folderId || hasFilters(query.filter));
const searchFormSchemaUrl = this.props.sectionConfig.form.fileSearchForm.schemaUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import { getFolderDescendantFileTotals, getFileTotalItems } from './helpers';
const BulkDeleteConfirmation = ({
loading, LoadingComponent, transition,
files, descendantFileCounts,
onModalClose, onCancel, onConfirm
onModalClose, onCancel, onConfirm, archiveFiles
}) => {
let body = null;
const transKey = archiveFiles ? 'AssetAdmin.ARCHIVE' : 'AssetAdmin.DELETE';
const transDefault = archiveFiles ? 'Archive' : 'Delete';
let actions = [
{
label: i18n._t('AssetAdmin.DELETE', 'Delete'),
label: i18n._t(transKey, transDefault),
handler: () => onConfirm(files.map(({ id }) => id)),
color: 'danger'
},
Expand All @@ -42,7 +44,7 @@ const BulkDeleteConfirmation = ({
const folderDescendantFileTotals = getFolderDescendantFileTotals(files, descendantFileCounts);
const fileTotalItems = getFileTotalItems(files);

const bodyProps = { folderCount, folderDescendantFileTotals, fileTotalItems };
const bodyProps = { folderCount, folderDescendantFileTotals, fileTotalItems, archiveFiles };
body = <BulkDeleteMessage {...bodyProps} />;

if (folderDescendantFileTotals.totalItems || fileTotalItems) {
Expand All @@ -53,10 +55,10 @@ const BulkDeleteConfirmation = ({
color: 'primary'
},
{
label: i18n._t('AssetAdmin.DELETE', 'Delete'),
label: i18n._t(transKey, transDefault),
handler: () => onConfirm(files.map(({ id }) => id)),
color: 'danger',
},
}
];
}
}
Expand All @@ -72,6 +74,7 @@ const BulkDeleteConfirmation = ({
actions={actions}
onCancel={onCancel}
onClosed={onModalClose}
archiveFiles={archiveFiles}
/>);
};

Expand All @@ -84,6 +87,7 @@ BulkDeleteConfirmation.propTypes = {
onCancel: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired,
onConfirm: PropTypes.func.isRequired,
archiveFiles: PropTypes.bool.isRequired,
};

/**
Expand Down
87 changes: 61 additions & 26 deletions client/src/containers/BulkDeleteConfirmation/BulkDeleteMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,79 @@ import { descendantFileTotalsShape } from './helpers';
* @param {object} fileTotalItems
* @returns {string}
*/
const confirmationMessage = (folderCount, folderDescendantFileTotals, fileTotalItems) => {
const confirmationMessage = (
folderCount,
folderDescendantFileTotals,
fileTotalItems,
archiveFiles
) => {
const fileCount = folderDescendantFileTotals.totalCount + fileTotalItems;
if (fileCount > 0) {
let transKey = 'AssetAdmin.BULK_ACTIONS_DELETE_ITEMS_CONFIRM';
let transDefault = [
"You're about to delete %s file(s) which may be used in your site's content.",
'Carefully check the file usage on the files before deleting the file(s).'
].join(' ');
if (archiveFiles) {
transKey = 'AssetAdmin.BULK_ACTIONS_ARCHIVE_ITEMS_CONFIRM';
transDefault = [
"You're about to archive %s file(s) which may be used in your site's content.",
'Carefully check the file usage on the files before archiving the file(s).'
].join(' ');
}
return i18n.sprintf(
i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_ITEMS_CONFIRM',
[
"You're about to delete %s file(s) which may be used in your site's content.",
'Carefully check the file usage on the files before deleting the folder.'
].join(' ')
),
i18n._t(transKey, transDefault),
fileCount
);
} else if (folderCount === 1) {
return i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_FOLDER_CONFIRM',
'Are you sure you want to delete this folder?'
);
let transKey = 'AssetAdmin.BULK_ACTIONS_DELETE_FOLDER_CONFIRM';
let transDefault = 'Are you sure you want to delete this folder?';
if (archiveFiles) {
transKey = 'AssetAdmin.BULK_ACTIONS_ARCHIVE_FOLDER_CONFIRM';
transDefault = 'Are you sure you want to archive this folder?';
}
return i18n._t(transKey, transDefault);
}
return i18n._t(
'AssetAdmin.BULK_ACTIONS_DELETE_FOLDERS_CONFIRM',
'Are you sure you want to delete these folders?'
);
let transKey = 'AssetAdmin.BULK_ACTIONS_DELETE_FOLDERS_CONFIRM';
let transDefault = 'Are you sure you want to delete these folders?';
if (archiveFiles) {
transKey = 'AssetAdmin.BULK_ACTIONS_ARCHIVE_FOLDERS_CONFIRM';
transDefault = 'Are you sure you want to archive these folders?';
}
return i18n._t(transKey, transDefault);
};

/**
* Display a context dependent confirmation message.
*/
const BulkDeleteMessage = ({ folderCount, folderDescendantFileTotals, fileTotalItems }) => (
<>
<p>{confirmationMessage(folderCount, folderDescendantFileTotals, fileTotalItems)}</p>
{(folderDescendantFileTotals.totalItems > 0 || fileTotalItems > 0) &&
<p>{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.'
)}</p>}
</>
);
const BulkDeleteMessage = ({
folderCount,
folderDescendantFileTotals,
fileTotalItems,
archiveFiles
}) => {
let transKey = 'AssetAdmin.BULK_ACTIONS_DELETE_WARNING';
let transDefault = 'Ensure files are removed from content areas prior to deleting them, otherwise they will '
+ 'appear as broken links.';
if (archiveFiles) {
transKey = 'AssetAdmin.BULK_ACTIONS_ARCHIVE_WARNING';
transDefault = 'Ensure files are removed from content areas prior to archiving them, otherwise they will '
+ 'appear as broken links.';
}
const message = confirmationMessage(
folderCount,
folderDescendantFileTotals,
fileTotalItems,
archiveFiles
);
return (
<Fragment>
<p>{message}</p>
{(folderDescendantFileTotals.totalItems > 0 || fileTotalItems > 0) &&
<p>{i18n._t(transKey, transDefault)}</p>}
</Fragment>
);
};

BulkDeleteMessage.propTypes = {
folderCount: PropTypes.number,
Expand Down
37 changes: 23 additions & 14 deletions client/src/containers/BulkDeleteConfirmation/DeletionModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';

const DeletionModal = ({ isOpen, body, onCancel, actions }) => (
<Modal isOpen={isOpen} toggle={onCancel}>
<ModalHeader toggle={onCancel}>
{i18n._t('AssetAdmin.CONFIRM_FILE_DELETION', 'Confirm deletion')}
</ModalHeader>
<ModalBody>{body}</ModalBody>
<ModalFooter>
{actions.map(({ label, handler, color }) => (
<Button key={label} color={color} onClick={handler}>{label}</Button>
))}
</ModalFooter>
</Modal>
);
const DeletionModal = ({ isOpen, body, onCancel, actions, archiveFiles }) => {
let transKey = 'AssetAdmin.CONFIRM_FILE_DELETION';
let transDefault = 'Confirm deletion';
if (archiveFiles) {
transKey = 'AssetAdmin.CONFIRM_FILE_ARCHIVE';
transDefault = 'Confirm archive';
}
return (
<Modal isOpen={isOpen} toggle={onCancel}>
<ModalHeader toggle={onCancel}>
{i18n._t(transKey, transDefault)}
</ModalHeader>
<ModalBody>{body}</ModalBody>
<ModalFooter>
{actions.map(({ label, handler, color }) => (
<Button key={label} color={color} onClick={handler}>{label}</Button>
))}
</ModalFooter>
</Modal>
);
};

DeletionModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
Expand All @@ -25,7 +33,8 @@ DeletionModal.propTypes = {
label: PropTypes.string.isRequired,
handler: PropTypes.func,
color: PropTypes.string
}))
})),
archiveFiles: PropTypes.bool.isRequired,
};

export default DeletionModal;
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const manyFilesProps = {

const getMessage = (count) => [
`You're about to delete ${count} file(s) which may be used in your site's content.`,
'Carefully check the file usage on the files before deleting the folder.'
'Carefully check the file usage on the files before deleting the file(s).'
].join(' ');

const emptyFolderMessage = 'Are you sure you want to delete this folder?';
Expand Down
Loading

0 comments on commit 5dea8dc

Please sign in to comment.