|
|
@@ -3,8 +3,11 @@ import PropTypes from 'prop-types';
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
|
import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
+import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
|
|
|
|
+import AppContainer from '../../../services/AppContainer';
|
|
|
import AdminGeneralSecurityContainer from '../../../services/AdminGeneralSecurityContainer';
|
|
|
+
|
|
|
import ShareLinkList from '../../ShareLinkList';
|
|
|
import DeleteAllShareLinksModal from './DeleteAllShareLinksModal';
|
|
|
|
|
|
@@ -20,6 +23,7 @@ class ShareLinkSetting extends React.Component {
|
|
|
|
|
|
this.showDeleteConfirmModal = this.showDeleteConfirmModal.bind(this);
|
|
|
this.closeDeleteConfirmModal = this.closeDeleteConfirmModal.bind(this);
|
|
|
+ this.deleteAllLinksButtonHandler = this.deleteAllLinksButtonHandler.bind(this);
|
|
|
}
|
|
|
|
|
|
showDeleteConfirmModal() {
|
|
|
@@ -30,11 +34,28 @@ class ShareLinkSetting extends React.Component {
|
|
|
this.setState({ isDeleteConfirmModalShown: false });
|
|
|
}
|
|
|
|
|
|
+ async deleteAllLinksButtonHandler() {
|
|
|
+ const { t, appContainer } = this.props;
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await appContainer.apiv3Delete('/share-links/all');
|
|
|
+ console.log(res);
|
|
|
+ const count = res.data.n;
|
|
|
+ toastSuccess(t('toaster.remove_share_link', { count }));
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ toastError(err);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
render() {
|
|
|
return (
|
|
|
<>
|
|
|
<h2 className="border-bottom mb-3">
|
|
|
Shared Link List
|
|
|
+
|
|
|
<button type="button" className="btn btn-danger pull-right" onClick={this.showDeleteConfirmModal}>Delete all links</button>
|
|
|
</h2>
|
|
|
|
|
|
@@ -46,6 +67,8 @@ class ShareLinkSetting extends React.Component {
|
|
|
<DeleteAllShareLinksModal
|
|
|
isOpen={this.state.isDeleteConfirmModalShown}
|
|
|
onClose={this.closeDeleteConfirmModal}
|
|
|
+ count={this.state.shareLinks.length}
|
|
|
+ onClickDeleteButton={this.deleteAllLinksButtonHandler}
|
|
|
/>
|
|
|
|
|
|
</>
|
|
|
@@ -54,10 +77,13 @@ class ShareLinkSetting extends React.Component {
|
|
|
|
|
|
}
|
|
|
|
|
|
-const ShareLinkSettingWrapper = withUnstatedContainers(ShareLinkSetting, [AdminGeneralSecurityContainer]);
|
|
|
+const ShareLinkSettingWrapper = withUnstatedContainers(ShareLinkSetting, [AppContainer, AdminGeneralSecurityContainer]);
|
|
|
|
|
|
ShareLinkSetting.propTypes = {
|
|
|
+ t: PropTypes.func.isRequired, // i18next
|
|
|
+
|
|
|
adminGeneralSecurityContainer: PropTypes.instanceOf(AdminGeneralSecurityContainer).isRequired,
|
|
|
+ appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
};
|
|
|
|
|
|
export default withTranslation()(ShareLinkSettingWrapper);
|