forked from opencast/admin-interface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThemesActionsCell.tsx
More file actions
80 lines (70 loc) · 2.05 KB
/
ThemesActionsCell.tsx
File metadata and controls
80 lines (70 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { useRef } from "react";
import {
fetchThemeDetails,
fetchUsage,
} from "../../../slices/themeDetailsSlice";
import { useAppDispatch } from "../../../store";
import { deleteTheme, ThemeDetailsType } from "../../../slices/themeSlice";
import ThemeDetails from "./wizard/ThemeDetails";
import { ActionCellDelete } from "../../shared/ActionCellDelete";
import { Modal, ModalHandle } from "../../shared/modals/Modal";
import { useTranslation } from "react-i18next";
import ButtonLikeAnchor from "../../shared/ButtonLikeAnchor";
import { LuFileText } from "react-icons/lu";
/**
* This component renders the action cells of themes in the table view
*/
const ThemesActionsCell = ({
row,
}: {
row: ThemeDetailsType
}) => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const detailsModalRef = useRef<ModalHandle>(null);
const hideThemeDetails = () => {
detailsModalRef.current?.close?.();
};
const showThemeDetails = async () => {
await Promise.all([
dispatch(fetchThemeDetails(row.id)),
dispatch(fetchUsage(row.id)),
]);
detailsModalRef.current?.open();
};
const deletingTheme = (id: number) => {
dispatch(deleteTheme(id));
};
return (
<>
{/* edit themes */}
<ButtonLikeAnchor
onClick={() => showThemeDetails()}
className={"action-cell-button"}
editAccessRole={"ROLE_UI_THEMES_EDIT"}
tooltipText={"CONFIGURATION.THEMES.TABLE.TOOLTIP.DETAILS"}
>
<LuFileText />
</ButtonLikeAnchor>
{/* themes details modal */}
<Modal
header={t("CONFIGURATION.THEMES.DETAILS.EDITCAPTION", { name: row.name })}
classId="theme-details-modal"
ref={detailsModalRef}
>
{/* component that manages tabs of theme details modal*/}
<ThemeDetails close={hideThemeDetails} />
</Modal>
{/* delete themes */}
<ActionCellDelete
editAccessRole={"ROLE_UI_THEMES_DELETE"}
tooltipText={"CONFIGURATION.THEMES.TABLE.TOOLTIP.DELETE"}
resourceId={row.id}
resourceName={row.name}
resourceType={"THEME"}
deleteMethod={deletingTheme}
/>
</>
);
};
export default ThemesActionsCell;