mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-15 03:01:37 -05:00
Removed "Remove" button from recommendation list
refs https://github.com/TryGhost/Product/issues/3899
This commit is contained in:
parent
a66d811236
commit
308a76faf3
1 changed files with 2 additions and 36 deletions
|
@ -1,6 +1,3 @@
|
|||
import Button from '../../../../admin-x-ds/global/Button';
|
||||
import ConfirmationModal from '../../../../admin-x-ds/global/modal/ConfirmationModal';
|
||||
import NiceModal from '@ebay/nice-modal-react';
|
||||
import NoValueLabel from '../../../../admin-x-ds/global/NoValueLabel';
|
||||
import React from 'react';
|
||||
import RecommendationIcon from './RecommendationIcon';
|
||||
|
@ -9,8 +6,7 @@ import TableCell from '../../../../admin-x-ds/global/TableCell';
|
|||
import TableRow from '../../../../admin-x-ds/global/TableRow';
|
||||
import useRouting from '../../../../hooks/useRouting';
|
||||
import {PaginationData} from '../../../../hooks/usePagination';
|
||||
import {Recommendation, useDeleteRecommendation} from '../../../../api/recommendations';
|
||||
import {showToast} from '../../../../admin-x-ds/global/Toast';
|
||||
import {Recommendation} from '../../../../api/recommendations';
|
||||
|
||||
interface RecommendationListProps {
|
||||
recommendations: Recommendation[],
|
||||
|
@ -20,36 +16,6 @@ interface RecommendationListProps {
|
|||
|
||||
const RecommendationItem: React.FC<{recommendation: Recommendation}> = ({recommendation}) => {
|
||||
const {updateRoute} = useRouting();
|
||||
const {mutateAsync: deleteRecommendation} = useDeleteRecommendation();
|
||||
|
||||
const action = (
|
||||
<div className="flex items-center justify-end">
|
||||
<Button color='red' label='Remove' link onClick={() => {
|
||||
NiceModal.show(ConfirmationModal, {
|
||||
title: 'Remove recommendation',
|
||||
prompt: <>
|
||||
<p>Your recommendation <strong>{recommendation.title}</strong> will no longer be visible to your audience.</p>
|
||||
</>,
|
||||
okLabel: 'Remove',
|
||||
onOk: async (modal) => {
|
||||
try {
|
||||
await deleteRecommendation(recommendation);
|
||||
modal?.remove();
|
||||
showToast({
|
||||
message: 'Successfully removed the recommendation',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (_) {
|
||||
showToast({
|
||||
message: 'Failed to remove the recommendation. Please try again later.',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}} />
|
||||
</div>
|
||||
);
|
||||
|
||||
const showDetails = () => {
|
||||
updateRoute({route: `recommendations/${recommendation.id}`});
|
||||
|
@ -59,7 +25,7 @@ const RecommendationItem: React.FC<{recommendation: Recommendation}> = ({recomme
|
|||
const count = (showSubscribes ? recommendation.count?.subscribers : recommendation.count?.clicks) || 0;
|
||||
|
||||
return (
|
||||
<TableRow action={action} hideActions>
|
||||
<TableRow>
|
||||
<TableCell onClick={showDetails}>
|
||||
<div className='group flex items-center gap-3 hover:cursor-pointer'>
|
||||
<div className={`flex grow flex-col`}>
|
||||
|
|
Loading…
Add table
Reference in a new issue