272 lines
8.2 KiB
JavaScript
272 lines
8.2 KiB
JavaScript
import {
|
|
DocumentStatus,
|
|
RelativeTime
|
|
} from "./chunk-7FUKGPNR.js";
|
|
import {
|
|
contentManagerApi
|
|
} from "./chunk-P4VL3IHZ.js";
|
|
import "./chunk-QF6GPHA4.js";
|
|
import "./chunk-JRLAXHTE.js";
|
|
import {
|
|
Widget
|
|
} from "./chunk-E4IFZ6ZT.js";
|
|
import "./chunk-QLEKUQKW.js";
|
|
import "./chunk-4J3VOWQV.js";
|
|
import "./chunk-PFI4R5WA.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 "./chunk-NP53ZCXD.js";
|
|
import "./chunk-KFLQQE5L.js";
|
|
import "./chunk-ED4XR3VQ.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 "./chunk-ZM6TT53G.js";
|
|
import "./chunk-6AXVGFVQ.js";
|
|
import "./chunk-BFLP6DBI.js";
|
|
import "./chunk-CMLQV3Z2.js";
|
|
import "./chunk-D4WYVNVM.js";
|
|
import "./chunk-MMOBCIZG.js";
|
|
import "./chunk-IGCTEXRF.js";
|
|
import "./chunk-TIVRAWTC.js";
|
|
import "./chunk-PQINNV4N.js";
|
|
import "./chunk-VYSYYPOB.js";
|
|
import "./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 {
|
|
Box,
|
|
IconButton,
|
|
Table,
|
|
Tbody,
|
|
Td,
|
|
Tr,
|
|
Typography,
|
|
useIntl
|
|
} from "./chunk-7XB6XSWQ.js";
|
|
import "./chunk-5ZC4PE57.js";
|
|
import {
|
|
Link,
|
|
useNavigate
|
|
} from "./chunk-TUXTO2Z5.js";
|
|
import "./chunk-FOD4ENRR.js";
|
|
import {
|
|
ForwardRef$1v
|
|
} from "./chunk-WRD5KPDH.js";
|
|
import {
|
|
require_jsx_runtime
|
|
} from "./chunk-NIAJZ5MX.js";
|
|
import {
|
|
dt
|
|
} from "./chunk-ACIMPXWY.js";
|
|
import "./chunk-MADUDGYZ.js";
|
|
import {
|
|
__toESM
|
|
} from "./chunk-PLDDJCW6.js";
|
|
|
|
// node_modules/@strapi/content-manager/dist/admin/components/Widgets.mjs
|
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
|
|
// node_modules/@strapi/content-manager/dist/admin/services/homepage.mjs
|
|
var homepageService = contentManagerApi.enhanceEndpoints({
|
|
addTagTypes: [
|
|
"RecentDocumentList"
|
|
]
|
|
}).injectEndpoints({
|
|
/**
|
|
* TODO: Remove overrideExisting when we remove the future flag
|
|
* and delete the old homepage service in the admin
|
|
*/
|
|
overrideExisting: true,
|
|
endpoints: (builder) => ({
|
|
getRecentDocuments: builder.query({
|
|
query: (params) => `/content-manager/homepage/recent-documents?action=${params.action}`,
|
|
transformResponse: (response) => response.data,
|
|
providesTags: (res, _err, { action }) => [
|
|
{
|
|
type: "RecentDocumentList",
|
|
id: action
|
|
}
|
|
]
|
|
})
|
|
})
|
|
});
|
|
var { useGetRecentDocumentsQuery } = homepageService;
|
|
|
|
// node_modules/@strapi/content-manager/dist/admin/components/Widgets.mjs
|
|
var CellTypography = dt(Typography).attrs({
|
|
maxWidth: "14.4rem",
|
|
display: "block"
|
|
})`
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
`;
|
|
var RecentDocumentsTable = ({ documents }) => {
|
|
const { formatMessage } = useIntl();
|
|
const { trackUsage } = useTracking();
|
|
const navigate = useNavigate();
|
|
const getEditViewLink = (document) => {
|
|
const isSingleType = document.kind === "singleType";
|
|
const kindPath = isSingleType ? "single-types" : "collection-types";
|
|
const queryParams = document.locale ? `?plugins[i18n][locale]=${document.locale}` : "";
|
|
return `/content-manager/${kindPath}/${document.contentTypeUid}${isSingleType ? "" : "/" + document.documentId}${queryParams}`;
|
|
};
|
|
const handleRowClick = (document) => () => {
|
|
trackUsage("willEditEntryFromHome");
|
|
const link = getEditViewLink(document);
|
|
navigate(link);
|
|
};
|
|
return (0, import_jsx_runtime.jsx)(Table, {
|
|
colCount: 5,
|
|
rowCount: (documents == null ? void 0 : documents.length) ?? 0,
|
|
children: (0, import_jsx_runtime.jsx)(Tbody, {
|
|
children: documents == null ? void 0 : documents.map((document) => (0, import_jsx_runtime.jsxs)(Tr, {
|
|
onClick: handleRowClick(document),
|
|
cursor: "pointer",
|
|
children: [
|
|
(0, import_jsx_runtime.jsx)(Td, {
|
|
children: (0, import_jsx_runtime.jsx)(CellTypography, {
|
|
title: document.title,
|
|
variant: "omega",
|
|
textColor: "neutral800",
|
|
children: document.title
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Td, {
|
|
children: (0, import_jsx_runtime.jsx)(CellTypography, {
|
|
variant: "omega",
|
|
textColor: "neutral600",
|
|
children: document.kind === "singleType" ? formatMessage({
|
|
id: "content-manager.widget.last-edited.single-type",
|
|
defaultMessage: "Single-Type"
|
|
}) : formatMessage({
|
|
id: document.contentTypeDisplayName,
|
|
defaultMessage: document.contentTypeDisplayName
|
|
})
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Td, {
|
|
children: (0, import_jsx_runtime.jsx)(Box, {
|
|
display: "inline-block",
|
|
children: document.status ? (0, import_jsx_runtime.jsx)(DocumentStatus, {
|
|
status: document.status
|
|
}) : (0, import_jsx_runtime.jsx)(Typography, {
|
|
textColor: "neutral600",
|
|
"aria-hidden": true,
|
|
children: "-"
|
|
})
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Td, {
|
|
children: (0, import_jsx_runtime.jsx)(Typography, {
|
|
textColor: "neutral600",
|
|
children: (0, import_jsx_runtime.jsx)(RelativeTime, {
|
|
timestamp: new Date(document.updatedAt)
|
|
})
|
|
})
|
|
}),
|
|
(0, import_jsx_runtime.jsx)(Td, {
|
|
onClick: (e) => e.stopPropagation(),
|
|
children: (0, import_jsx_runtime.jsx)(Box, {
|
|
display: "inline-block",
|
|
children: (0, import_jsx_runtime.jsx)(IconButton, {
|
|
tag: Link,
|
|
to: getEditViewLink(document),
|
|
onClick: () => trackUsage("willEditEntryFromHome"),
|
|
label: formatMessage({
|
|
id: "content-manager.actions.edit.label",
|
|
defaultMessage: "Edit"
|
|
}),
|
|
variant: "ghost",
|
|
children: (0, import_jsx_runtime.jsx)(ForwardRef$1v, {})
|
|
})
|
|
})
|
|
})
|
|
]
|
|
}, document.documentId))
|
|
})
|
|
});
|
|
};
|
|
var LastEditedWidget = () => {
|
|
const { formatMessage } = useIntl();
|
|
const { data, isLoading, error } = useGetRecentDocumentsQuery({
|
|
action: "update"
|
|
});
|
|
if (isLoading) {
|
|
return (0, import_jsx_runtime.jsx)(Widget.Loading, {});
|
|
}
|
|
if (error || !data) {
|
|
return (0, import_jsx_runtime.jsx)(Widget.Error, {});
|
|
}
|
|
if (data.length === 0) {
|
|
return (0, import_jsx_runtime.jsx)(Widget.NoData, {
|
|
children: formatMessage({
|
|
id: "content-manager.widget.last-edited.no-data",
|
|
defaultMessage: "No edited entries"
|
|
})
|
|
});
|
|
}
|
|
return (0, import_jsx_runtime.jsx)(RecentDocumentsTable, {
|
|
documents: data
|
|
});
|
|
};
|
|
var LastPublishedWidget = () => {
|
|
const { formatMessage } = useIntl();
|
|
const { data, isLoading, error } = useGetRecentDocumentsQuery({
|
|
action: "publish"
|
|
});
|
|
if (isLoading) {
|
|
return (0, import_jsx_runtime.jsx)(Widget.Loading, {});
|
|
}
|
|
if (error || !data) {
|
|
return (0, import_jsx_runtime.jsx)(Widget.Error, {});
|
|
}
|
|
if (data.length === 0) {
|
|
return (0, import_jsx_runtime.jsx)(Widget.NoData, {
|
|
children: formatMessage({
|
|
id: "content-manager.widget.last-published.no-data",
|
|
defaultMessage: "No published entries"
|
|
})
|
|
});
|
|
}
|
|
return (0, import_jsx_runtime.jsx)(RecentDocumentsTable, {
|
|
documents: data
|
|
});
|
|
};
|
|
export {
|
|
LastEditedWidget,
|
|
LastPublishedWidget
|
|
};
|
|
//# sourceMappingURL=Widgets-KX2SYFOA.js.map
|