Skip to content

Commit

Permalink
After QA
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasOsti committed Apr 12, 2024
1 parent df70b32 commit c770f94
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/bundle/Resources/public/img/icons/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,19 @@
<target state="new">Upload file</target>
<note>key: upload_btn.label</note>
</trans-unit>
<trans-unit id="19d5456f3b1299d65b92474d58e70ff787010ba1" resname="upload_popup.cancel_label">
<source>Cancel pending upload</source>
<target state="new">Cancel pending upload</target>
<note>key: upload_popup.cancel_label</note>
</trans-unit>
<trans-unit id="36999e5e928304452a57984fe9fb29daef497121" resname="upload_popup.close_label">
<source>Confirm and close</source>
<target state="new">Confirm and close</target>
<source>Close</source>
<target state="new">Close</target>
<note>key: upload_popup.close_label</note>
</trans-unit>
<trans-unit id="69ca9f45ba70d7b75027057e8b1f23057801a70e" resname="upload_popup.confirm_label">
<source>Cancel pending upload</source>
<target state="new">Cancel pending upload</target>
<source>Confirm and close</source>
<target state="new">Confirm and close</target>
<note>key: upload_popup.confirm_label</note>
</trans-unit>
<trans-unit id="8964e0ca9f836009ee40abf9e9b013b41b2dd2d4" resname="upload_popup.label">
Expand Down
2 changes: 2 additions & 0 deletions src/bundle/ui-dev/src/modules/common/icon/inculdedIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import User from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/user.svg
import UserGroup from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/user_group.svg';
import Upload from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/upload.svg';
import UploadImage from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/upload-image.svg';
import Warning from '@ibexa-admin-ui/src/bundle/Resources/public/img/icons/warning.svg';

