2022-11-28 09:27:17 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { seafileAPI } from '../../utils/seafile-api';
|
2024-12-24 11:20:40 +08:00
|
|
|
import { Modal, ModalBody, ModalFooter, Button } from 'reactstrap';
|
2022-11-28 09:27:17 +08:00
|
|
|
import { gettext } from '../../utils/constants';
|
|
|
|
import { Utils } from '../../utils/utils';
|
2024-12-24 11:20:40 +08:00
|
|
|
import SeahubModalHeader from '@/components/common/seahub-modal-header';
|
2022-11-28 09:27:17 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
repoID: PropTypes.string.isRequired,
|
|
|
|
path: PropTypes.string.isRequired,
|
|
|
|
deleteFolder: PropTypes.func.isRequired,
|
|
|
|
toggleDialog: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
class DeleteFolderDialog extends Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
sharedToUserCount: 0,
|
|
|
|
sharedToGroupCount: 0
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
const { repoID, path } = this.props;
|
|
|
|
seafileAPI.getRepoFolderShareInfo(repoID, path).then((res) => {
|
|
|
|
this.setState({
|
|
|
|
sharedToUserCount: res.data['shared_user_emails'].length,
|
|
|
|
sharedToGroupCount: res.data['shared_group_ids'].length
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
deleteFolder = () => {
|
|
|
|
this.props.deleteFolder();
|
|
|
|
this.props.toggleDialog();
|
2023-09-13 08:40:50 +08:00
|
|
|
};
|
2022-11-28 09:27:17 +08:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { sharedToUserCount, sharedToGroupCount } = this.state;
|
|
|
|
const { path, toggleDialog } = this.props;
|
|
|
|
const folderName = Utils.getFileName(path);
|
|
|
|
const opTarget = '<span class="op-target">' + Utils.HTMLescape(folderName) + '</span>';
|
2025-10-13 18:10:53 +08:00
|
|
|
const message = gettext('Are you sure you want to delete {placeholder} ?').replace('{placeholder}', opTarget);
|
2022-11-28 09:27:17 +08:00
|
|
|
|
|
|
|
let alert_message = '';
|
|
|
|
if (sharedToUserCount > 0 || sharedToGroupCount > 0) {
|
|
|
|
alert_message = gettext('This folder has been shared to {user_amount} user(s) and {group_amount} group(s).')
|
|
|
|
.replace('{user_amount}', sharedToUserCount)
|
|
|
|
.replace('{group_amount}', sharedToGroupCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal isOpen={true} toggle={toggleDialog}>
|
2024-12-24 11:20:40 +08:00
|
|
|
<SeahubModalHeader toggle={toggleDialog}>{gettext('Delete Folder')}</SeahubModalHeader>
|
2022-11-28 09:27:17 +08:00
|
|
|
<ModalBody>
|
2025-07-01 14:50:19 +08:00
|
|
|
<div className="pb-6">
|
|
|
|
<p dangerouslySetInnerHTML={{ __html: message }}></p>
|
|
|
|
{alert_message && <p className="error">{alert_message}</p>}
|
|
|
|
</div>
|
2022-11-28 09:27:17 +08:00
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
<Button color="secondary" onClick={toggleDialog}>{gettext('Cancel')}</Button>
|
|
|
|
<Button color="primary" onClick={this.deleteFolder}>{gettext('Delete')}</Button>
|
|
|
|
</ModalFooter>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteFolderDialog.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default DeleteFolderDialog;
|