import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import { withUnstatedContainers } from '../../UnstatedUtils'; import { toastSuccess, toastError } from '../../../util/apiNotification'; import PaginationWrapper from '../../PaginationWrapper'; import AppContainer from '../../../services/AppContainer'; import AdminGeneralSecurityContainer from '../../../services/AdminGeneralSecurityContainer'; import DeleteAllShareLinksModal from './DeleteAllShareLinksModal'; class ShareLinkSetting extends React.Component { constructor() { super(); this.state = { shareLinks: [], isDeleteConfirmModalShown: false, }; this.getShareLinkList = this.getShareLinkList.bind(this); this.showDeleteConfirmModal = this.showDeleteConfirmModal.bind(this); this.closeDeleteConfirmModal = this.closeDeleteConfirmModal.bind(this); this.deleteAllLinksButtonHandler = this.deleteAllLinksButtonHandler.bind(this); } componentWillMount() { this.getShareLinkList(1); } async getShareLinkList(page) { try { await this.props.adminGeneralSecurityContainer.retrieveShareLinksByPagingNum(page); } catch (err) { toastError(err); } } showDeleteConfirmModal() { this.setState({ isDeleteConfirmModalShown: true }); } closeDeleteConfirmModal() { this.setState({ isDeleteConfirmModalShown: false }); } async deleteAllLinksButtonHandler() { const { t, appContainer } = this.props; try { const res = await appContainer.apiv3Delete('/share-links/all'); const { deletedCount } = res.data; toastSuccess(t('toaster.remove_share_link', { count: deletedCount })); } catch (err) { toastError(err); } } render() { const { adminGeneralSecurityContainer } = this.props; const pager = (
No share links
) ); return (| Link | PagePath | Expiration | Description | Order |
|---|---|---|---|---|
| {sharelink._id} | {sharelink.relatedPage.path} | {sharelink.expiredAt} | {sharelink.description} |