const iconsMap = {
about: About,
Expand Down Expand Up @@ -69,6 +70,7 @@ const iconsMap = {
user_group: UserGroup,
upload: Upload,
'upload-image': UploadImage,
warning: Warning
};

const InculdedIcon = (props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ PaginationButton.propTypes = {
label: PropTypes.string,
disabled: PropTypes.bool,
onPageChange: PropTypes.func,
pageIndex: PropTypes.number.isRequired,
pageIndex: PropTypes.number,
additionalClasses: PropTypes.string,
buttonAdditionalClasses: PropTypes.string,
};

PaginationButton.defaultProps = {
pageIndex: null,
label: '',
disabled: false,
additionalClasses: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,15 @@ export default class UploadItemComponent extends Component {
const label = Translator.trans(/*@Desc("Abort")*/ 'abort.label', {}, 'ibexa_multi_file_upload');

return (
<div
<button
className="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text ibexa-btn--small c-upload-list-item__action c-upload-list-item__action--abort"
onClick={this.abortUploading}
title={label}
tabIndex="-1"
type="button"
>
<Icon name="trash" extraClasses="ibexa-icon--small" />
</div>
</button>
);
}

Expand All @@ -373,7 +374,7 @@ export default class UploadItemComponent extends Component {

renderEditBtn() {
const Translator = getTranslator();
const { uploaded, failed } = this.state;
const { uploaded, failed, struct } = this.state;
const canEdit = uploaded && !failed;

if (!canEdit || this.isExternalInstance) {
Expand All @@ -383,19 +384,21 @@ export default class UploadItemComponent extends Component {
const label = Translator.trans(/*@Desc("Edit")*/ 'edit.label', {}, 'ibexa_multi_file_upload');

return (
<div
<button
className="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text ibexa-btn--small c-upload-list-item__action c-upload-list-item__action--edit"
title={label}
onClick={this.handleEditBtnClick}
tabIndex="-1"
type="button"
disabled={!struct}
>
<Icon name="edit" extraClasses="ibexa-icon--small" />
</div>
</button>
);
}

renderDeleteBtn() {
const { uploaded, aborted, failed } = this.state;
const { uploaded, aborted, failed, struct } = this.state;
const canDelete = (uploaded && !aborted) || failed;

if (!canDelete) {
Expand All @@ -406,14 +409,16 @@ export default class UploadItemComponent extends Component {
const label = Translator.trans(/*@Desc("Delete")*/ 'delete.label', {}, 'ibexa_multi_file_upload');

return (
<div
<button
className="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text ibexa-btn--small c-upload-list-item__action c-upload-list-item__action--delete"
onClick={this.deleteFile}
title={label}
tabIndex="-1"
type="button"
disabled={!(struct || failed)}
>
<Icon name="trash" extraClasses="ibexa-icon--small" />
</div>
</button>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ export default class UploadListComponent extends Component {
};
}

componentDidUpdate() {
this.props.onAfterUpload(this.state.items);
}

handleAfterUpload(item) {
this.props.removeItemsToUpload([item]);
this.setState((state) => ({
items: [...state.items, item],
}));
this.setState(
(state) => {
return {
items: [...state.items, item],
};
},
() => {
this.props.removeItemsToUpload([item]);
this.props.onAfterUpload(this.state.items);
},
);
}

handleAfterAbort(item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class UploadPopupModule extends Component {

maxFileSizes.push({
name: contentTypeName,
maxFileSize: contentTypeMapping.maxFileSize || defaultMaxFileSize,
maxFileSize: contentTypeMapping?.maxFileSize || defaultMaxFileSize,
});

return maxFileSizes;
Expand All @@ -48,7 +48,18 @@ export default class UploadPopupModule extends Component {

render() {
const Translator = getTranslator();
const hasAnyUploadedItems = !!this.props.uploadedItems.length;
const hasAnyItemsToUpload = !!this.props.itemsToUpload.length;
const label = Translator.trans(/*@Desc("Upload")*/ 'upload_popup.label', {}, 'ibexa_multi_file_upload');
const confirmBtnLabel =
!hasAnyUploadedItems && !hasAnyItemsToUpload
? Translator.trans(/*@Desc("Close")*/ 'upload_popup.close_label', {}, 'ibexa_multi_file_upload')
: Translator.trans(/*@Desc("Confirm and close")*/ 'upload_popup.confirm_label', {}, 'ibexa_multi_file_upload');
const closeBtnLabel = Translator.trans(
/*@Desc("Cancel pending upload")*/ 'upload_popup.cancel_label',
{},
'ibexa_multi_file_upload',
);
const {
addItemsToUpload,
subtitle,
Expand Down Expand Up @@ -77,8 +88,8 @@ export default class UploadPopupModule extends Component {
onConfirm,
onClose,
title: Translator.trans(/*@Desc("Multi-file upload")*/ 'upload_popup.title', {}, 'ibexa_multi_file_upload'),
confirmLabel: Translator.trans(/*@Desc("Confirm and close")*/ 'upload_popup.close_label', {}, 'ibexa_multi_file_upload'),
closeLabel: Translator.trans(/*@Desc("Cancel pending upload")*/ 'upload_popup.confirm_label', {}, 'ibexa_multi_file_upload'),
confirmLabel: confirmBtnLabel,
closeLabel: closeBtnLabel,
confirmBtnAttrs: {
disabled: itemsToUpload.length,
},
Expand Down Expand Up @@ -123,6 +134,7 @@ UploadPopupModule.propTypes = {
subtitle: PropTypes.string,
visible: PropTypes.bool,
itemsToUpload: PropTypes.array,
uploadedItems: PropTypes.array,
onAfterUpload: PropTypes.func.isRequired,
createFileStruct: PropTypes.func.isRequired,
publishFile: PropTypes.func.isRequired,
Expand Down Expand Up @@ -157,6 +169,7 @@ UploadPopupModule.defaultProps = {
subtitle: '',
visible: true,
itemsToUpload: [],
uploadedItems: [],
currentLanguage: '',
contentCreatePermissionsConfig: {},
onConfirm: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export default class MultiFileUploadModule extends Component {
onClose: this.hidePopup,
onConfirm: this.confirmPopup,
itemsToUpload: this.state.itemsToUpload,
uploadedItems: this._itemsUploaded,
onAfterUpload: this.handleAfterUpload,
onAfterDelete: this.handleAfterDelete,
preventDefaultAction: this.preventDefaultAction,
Expand Down

0 comments on commit c770f94

Please sign in to comment.