@danjojojo/strapi-audit-trail 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const reactRouterDom = require("react-router-dom");
5
5
  const icons = require("@strapi/icons");
6
- const index$1 = require("./index-D6PVUxkf.js");
6
+ const index$1 = require("./index-Cck0L8rD.js");
7
7
  const symbols = require("@strapi/icons/symbols");
8
8
  const styledComponents = require("styled-components");
9
9
  const designSystem = require("@strapi/design-system");
@@ -32,13 +32,6 @@ const RECENTS = {
32
32
  name: "Recents",
33
33
  kind: "none"
34
34
  };
35
- const OTHERS = [
36
- {
37
- uid: "cms-logins",
38
- name: "CMS Logins",
39
- kind: "others"
40
- }
41
- ];
42
35
  const EMPTY_STATE = {
43
36
  content: "Activities for this collection were not yet recorded. Create, update, delete, or publish an entry from this collection to record an activity.",
44
37
  action: {
@@ -87,20 +80,6 @@ const ERROR$1 = {
87
80
  INVALID: "This content type requst is invalid. Please select an available content type from the sidebar.",
88
81
  ERROR_ANY: "Experienced an error while fetching the audit logs for this content type. Please try again, and refresh this page.",
89
82
  ERROR_RECENTS: "Experienced an error while fetching the most recent audit logs. Please try again, and refresh this page."
90
- },
91
- BASE: {
92
- INVALID: "This request is invalid. Please select an available content type from the sidebar.",
93
- ERROR: "Experienced an error while fetching data. Please try again, and refresh this page."
94
- }
95
- };
96
- const LOGIN_RESULT_COLORS = {
97
- success: {
98
- backgroundColor: "success100",
99
- textColor: "success500"
100
- },
101
- failed: {
102
- backgroundColor: "danger100",
103
- textColor: "danger500"
104
83
  }
105
84
  };
106
85
  const contentManagerPath = `/admin/content-manager`;
@@ -23684,81 +23663,6 @@ function Table({
23684
23663
  rowDialog && dialogRow && rowDialog(dialogRow, closeDialogRow)
23685
23664
  ] });
23686
23665
  }
