Skip to content

Commit

Permalink
[dir view, toast] redesigned the 'converting' tip for md & sdoc file … (
Browse files Browse the repository at this point in the history
#5822)

* [dir view, toast] redesigned the 'converting' tip for md & sdoc file items; added a new type of toast

* [toast] updated the loading icon of the 'notify-in-progress' toast
  • Loading branch information
llj authored Dec 11, 2023
1 parent 7efe677 commit 8712b7d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 43 deletions.
19 changes: 0 additions & 19 deletions frontend/src/components/dialog/convert-markdown-dialog.js

This file was deleted.

2 changes: 2 additions & 0 deletions frontend/src/components/toast/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class Alert extends React.PureComponent {
return { borderStyle: this.containerBorderWarn, iconColor: css({color: 'rgb(217, 130, 43)'}) , iconClass: 'fa fa-exclamation-triangle' };
case 'none':
return { borderStyle: this.containerBorderNotify, iconColor: css({color: 'rgb(16, 112, 202)'}), iconClass: 'fa fa-exclamation-circle' };
case 'notify-in-progress':
return { borderStyle: this.containerBorderNotify, iconColor: css({width: '15px', height: '15px', margin: '3px'}), iconClass: 'loading-icon' };
case 'danger':
return { borderStyle: this.containerBorderDanger, iconColor: css({color: 'rgb(236, 76, 71)'}), iconClass: 'fa fa-exclamation-circle' };
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Toast extends React.PureComponent {
/**
* The type of the alert.
*/
intent: PropTypes.oneOf(['none', 'success', 'warning', 'danger']).isRequired,
intent: PropTypes.oneOf(['none', 'notify-in-progress', 'success', 'warning', 'danger']).isRequired,

/**
* The title of the alert.
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/toast/toaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export default class Toaster {
return this.notifyHandler(title, { ...settings, intent: 'none' });
};

notifyInProgress = (title, settings = {}) => {
return this.notifyHandler(title, { ...settings, intent: 'notify-in-progress' });
};

success = (title, settings = {}) => {
return this.notifyHandler(title, { ...settings, intent: 'success' });
};
Expand Down
14 changes: 0 additions & 14 deletions frontend/src/css/convert-markdown.css

This file was deleted.

11 changes: 2 additions & 9 deletions frontend/src/pages/lib-content-view/lib-content-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import LibContentContainer from './lib-content-container';
import FileUploader from '../../components/file-uploader/file-uploader';
import CopyMoveDirentProgressDialog from '../../components/dialog/copy-move-dirent-progress-dialog';
import DeleteFolderDialog from '../../components/dialog/delete-folder-dialog';
import ConvertMarkdownDialog from '../../components/dialog/convert-markdown-dialog';

const propTypes = {
pathPrefix: PropTypes.array.isRequired,
Expand Down Expand Up @@ -81,7 +80,6 @@ class LibContentView extends React.Component {
asyncOperationType: 'move',
asyncOperationProgress: 0,
asyncOperatedFilesLength: 0,
isConvertLoading: false,
};

this.oldonpopstate = window.onpopstate;
Expand Down Expand Up @@ -1263,7 +1261,7 @@ class LibContentView extends React.Component {
onConvertItem = (dirent, dstType) => {
let path = Utils.joinPath(this.state.path, dirent.name);
let repoID = this.props.repoID;
this.setState({isConvertLoading: true});
toaster.notifyInProgress(gettext('Converting, please wait...'));
seafileAPI.convertFile(repoID, path, dstType).then((res) => {
let newFileName = res.data.obj_name;
let parentDir = res.data.parent_dir;
Expand All @@ -1275,13 +1273,11 @@ class LibContentView extends React.Component {
}

this.addDirent(newFileName, 'file', res.data.size);
this.setState({isConvertLoading: false});
let message = gettext('Successfully converted the file.');
toaster.success(message);

}).catch((error) => {
let errMessage = Utils.getErrorMsg(error);
this.setState({isConvertLoading: false});
if (errMessage === gettext('Error')) {
let name = Utils.getFileName(path);
errMessage = gettext('Failed to convert {name}.').replace('{name}', name);
Expand Down Expand Up @@ -1963,7 +1959,7 @@ class LibContentView extends React.Component {
}

let enableDirPrivateShare = false;
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen, isConvertLoading } = this.state;
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen } = this.state;
let showShareBtn = Utils.isHasPermissionToShare(currentRepoInfo, userPerm);
let isRepoOwner = currentRepoInfo.owner_email === username;
let isVirtual = currentRepoInfo.is_virtual;
Expand Down Expand Up @@ -2127,9 +2123,6 @@ class LibContentView extends React.Component {
toggleDialog={this.toggleDeleteFolderDialog}
/>
)}
{isConvertLoading && (
<ConvertMarkdownDialog />
)}
</Fragment>
);
}
Expand Down

0 comments on commit 8712b7d

Please sign in to comment.