360 lines
13 KiB
JavaScript
360 lines
13 KiB
JavaScript
import {
|
||
Header,
|
||
Root,
|
||
useReviewWorkflows
|
||
} from "./chunk-HDN4UDJS.js";
|
||
import {
|
||
CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME,
|
||
LimitsModal,
|
||
useGetContentTypesQuery
|
||
} from "./chunk-E3IW2VDN.js";
|
||
import {
|
||
useTypedSelector
|
||
} from "./chunk-MN3D3XJI.js";
|
||
import "./chunk-C7H2BX76.js";
|
||
import "./chunk-QF6GPHA4.js";
|
||
import "./chunk-S3HPKOXW.js";
|
||
import "./chunk-JRLAXHTE.js";
|
||
import "./chunk-E4IFZ6ZT.js";
|
||
import "./chunk-QLEKUQKW.js";
|
||
import "./chunk-4J3VOWQV.js";
|
||
import "./chunk-PFI4R5WA.js";
|
||
import {
|
||
useLicenseLimits
|
||
} from "./chunk-G2UWKDMB.js";
|
||
import "./chunk-B3BGMYGX.js";
|
||
import "./chunk-W6ICJ5TB.js";
|
||
import "./chunk-IHYIPMY2.js";
|
||
import "./chunk-UWHSN2C7.js";
|
||
import "./chunk-ERK7O2GM.js";
|
||
import "./chunk-FCIM6RNO.js";
|
||
import "./chunk-J33IXKN4.js";
|
||
import {
|
||
ConfirmDialog
|
||
} from "./chunk-NP53ZCXD.js";
|
||
import "./chunk-MBK4V2X7.js";
|
||
import "./chunk-5ESYXDTN.js";
|
||
import "./chunk-K65KIEAL.js";
|
||
import "./chunk-B7ZLODDO.js";
|
||
import "./chunk-PW7XKCYO.js";
|
||
import "./chunk-RMBEU7DO.js";
|
||
import "./chunk-RI2W2UZ6.js";
|
||
import "./chunk-IY256CNP.js";
|
||
import "./chunk-IFOFBKTA.js";
|
||
import "./chunk-XLSIZGJF.js";
|
||
import "./chunk-EGNP2T5O.js";
|
||
import {
|
||
useTracking
|
||
} from "./chunk-GSN7U3BK.js";
|
||
import "./chunk-T3B5F2LV.js";
|
||
import "./chunk-YXDCVYVT.js";
|
||
import "./chunk-QIJGNK42.js";
|
||
import "./chunk-7PUJSL55.js";
|
||
import "./chunk-C2ZJTFO7.js";
|
||
import "./chunk-C75BZXCZ.js";
|
||
import "./chunk-APGTER6B.js";
|
||
import {
|
||
Table
|
||
} from "./chunk-ZM6TT53G.js";
|
||
import "./chunk-6AXVGFVQ.js";
|
||
import "./chunk-BFLP6DBI.js";
|
||
import {
|
||
useRBAC
|
||
} from "./chunk-CMLQV3Z2.js";
|
||
import "./chunk-IGCTEXRF.js";
|
||
import "./chunk-TIVRAWTC.js";
|
||
import "./chunk-PQINNV4N.js";
|
||
import "./chunk-VYSYYPOB.js";
|
||
import {
|
||
Page
|
||
} from "./chunk-5CAWUBTQ.js";
|
||
import "./chunk-W2TBR6J3.js";
|
||
import "./chunk-QEGMJR7H.js";
|
||
import "./chunk-LCL5TIBZ.js";
|
||
import "./chunk-WOQNBAGN.js";
|
||
import "./chunk-BHLYCXQ7.js";
|
||
import "./chunk-76QM3EFM.js";
|
||
import "./chunk-CE4VABH2.js";
|
||
import "./chunk-5VODLFKF.js";
|
||
import "./chunk-N55RVBRV.js";
|
||
import {
|
||
Dialog,
|
||
Flex,
|
||
IconButton,
|
||
LinkButton,
|
||
TFooter,
|
||
Typography,
|
||
useIntl
|
||
} from "./chunk-7XB6XSWQ.js";
|
||
import "./chunk-5ZC4PE57.js";
|
||
import {
|
||
Link,
|
||
NavLink,
|
||
useNavigate
|
||
} from "./chunk-TUXTO2Z5.js";
|
||
import "./chunk-FOD4ENRR.js";
|
||
import {
|
||
ForwardRef$1h,
|
||
ForwardRef$1v,
|
||
ForwardRef$j
|
||
} from "./chunk-WRD5KPDH.js";
|
||
import {
|
||
require_jsx_runtime
|
||
} from "./chunk-NIAJZ5MX.js";
|
||
import "./chunk-ACIMPXWY.js";
|
||
import {
|
||
require_react
|
||
} from "./chunk-MADUDGYZ.js";
|
||
import {
|
||
__toESM
|
||
} from "./chunk-PLDDJCW6.js";
|
||
|
||
// node_modules/@strapi/review-workflows/dist/admin/routes/settings/index.mjs
|
||
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
||
var React = __toESM(require_react(), 1);
|
||
var ReviewWorkflowsListView = () => {
|
||
const { formatMessage } = useIntl();
|
||
const navigate = useNavigate();
|
||
const { trackUsage } = useTracking();
|
||
const [workflowToDelete, setWorkflowToDelete] = React.useState(null);
|
||
const [showLimitModal, setShowLimitModal] = React.useState(false);
|
||
const { data, isLoading: isLoadingModels } = useGetContentTypesQuery();
|
||
const { meta, workflows, isLoading, delete: deleteAction } = useReviewWorkflows();
|
||
const { getFeature, isLoading: isLicenseLoading } = useLicenseLimits();
|
||
const permissions = useTypedSelector((state) => {
|
||
var _a;
|
||
return (_a = state.admin_app.permissions.settings) == null ? void 0 : _a["review-workflows"];
|
||
});
|
||
const { allowedActions: { canCreate, canRead, canUpdate, canDelete } } = useRBAC(permissions);
|
||
const limits = getFeature("review-workflows");
|
||
const numberOfWorkflows = limits == null ? void 0 : limits[CHARGEBEE_WORKFLOW_ENTITLEMENT_NAME];
|
||
const handleDeleteWorkflow = (workflowId) => {
|
||
setWorkflowToDelete(workflowId);
|
||
};
|
||
const toggleConfirmDeleteDialog = () => {
|
||
setWorkflowToDelete(null);
|
||
};
|
||
const handleConfirmDeleteDialog = async () => {
|
||
if (!workflowToDelete) return;
|
||
await deleteAction(workflowToDelete);
|
||
setWorkflowToDelete(null);
|
||
};
|
||
const handleCreateClick = (event) => {
|
||
event.preventDefault();
|
||
if (numberOfWorkflows && meta && (meta == null ? void 0 : meta.workflowCount) >= parseInt(numberOfWorkflows, 10)) {
|
||
event.preventDefault();
|
||
setShowLimitModal(true);
|
||
} else {
|
||
navigate("create");
|
||
trackUsage("willCreateWorkflow");
|
||
}
|
||
};
|
||
React.useEffect(() => {
|
||
if (!isLoading && !isLicenseLoading) {
|
||
if (numberOfWorkflows && meta && (meta == null ? void 0 : meta.workflowCount) > parseInt(numberOfWorkflows, 10)) {
|
||
setShowLimitModal(true);
|
||
}
|
||
}
|
||
}, [
|
||
isLicenseLoading,
|
||
isLoading,
|
||
meta,
|
||
meta == null ? void 0 : meta.workflowCount,
|
||
numberOfWorkflows
|
||
]);
|
||
const headers = [
|
||
{
|
||
label: formatMessage({
|
||
id: "Settings.review-workflows.list.page.list.column.name.title",
|
||
defaultMessage: "Name"
|
||
}),
|
||
name: "name"
|
||
},
|
||
{
|
||
label: formatMessage({
|
||
id: "Settings.review-workflows.list.page.list.column.stages.title",
|
||
defaultMessage: "Stages"
|
||
}),
|
||
name: "stages"
|
||
},
|
||
{
|
||
label: formatMessage({
|
||
id: "Settings.review-workflows.list.page.list.column.contentTypes.title",
|
||
defaultMessage: "Content Types"
|
||
}),
|
||
name: "content-types"
|
||
}
|
||
];
|
||
if (isLoading || isLoadingModels) {
|
||
return (0, import_jsx_runtime.jsx)(Page.Loading, {});
|
||
}
|
||
const contentTypes = Object.values(data ?? {}).reduce((acc, curr) => {
|
||
acc.push(...curr);
|
||
return acc;
|
||
}, []);
|
||
return (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
||
children: [
|
||
(0, import_jsx_runtime.jsx)(Header, {
|
||
primaryAction: canCreate ? (0, import_jsx_runtime.jsx)(LinkButton, {
|
||
startIcon: (0, import_jsx_runtime.jsx)(ForwardRef$1h, {}),
|
||
size: "S",
|
||
tag: NavLink,
|
||
to: "create",
|
||
onClick: handleCreateClick,
|
||
children: formatMessage({
|
||
id: "Settings.review-workflows.list.page.create",
|
||
defaultMessage: "Create new workflow"
|
||
})
|
||
}) : null,
|
||
subtitle: formatMessage({
|
||
id: "Settings.review-workflows.list.page.subtitle",
|
||
defaultMessage: "Manage your content review process"
|
||
}),
|
||
title: formatMessage({
|
||
id: "Settings.review-workflows.list.page.title",
|
||
defaultMessage: "Review Workflows"
|
||
})
|
||
}),
|
||
(0, import_jsx_runtime.jsxs)(Root, {
|
||
children: [
|
||
(0, import_jsx_runtime.jsx)(Table.Root, {
|
||
isLoading,
|
||
rows: workflows,
|
||
footer: canCreate ? (0, import_jsx_runtime.jsx)(TFooter, {
|
||
cursor: "pointer",
|
||
icon: (0, import_jsx_runtime.jsx)(ForwardRef$1h, {}),
|
||
onClick: handleCreateClick,
|
||
children: formatMessage({
|
||
id: "Settings.review-workflows.list.page.create",
|
||
defaultMessage: "Create new workflow"
|
||
})
|
||
}) : null,
|
||
headers,
|
||
children: (0, import_jsx_runtime.jsxs)(Table.Content, {
|
||
children: [
|
||
(0, import_jsx_runtime.jsx)(Table.Head, {
|
||
children: headers.map((head) => (0, import_jsx_runtime.jsx)(Table.HeaderCell, {
|
||
...head
|
||
}, head.name))
|
||
}),
|
||
(0, import_jsx_runtime.jsx)(Table.Body, {
|
||
children: workflows.map((workflow) => (0, import_jsx_runtime.jsxs)(Table.Row, {
|
||
onClick: () => {
|
||
navigate(`${workflow.id}`);
|
||
},
|
||
children: [
|
||
(0, import_jsx_runtime.jsx)(Table.Cell, {
|
||
width: "25rem",
|
||
children: (0, import_jsx_runtime.jsx)(Typography, {
|
||
textColor: "neutral800",
|
||
fontWeight: "bold",
|
||
ellipsis: true,
|
||
children: workflow.name
|
||
})
|
||
}),
|
||
(0, import_jsx_runtime.jsx)(Table.Cell, {
|
||
children: (0, import_jsx_runtime.jsx)(Typography, {
|
||
textColor: "neutral800",
|
||
children: workflow.stages.length
|
||
})
|
||
}),
|
||
(0, import_jsx_runtime.jsx)(Table.Cell, {
|
||
children: (0, import_jsx_runtime.jsx)(Typography, {
|
||
textColor: "neutral800",
|
||
children: workflow.contentTypes.map((uid) => {
|
||
const contentType = contentTypes.find((contentType2) => contentType2.uid === uid);
|
||
return (contentType == null ? void 0 : contentType.info.displayName) ?? "";
|
||
}).join(", ")
|
||
})
|
||
}),
|
||
(0, import_jsx_runtime.jsx)(Table.Cell, {
|
||
children: (0, import_jsx_runtime.jsxs)(Flex, {
|
||
alignItems: "center",
|
||
justifyContent: "end",
|
||
children: [
|
||
canRead || canUpdate ? (0, import_jsx_runtime.jsx)(IconButton, {
|
||
tag: Link,
|
||
to: workflow.id.toString(),
|
||
label: formatMessage({
|
||
id: "Settings.review-workflows.list.page.list.column.actions.edit.label",
|
||
defaultMessage: "Edit {name}"
|
||
}, {
|
||
name: workflow.name
|
||
}),
|
||
variant: "ghost",
|
||
children: (0, import_jsx_runtime.jsx)(ForwardRef$1v, {})
|
||
}) : null,
|
||
workflows.length > 1 && canDelete ? (0, import_jsx_runtime.jsx)(IconButton, {
|
||
withTooltip: false,
|
||
label: formatMessage({
|
||
id: "Settings.review-workflows.list.page.list.column.actions.delete.label",
|
||
defaultMessage: "Delete {name}"
|
||
}, {
|
||
name: "Default workflow"
|
||
}),
|
||
variant: "ghost",
|
||
onClick: (e) => {
|
||
e.stopPropagation();
|
||
handleDeleteWorkflow(String(workflow.id));
|
||
},
|
||
children: (0, import_jsx_runtime.jsx)(ForwardRef$j, {})
|
||
}) : null
|
||
]
|
||
})
|
||
})
|
||
]
|
||
}, workflow.id))
|
||
})
|
||
]
|
||
})
|
||
}),
|
||
(0, import_jsx_runtime.jsx)(Dialog.Root, {
|
||
open: !!workflowToDelete,
|
||
onOpenChange: toggleConfirmDeleteDialog,
|
||
children: (0, import_jsx_runtime.jsx)(ConfirmDialog, {
|
||
onConfirm: handleConfirmDeleteDialog,
|
||
children: formatMessage({
|
||
id: "Settings.review-workflows.list.page.delete.confirm.body",
|
||
defaultMessage: "If you remove this worfklow, all stage-related information will be removed for this content-type. Are you sure you want to remove it?"
|
||
})
|
||
})
|
||
}),
|
||
(0, import_jsx_runtime.jsxs)(LimitsModal.Root, {
|
||
open: showLimitModal,
|
||
onOpenChange: () => setShowLimitModal(false),
|
||
children: [
|
||
(0, import_jsx_runtime.jsx)(LimitsModal.Title, {
|
||
children: formatMessage({
|
||
id: "Settings.review-workflows.list.page.workflows.limit.title",
|
||
defaultMessage: "You’ve reached the limit of workflows in your plan"
|
||
})
|
||
}),
|
||
(0, import_jsx_runtime.jsx)(LimitsModal.Body, {
|
||
children: formatMessage({
|
||
id: "Settings.review-workflows.list.page.workflows.limit.body",
|
||
defaultMessage: "Delete a workflow or contact Sales to enable more workflows."
|
||
})
|
||
})
|
||
]
|
||
})
|
||
]
|
||
})
|
||
]
|
||
});
|
||
};
|
||
var ProtectedListPage = () => {
|
||
const permissions = useTypedSelector((state) => {
|
||
var _a, _b;
|
||
return (_b = (_a = state.admin_app.permissions.settings) == null ? void 0 : _a["review-workflows"]) == null ? void 0 : _b.main;
|
||
});
|
||
return (0, import_jsx_runtime.jsx)(Page.Protect, {
|
||
permissions,
|
||
children: (0, import_jsx_runtime.jsx)(ReviewWorkflowsListView, {})
|
||
});
|
||
};
|
||
export {
|
||
ProtectedListPage,
|
||
ReviewWorkflowsListView
|
||
};
|
||
//# sourceMappingURL=settings-FDYE2MN3.js.map
|