23687
- const NoPermissionPage = ({
23688
- content: content2 = "You don't have permission to access this page."
23689
- }) => {
23690
- return /* @__PURE__ */ jsxRuntime.jsx(LandingContentLayout, { children: /* @__PURE__ */ jsxRuntime.jsx(
23691
- EmptyState,
23692
- {
23693
- content: content2,
23694
- hideAction: true,
23695
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.WarningCircle, { width: "10rem", height: "10rem" })
23696
- }
23697
- ) });
23698
- };
23699
- function useAuditLogins() {
23700
- const { getAuditLogins } = services();
23701
- const { collectionKind, collectionUid, searchParams } = useRouting();
23702
- const [auditLogins, setAuditLogins] = React.useState([]);
23703
- const [auditLoginsLoading, setAuditLoginsLoading] = React.useState(true);
23704
- const [auditLoginsError, setAuditLoginsError] = React.useState("none");
23705
- const [auditLoginsMeta, setAuditLoginsMeta] = React.useState();
23706
- const getQuery = () => {
23707
- const _q = searchParams.get("_q") ?? void 0;
23708
- const sort = searchParams.get("sort") ?? void 0;
23709
- const page = stringToNumber({
23710
- value: searchParams.get("page"),
23711
- returnedValueIfError: 1,
23712
- minCap: 1
23713
- });
23714
- const pageSize = stringToNumber({
23715
- value: searchParams.get("pageSize"),
23716
- returnedValueIfError: 10,
23717
- minCap: 10,
23718
- maxCap: 100
23719
- });
23720
- return {
23721
- _q,
23722
- sort,
23723
- page,
23724
- pageSize
23725
- };
23726
- };
23727
- const fetchAuditLogins = async ({ query }) => {
23728
- try {
23729
- setAuditLoginsLoading(true);
23730
- const res = await getAuditLogins({ query });
23731
- if (typeof res === "number") {
23732
- setAuditLoginsError(getResponseStatus(res));
23733
- return;
23734
- }
23735
- if (res?.data) {
23736
- setAuditLogins(res.data);
23737
- }
23738
- if (res?.meta) {
23739
- setAuditLoginsMeta(res.meta);
23740
- }
23741
- setAuditLoginsError("none");
23742
- } catch (error) {
23743
- console.error(error);
23744
- } finally {
23745
- setAuditLoginsLoading(false);
23746
- return;
23747
- }
23748
- };
23749
- React.useEffect(() => {
23750
- const query = getQuery();
23751
- if (collectionKind === "others" && collectionUid === "cms-logins") {
23752
- fetchAuditLogins({ query });
23753
- }
23754
- }, [collectionKind, collectionUid, searchParams]);
23755
- return {
23756
- auditLogins,
23757
- auditLoginsError,
23758
- auditLoginsLoading,
23759
- auditLoginsMeta
23760
- };
23761
- }
23762
23666
  function useCollections() {
23763
23667
  const { isLoading, allowedActions } = admin.useRBAC(index$1.pluginPermissions);
23764
23668
  const { collectionKind, collectionUid, overrideNavigate } = useRouting();
@@ -23772,7 +23676,7 @@ function useCollections() {
23772
23676
  const fetchCollections = async () => {
23773
23677
  const data = await getAllCollections();
23774
23678
  if (data) {
23775
- const allData = [...data, ...OTHERS];
23679
+ const allData = [...data];
23776
23680
  setAllCollections(allData);
23777
23681
  setFilteredCollections(allData);
23778
23682
  }
@@ -23846,114 +23750,6 @@ function HomepageHeader({ title, count }) {
23846
23750
  const { selectedCollection } = useCollectionContext();
23847
23751
  return /* @__PURE__ */ jsxRuntime.jsx(Header, { title: title ?? selectedCollection?.name, count });
23848
23752
  }
23849
- const StyledDialog = {
23850
- Content: styledComponents.styled(designSystem.Dialog.Content)`
23851
- position: absolute;
23852
- display: flex;
23853
- flex-direction: column;
23854
- width: 60vw !important;
23855
- height: 100% !important;
23856
- max-height: 60vh !important;
23857
- max-width: 60vw !important;
23858
- `
23859
- };
23860
- function safeParse(text2) {
23861
- if (!text2) return null;
23862
- try {
23863
- return JSON.parse(text2);
23864
- } catch (error) {
23865
- return text2;
23866
- }
23867
- }
23868
- function spaceSnakeCase(text2, textCase = "retain") {
23869
- const spaced = text2.replace(/_+/g, " ").trim();
23870
- switch (textCase) {
23871
- case "upper":
23872
- return spaced.toUpperCase();
23873
- case "lower":
23874
- return spaced.toLowerCase();
23875
- case "sentence":
23876
- return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();
23877
- case "capitalize":
23878
- return spaced.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
23879
- default:
23880
- return spaced;
23881
- }
23882
- }
23883
- function AuditLoginDialog({ data, onClose }) {
23884
- const { overrideNavigate } = useRouting();
23885
- const userDetails = safeParse(data.userDetails);
23886
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: true, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(StyledDialog.Content, { onOpenAutoFocus: (e) => e.preventDefault(), children: [
23887
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", width: "100%", children: [
23888
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: `Login Details - ${data.emailAddress}` }),
23889
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { label: "Collapse", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Collapse, {}) }) })
23890
- ] }) }),
23891
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: "24px", width: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: "24px", children: [
23892
- data.loginResult === "failed" && /* @__PURE__ */ jsxRuntime.jsx(DialogGridItem, { label: "Login error reason", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: spaceSnakeCase(data.loginErrorReason, "sentence") }) }),
23893
- /* @__PURE__ */ jsxRuntime.jsx(DialogGridItem, { label: "Login request time", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: getClientDatetime(data.requestTime) }) }),
23894
- /* @__PURE__ */ jsxRuntime.jsx(DialogGridItem, { label: "User Details", children: userDetails?.id ? /* @__PURE__ */ jsxRuntime.jsx(
23895
- StyledLinkButton,
23896
- {
23897
- href: `/admin/settings/users/${userDetails.id}`,
23898
- size: "S",
23899
- variant: "secondary",
23900
- onClick: (e) => overrideNavigate(`/admin/settings/users/${userDetails.id}`, e),
23901
- endIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRight, {}),
23902
- children: "Verified user"
23903
- }
23904
- ) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: data.userDetails }) }),
23905
- /* @__PURE__ */ jsxRuntime.jsx(DialogGridItem, { label: "IP Address", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: data.ipAddress }) }),
23906
- /* @__PURE__ */ jsxRuntime.jsx(DialogGridItem, { label: "User Client", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: data.userClient }) })
23907
- ] }) })
23908
- ] }) });
23909
- }
23910
- function DialogGridItem({ label, children }) {
23911
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", alignItems: "start", direction: "column", gap: "4px", children: [
23912
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral400", children: label }),
23913
- children
23914
- ] }) });
23915
- }
23916
- const LoginsPage = () => {
23917
- const { allowedActions, isLoading: isRBACLoading } = admin.useRBAC(index$1.pluginPermissions);
23918
- const { isCollectionLoading, isInvalidCollection } = useCollectionContext();
23919
- const { auditLogins, auditLoginsError, auditLoginsLoading, auditLoginsMeta } = useAuditLogins();
23920
- if (!isRBACLoading && !allowedActions.canLoginsPage) {
23921
- return /* @__PURE__ */ jsxRuntime.jsx(NoPermissionPage, {});
23922
- }
23923
- if (!auditLoginsLoading && !isCollectionLoading && isInvalidCollection) {
23924
- return /* @__PURE__ */ jsxRuntime.jsx(ErrorPage, { content: ERROR$1.BASE.INVALID });
23925
- }
23926
- return /* @__PURE__ */ jsxRuntime.jsxs(LandingContentLayout, { children: [
23927
- /* @__PURE__ */ jsxRuntime.jsx(HomepageHeader, {}),
23928
- auditLoginsLoading || isCollectionLoading ? /* @__PURE__ */ jsxRuntime.jsx(Loader, {}) : auditLoginsError === "invalid" ? /* @__PURE__ */ jsxRuntime.jsx(ErrorState, { content: ERROR$1.BASE.ERROR }) : auditLoginsError === "network-error" ? /* @__PURE__ */ jsxRuntime.jsx(ErrorState, { content: ERROR$1.BASE.ERROR }) : !auditLoginsLoading && auditLogins.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
23929
- Table,
23930
- {
23931
- data: auditLogins,
23932
- columns: {
23933
- show: ["emailAddress", "loginResult", "requestTime", "userClient"],
23934
- datetime: ["requestTime"],
23935
- override: {
23936
- loginResult: "Result"
23937
- },
23938
- badge: {
23939
- column: "loginResult",
23940
- colors: LOGIN_RESULT_COLORS
23941
- }
23942
- },
23943
- rowDialog: (rowData, onClose) => /* @__PURE__ */ jsxRuntime.jsx(AuditLoginDialog, { data: rowData, onClose }),
23944
- pagination: {
23945
- pageCount: auditLoginsMeta?.pageCount ?? 1
23946
- }
23947
- }
23948
- ) : /* @__PURE__ */ jsxRuntime.jsx(
23949
- EmptyState,
23950
- {
23951
- content: "No CMS user logins were recorded yet. Entries will show up here when any user login occurs.",
23952
- hideAction: true
23953
- }
23954
- )
23955
- ] });
23956
- };
23957
23753
  const RecentsPage = () => {
23958
23754
  const { isCollectionLoading, isInvalidCollection } = useCollectionContext();
23959
23755
  const { auditLogs, auditLogsLoading, auditLogsError, auditLogsMeta } = useAuditLogs();
@@ -24035,7 +23831,6 @@ function AppRoutes() {
24035
23831
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "/?", element: /* @__PURE__ */ jsxRuntime.jsx(RecentsPage, {}) }),
24036
23832
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "collection-types/:collectionUid?", element: /* @__PURE__ */ jsxRuntime.jsx(ContentTypePage, {}) }),
24037
23833
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "single-types/:collectionUid?", element: /* @__PURE__ */ jsxRuntime.jsx(ContentTypePage, {}) }),
24038
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "others/cms-logins", element: /* @__PURE__ */ jsxRuntime.jsx(LoginsPage, {}) }),
24039
23834
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "single-types/:collectionUid/:documentId?", element: /* @__PURE__ */ jsxRuntime.jsx(DetailPage, {}) }),
24040
23835
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "collection-types/:collectionUid/:documentId?", element: /* @__PURE__ */ jsxRuntime.jsx(DetailPage, {}) }),
24041
23836
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Route, { path: "*", element: /* @__PURE__ */ jsxRuntime.jsx(ErrorPage, {}) })
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useParams, useNavigate, useSearchParams, Routes, Route } from "react-router-dom";
3
- import { ArrowLeft, WarningCircle, Paragraph as Paragraph$2, Bold, Italic, Underline, StrikeThrough, Code as Code$2, Link, BulletList, NumberList, Expand, Collapse, Image as Image$1, Quotes, GridFour, Eye, ArrowRight, Cross, Search } from "@strapi/icons";
4
- import { P as PLUGIN_ID, p as pluginPermissions } from "./index-B_D8BZUB.mjs";
3
+ import { ArrowLeft, WarningCircle, Paragraph as Paragraph$2, Bold, Italic, Underline, StrikeThrough, Code as Code$2, Link, BulletList, NumberList, Expand, Collapse, Image as Image$1, Quotes, GridFour, Eye, Cross, Search } from "@strapi/icons";
4
+ import { P as PLUGIN_ID, p as pluginPermissions } from "./index-D_ap-V-J.mjs";
5
5
  import { EmptyDocuments } from "@strapi/icons/symbols";
6
6
  import { styled, css, createGlobalStyle } from "styled-components";
7
- import { LinkButton, Box, Flex, Typography, Loader as Loader$1, Badge, ScrollArea, Button, Field as Field$1, TimePicker as TimePicker$1, DatePicker as DatePicker$1, DateTimePicker as DateTimePicker$1, JSONInput, CarouselInput, CarouselSlide, CarouselImage, IconButton, Dialog as Dialog$2, SingleSelect, SingleSelectOption, Toggle, Textarea as Textarea$1, IconButtonGroup, Accordion, Link as Link$1, Pagination as Pagination$1, PreviousLink, PageLink, NextLink, Table as Table$1, Thead, Tr, Th, Tbody, Td, Grid, Main } from "@strapi/design-system";
7
+ import { LinkButton, Box, Flex, Typography, Loader as Loader$1, Badge, ScrollArea, Button, Field as Field$1, TimePicker as TimePicker$1, DatePicker as DatePicker$1, DateTimePicker as DateTimePicker$1, JSONInput, CarouselInput, CarouselSlide, CarouselImage, IconButton, Dialog as Dialog$2, SingleSelect, SingleSelectOption, Toggle, Textarea as Textarea$1, IconButtonGroup, Accordion, Link as Link$1, Pagination as Pagination$1, PreviousLink, PageLink, NextLink, Table as Table$1, Thead, Tr, Th, Tbody, Td, Main } from "@strapi/design-system";
8
8
  import { useFetchClient, useStrapiApp, Form, useRBAC, Page } from "@strapi/strapi/admin";
9
9
  import * as React from "react";
10
10
  import { useState, useEffect, useContext, createContext, createElement } from "react";
@@ -13,13 +13,6 @@ const RECENTS = {
13
13
  name: "Recents",
14
14
  kind: "none"
15
15
  };
16
- const OTHERS = [
17
- {
18
- uid: "cms-logins",
19
- name: "CMS Logins",
20
- kind: "others"
21
- }
22
- ];
23
16
  const EMPTY_STATE = {
24
17
  content: "Activities for this collection were not yet recorded. Create, update, delete, or publish an entry from this collection to record an activity.",
25
18
  action: {
@@ -68,20 +61,6 @@ const ERROR$1 = {
68
61
  INVALID: "This content type requst is invalid. Please select an available content type from the sidebar.",
69
62
  ERROR_ANY: "Experienced an error while fetching the audit logs for this content type. Please try again, and refresh this page.",
70
63
  ERROR_RECENTS: "Experienced an error while fetching the most recent audit logs. Please try again, and refresh this page."
71
- },
72
- BASE: {
73
- INVALID: "This request is invalid. Please select an available content type from the sidebar.",
74
- ERROR: "Experienced an error while fetching data. Please try again, and refresh this page."
75
- }
76
- };
77
- const LOGIN_RESULT_COLORS = {
78
- success: {
79
- backgroundColor: "success100",
80
- textColor: "success500"
81
- },
82
- failed: {
83
- backgroundColor: "danger100",
84
- textColor: "danger500"
85
64
  }
86
65
  };
87
66
  const contentManagerPath = `/admin/content-manager`;
@@ -23665,81 +23644,6 @@ function Table({
23665
23644
  rowDialog && dialogRow && rowDialog(dialogRow, closeDialogRow)
23666
23645
  ] });
23667
23646
  }
23668
- const NoPermissionPage = ({
23669
- content: content2 = "You don't have permission to access this page."
23670
- }) => {
23671
- return /* @__PURE__ */ jsx(LandingContentLayout, { children: /* @__PURE__ */ jsx(
23672
- EmptyState,
23673
- {
23674
- content: content2,
23675
- hideAction: true,
23676
- icon: /* @__PURE__ */ jsx(WarningCircle, { width: "10rem", height: "10rem" })
23677
- }
23678
- ) });
23679
- };
23680
- function useAuditLogins() {
23681
- const { getAuditLogins } = services();
23682
- const { collectionKind, collectionUid, searchParams } = useRouting();
23683
- const [auditLogins, setAuditLogins] = useState([]);
23684
- const [auditLoginsLoading, setAuditLoginsLoading] = useState(true);
23685
- const [auditLoginsError, setAuditLoginsError] = useState("none");
23686
- const [auditLoginsMeta, setAuditLoginsMeta] = useState();
23687
- const getQuery = () => {
23688
- const _q = searchParams.get("_q") ?? void 0;
23689
- const sort = searchParams.get("sort") ?? void 0;
23690
- const page = stringToNumber({
23691
- value: searchParams.get("page"),
23692
- returnedValueIfError: 1,
23693
- minCap: 1
23694
- });
23695
- const pageSize = stringToNumber({
23696
- value: searchParams.get("pageSize"),
23697
- returnedValueIfError: 10,
23698
- minCap: 10,
23699
- maxCap: 100
23700
- });
23701
- return {
23702
- _q,
23703
- sort,
23704
- page,
23705
- pageSize
23706
- };
23707
- };
23708
- const fetchAuditLogins = async ({ query }) => {
23709
- try {
23710
- setAuditLoginsLoading(true);
23711
- const res = await getAuditLogins({ query });
23712
- if (typeof res === "number") {
23713
- setAuditLoginsError(getResponseStatus(res));
23714
- return;
23715
- }
23716
- if (res?.data) {
23717
- setAuditLogins(res.data);
23718
- }
23719
- if (res?.meta) {
23720
- setAuditLoginsMeta(res.meta);
23721
- }
23722
- setAuditLoginsError("none");
23723
- } catch (error) {
23724
- console.error(error);
23725
- } finally {
23726
- setAuditLoginsLoading(false);
23727
- return;
23728
- }
23729
- };
23730
- useEffect(() => {
23731
- const query = getQuery();
23732
- if (collectionKind === "others" && collectionUid === "cms-logins") {
23733
- fetchAuditLogins({ query });
23734
- }
23735
- }, [collectionKind, collectionUid, searchParams]);
23736
- return {
23737
- auditLogins,
23738
- auditLoginsError,
23739
- auditLoginsLoading,
23740
- auditLoginsMeta
23741
- };
23742
- }
23743
23647
  function useCollections() {
23744
23648
  const { isLoading, allowedActions } = useRBAC(pluginPermissions);
23745
23649
  const { collectionKind, collectionUid, overrideNavigate } = useRouting();
@@ -23753,7 +23657,7 @@ function useCollections() {
23753
23657
  const fetchCollections = async () => {
23754
23658
  const data = await getAllCollections();
23755
23659
  if (data) {
23756
- const allData = [...data, ...OTHERS];
23660
+ const allData = [...data];
23757
23661
  setAllCollections(allData);
23758
23662
  setFilteredCollections(allData);
23759
23663
  }
@@ -23827,114 +23731,6 @@ function HomepageHeader({ title, count }) {
23827
23731
  const { selectedCollection } = useCollectionContext();
23828
23732
  return /* @__PURE__ */ jsx(Header, { title: title ?? selectedCollection?.name, count });
23829
23733
  }
23830
- const StyledDialog = {
23831
- Content: styled(Dialog$2.Content)`
23832
- position: absolute;
23833
- display: flex;
23834
- flex-direction: column;
23835
- width: 60vw !important;
23836
- height: 100% !important;
23837
- max-height: 60vh !important;
23838
- max-width: 60vw !important;
23839
- `
23840
- };
23841
- function safeParse(text2) {
23842
- if (!text2) return null;
23843
- try {
23844
- return JSON.parse(text2);
23845
- } catch (error) {
23846
- return text2;
23847
- }
23848
- }
23849
- function spaceSnakeCase(text2, textCase = "retain") {
23850
- const spaced = text2.replace(/_+/g, " ").trim();
23851
- switch (textCase) {
23852
- case "upper":
23853
- return spaced.toUpperCase();
23854
- case "lower":
23855
- return spaced.toLowerCase();
23856
- case "sentence":
23857
- return spaced.charAt(0).toUpperCase() + spaced.slice(1).toLowerCase();
23858
- case "capitalize":
23859
- return spaced.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
23860
- default:
23861
- return spaced;
23862
- }
23863
- }
23864
- function AuditLoginDialog({ data, onClose }) {
23865
- const { overrideNavigate } = useRouting();
23866
- const userDetails = safeParse(data.userDetails);
23867
- return /* @__PURE__ */ jsx(Dialog$2.Root, { open: true, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(StyledDialog.Content, { onOpenAutoFocus: (e) => e.preventDefault(), children: [
23868
- /* @__PURE__ */ jsx(Dialog$2.Header, { children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", width: "100%", children: [
23869
- /* @__PURE__ */ jsx(Typography, { children: `Login Details - ${data.emailAddress}` }),
23870
- /* @__PURE__ */ jsx(Dialog$2.Cancel, { children: /* @__PURE__ */ jsx(IconButton, { label: "Collapse", children: /* @__PURE__ */ jsx(Collapse, {}) }) })
23871
- ] }) }),
23872
- /* @__PURE__ */ jsx(Box, { padding: "24px", width: "100%", children: /* @__PURE__ */ jsxs(Grid.Root, { gap: "24px", children: [
23873
- data.loginResult === "failed" && /* @__PURE__ */ jsx(DialogGridItem, { label: "Login error reason", children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: spaceSnakeCase(data.loginErrorReason, "sentence") }) }),
23874
- /* @__PURE__ */ jsx(DialogGridItem, { label: "Login request time", children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: getClientDatetime(data.requestTime) }) }),
23875
- /* @__PURE__ */ jsx(DialogGridItem, { label: "User Details", children: userDetails?.id ? /* @__PURE__ */ jsx(
23876
- StyledLinkButton,
23877
- {
23878
- href: `/admin/settings/users/${userDetails.id}`,
23879
- size: "S",
23880
- variant: "secondary",
23881
- onClick: (e) => overrideNavigate(`/admin/settings/users/${userDetails.id}`, e),
23882
- endIcon: /* @__PURE__ */ jsx(ArrowRight, {}),
23883
- children: "Verified user"
23884
- }
23885
- ) : /* @__PURE__ */ jsx(Typography, { variant: "omega", children: data.userDetails }) }),
23886
- /* @__PURE__ */ jsx(DialogGridItem, { label: "IP Address", children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: data.ipAddress }) }),
23887
- /* @__PURE__ */ jsx(DialogGridItem, { label: "User Client", children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: data.userClient }) })
23888
- ] }) })
23889
- ] }) });
23890
- }
23891
- function DialogGridItem({ label, children }) {
23892
- return /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Flex, { width: "100%", alignItems: "start", direction: "column", gap: "4px", children: [
23893
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", textColor: "neutral400", children: label }),
23894
- children
23895
- ] }) });
23896
- }
23897
- const LoginsPage = () => {
23898
- const { allowedActions, isLoading: isRBACLoading } = useRBAC(pluginPermissions);
23899
- const { isCollectionLoading, isInvalidCollection } = useCollectionContext();
23900
- const { auditLogins, auditLoginsError, auditLoginsLoading, auditLoginsMeta } = useAuditLogins();
23901
- if (!isRBACLoading && !allowedActions.canLoginsPage) {
23902
- return /* @__PURE__ */ jsx(NoPermissionPage, {});
23903
- }
23904
- if (!auditLoginsLoading && !isCollectionLoading && isInvalidCollection) {
23905
- return /* @__PURE__ */ jsx(ErrorPage, { content: ERROR$1.BASE.INVALID });
23906
- }
23907
- return /* @__PURE__ */ jsxs(LandingContentLayout, { children: [
23908
- /* @__PURE__ */ jsx(HomepageHeader, {}),
23909
- auditLoginsLoading || isCollectionLoading ? /* @__PURE__ */ jsx(Loader, {}) : auditLoginsError === "invalid" ? /* @__PURE__ */ jsx(ErrorState, { content: ERROR$1.BASE.ERROR }) : auditLoginsError === "network-error" ? /* @__PURE__ */ jsx(ErrorState, { content: ERROR$1.BASE.ERROR }) : !auditLoginsLoading && auditLogins.length > 0 ? /* @__PURE__ */ jsx(
23910
- Table,
23911
- {
23912
- data: auditLogins,
23913
- columns: {
23914
- show: ["emailAddress", "loginResult", "requestTime", "userClient"],
23915
- datetime: ["requestTime"],
23916
- override: {
23917
- loginResult: "Result"
23918
- },
23919
- badge: {
23920
- column: "loginResult",
23921
- colors: LOGIN_RESULT_COLORS
23922
- }
23923
- },
23924
- rowDialog: (rowData, onClose) => /* @__PURE__ */ jsx(AuditLoginDialog, { data: rowData, onClose }),
23925
- pagination: {
23926
- pageCount: auditLoginsMeta?.pageCount ?? 1
23927
- }
23928
- }
23929
- ) : /* @__PURE__ */ jsx(
23930
- EmptyState,
23931
- {
23932
- content: "No CMS user logins were recorded yet. Entries will show up here when any user login occurs.",
23933
- hideAction: true
23934
- }
23935
- )
23936
- ] });
23937
- };
23938
23734
  const RecentsPage = () => {
23939
23735
  const { isCollectionLoading, isInvalidCollection } = useCollectionContext();
23940
23736
  const { auditLogs, auditLogsLoading, auditLogsError, auditLogsMeta } = useAuditLogs();
@@ -24016,7 +23812,6 @@ function AppRoutes() {
24016
23812
  /* @__PURE__ */ jsx(Route, { path: "/?", element: /* @__PURE__ */ jsx(RecentsPage, {}) }),
24017
23813
  /* @__PURE__ */ jsx(Route, { path: "collection-types/:collectionUid?", element: /* @__PURE__ */ jsx(ContentTypePage, {}) }),
24018
23814
  /* @__PURE__ */ jsx(Route, { path: "single-types/:collectionUid?", element: /* @__PURE__ */ jsx(ContentTypePage, {}) }),
24019
- /* @__PURE__ */ jsx(Route, { path: "others/cms-logins", element: /* @__PURE__ */ jsx(LoginsPage, {}) }),
24020
23815
  /* @__PURE__ */ jsx(Route, { path: "single-types/:collectionUid/:documentId?", element: /* @__PURE__ */ jsx(DetailPage, {}) }),
24021
23816
  /* @__PURE__ */ jsx(Route, { path: "collection-types/:collectionUid/:documentId?", element: /* @__PURE__ */ jsx(DetailPage, {}) }),
24022
23817
  /* @__PURE__ */ jsx(Route, { path: "*", element: /* @__PURE__ */ jsx(ErrorPage, {}) })
@@ -67,7 +67,7 @@ const plugin = {
67
67
  id: `${PLUGIN_ID}.plugin.name`,
68
68
  defaultMessage: "Audit Trail"
69
69
  },
70
- Component: () => Promise.resolve().then(() => require("./App-CnbPoQeS.js")),
70
+ Component: () => Promise.resolve().then(() => require("./App-C1CuKhGo.js")),
71
71
  permissions: pluginPermissions.accessPluginPage
72
72
  });
73
73
  app.registerPlugin({
@@ -66,7 +66,7 @@ const plugin = {
66
66
  id: `${PLUGIN_ID}.plugin.name`,
67
67
  defaultMessage: "Audit Trail"
68
68
  },
69
- Component: () => import("./App-Bh07BNJH.mjs"),
69
+ Component: () => import("./App-V9-zsdH6.mjs"),
70
70
  permissions: pluginPermissions.accessPluginPage
71
71
  });
72
72
  app.registerPlugin({
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-D6PVUxkf.js");
3
+ const index = require("./index-Cck0L8rD.js");
4
4
  exports.default = index.plugin;
@@ -1,4 +1,4 @@
1
- import { a } from "./index-B_D8BZUB.mjs";
1
+ import { a } from "./index-D_ap-V-J.mjs";
2
2
  export {
3
3
  a as default
4
4
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.1",
2
+ "version": "1.0.2",
3
3
  "keywords": [],
4
4
  "type": "commonjs",
5
5
  "exports": {