@webiny/app-audit-logs 0.0.0-unstable.06b2ede40f
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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/components/Text.d.ts +4 -0
- package/components/Text.js +25 -0
- package/components/Text.js.map +1 -0
- package/config/list/AuditLogsListConfig.d.ts +42 -0
- package/config/list/AuditLogsListConfig.js +21 -0
- package/config/list/AuditLogsListConfig.js.map +1 -0
- package/config/list/Browser/Filter.d.ts +39 -0
- package/config/list/Browser/Filter.js +44 -0
- package/config/list/Browser/Filter.js.map +1 -0
- package/config/list/Browser/FiltersToWhere.d.ts +7 -0
- package/config/list/Browser/FiltersToWhere.js +16 -0
- package/config/list/Browser/FiltersToWhere.js.map +1 -0
- package/config/list/Browser/index.d.ts +39 -0
- package/config/list/Browser/index.js +8 -0
- package/config/list/Browser/index.js.map +1 -0
- package/config/list/index.d.ts +1 -0
- package/config/list/index.js +3 -0
- package/config/list/index.js.map +1 -0
- package/constants/index.d.ts +1 -0
- package/constants/index.js +3 -0
- package/constants/index.js.map +1 -0
- package/graphql.d.ts +1 -0
- package/graphql.js +27 -0
- package/graphql.js.map +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -0
- package/hooks/index.js.map +1 -0
- package/hooks/useAuditLogsList.d.ts +21 -0
- package/hooks/useAuditLogsList.js +105 -0
- package/hooks/useAuditLogsList.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +52 -0
- package/index.js.map +1 -0
- package/package.json +51 -0
- package/plugins/permissionRenderer/AuditLogsPermissions.d.ts +8 -0
- package/plugins/permissionRenderer/AuditLogsPermissions.js +100 -0
- package/plugins/permissionRenderer/AuditLogsPermissions.js.map +1 -0
- package/plugins/permissionRenderer/index.d.ts +1 -0
- package/plugins/permissionRenderer/index.js +32 -0
- package/plugins/permissionRenderer/index.js.map +1 -0
- package/types.d.ts +30 -0
- package/types.js +14 -0
- package/types.js.map +1 -0
- package/utils/transformCmsContentEntriesToRecordEntries.d.ts +25 -0
- package/utils/transformCmsContentEntriesToRecordEntries.js +36 -0
- package/utils/transformCmsContentEntriesToRecordEntries.js.map +1 -0
- package/views/Logs/Filters/FilterByAction.d.ts +2 -0
- package/views/Logs/Filters/FilterByAction.js +47 -0
- package/views/Logs/Filters/FilterByAction.js.map +1 -0
- package/views/Logs/Filters/FilterByApp.d.ts +2 -0
- package/views/Logs/Filters/FilterByApp.js +36 -0
- package/views/Logs/Filters/FilterByApp.js.map +1 -0
- package/views/Logs/Filters/FilterByEntity.d.ts +2 -0
- package/views/Logs/Filters/FilterByEntity.js +47 -0
- package/views/Logs/Filters/FilterByEntity.js.map +1 -0
- package/views/Logs/Filters/FilterByInitiator.d.ts +2 -0
- package/views/Logs/Filters/FilterByInitiator.js +39 -0
- package/views/Logs/Filters/FilterByInitiator.js.map +1 -0
- package/views/Logs/Filters/FilterByTimestamp.d.ts +2 -0
- package/views/Logs/Filters/FilterByTimestamp.js +40 -0
- package/views/Logs/Filters/FilterByTimestamp.js.map +1 -0
- package/views/Logs/Filters/Filters.d.ts +8 -0
- package/views/Logs/Filters/Filters.js +32 -0
- package/views/Logs/Filters/Filters.js.map +1 -0
- package/views/Logs/Filters/index.d.ts +6 -0
- package/views/Logs/Filters/index.js +8 -0
- package/views/Logs/Filters/index.js.map +1 -0
- package/views/Logs/Filters/styled.d.ts +5 -0
- package/views/Logs/Filters/styled.js +18 -0
- package/views/Logs/Filters/styled.js.map +1 -0
- package/views/Logs/Header/ButtonFilters/ButtonFilters.d.ts +8 -0
- package/views/Logs/Header/ButtonFilters/ButtonFilters.js +48 -0
- package/views/Logs/Header/ButtonFilters/ButtonFilters.js.map +1 -0
- package/views/Logs/Header/ButtonFilters/index.d.ts +1 -0
- package/views/Logs/Header/ButtonFilters/index.js +3 -0
- package/views/Logs/Header/ButtonFilters/index.js.map +1 -0
- package/views/Logs/Header/Header.d.ts +11 -0
- package/views/Logs/Header/Header.js +79 -0
- package/views/Logs/Header/Header.js.map +1 -0
- package/views/Logs/Header/index.d.ts +1 -0
- package/views/Logs/Header/index.js +3 -0
- package/views/Logs/Header/index.js.map +1 -0
- package/views/Logs/LoadMoreButton/LoadMoreButton.d.ts +9 -0
- package/views/Logs/LoadMoreButton/LoadMoreButton.js +23 -0
- package/views/Logs/LoadMoreButton/LoadMoreButton.js.map +1 -0
- package/views/Logs/LoadMoreButton/index.d.ts +1 -0
- package/views/Logs/LoadMoreButton/index.js +3 -0
- package/views/Logs/LoadMoreButton/index.js.map +1 -0
- package/views/Logs/LoadMoreButton/styled.d.ts +5 -0
- package/views/Logs/LoadMoreButton/styled.js +18 -0
- package/views/Logs/LoadMoreButton/styled.js.map +1 -0
- package/views/Logs/LoadingMore/index.d.ts +2 -0
- package/views/Logs/LoadingMore/index.js +16 -0
- package/views/Logs/LoadingMore/index.js.map +1 -0
- package/views/Logs/LoadingMore/styled.d.ts +9 -0
- package/views/Logs/LoadingMore/styled.js +32 -0
- package/views/Logs/LoadingMore/styled.js.map +1 -0
- package/views/Logs/Logs.d.ts +3 -0
- package/views/Logs/Logs.js +84 -0
- package/views/Logs/Logs.js.map +1 -0
- package/views/Logs/LogsModule.d.ts +2 -0
- package/views/Logs/LogsModule.js +26 -0
- package/views/Logs/LogsModule.js.map +1 -0
- package/views/Logs/Preview/Preview.d.ts +9 -0
- package/views/Logs/Preview/Preview.js +90 -0
- package/views/Logs/Preview/Preview.js.map +1 -0
- package/views/Logs/Preview/index.d.ts +1 -0
- package/views/Logs/Preview/index.js +3 -0
- package/views/Logs/Preview/index.js.map +1 -0
- package/views/Logs/Preview/styled.d.ts +6 -0
- package/views/Logs/Preview/styled.js +25 -0
- package/views/Logs/Preview/styled.js.map +1 -0
- package/views/Logs/Table/Table.d.ts +25 -0
- package/views/Logs/Table/Table.js +130 -0
- package/views/Logs/Table/Table.js.map +1 -0
- package/views/Logs/Table/index.d.ts +1 -0
- package/views/Logs/Table/index.js +3 -0
- package/views/Logs/Table/index.js.map +1 -0
- package/views/Logs/Table/styled.d.ts +17 -0
- package/views/Logs/Table/styled.js +81 -0
- package/views/Logs/Table/styled.js.map +1 -0
- package/views/Logs/styled.d.ts +9 -0
- package/views/Logs/styled.js +32 -0
- package/views/Logs/styled.js.map +1 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/app-audit-logs",
|
|
3
|
+
"version": "0.0.0-unstable.06b2ede40f",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@apollo/react-hooks": "3.1.5",
|
|
13
|
+
"@emotion/react": "11.10.8",
|
|
14
|
+
"@emotion/styled": "11.10.6",
|
|
15
|
+
"@webiny/admin-ui": "0.0.0-unstable.06b2ede40f",
|
|
16
|
+
"@webiny/api-audit-logs": "0.0.0-unstable.06b2ede40f",
|
|
17
|
+
"@webiny/app": "0.0.0-unstable.06b2ede40f",
|
|
18
|
+
"@webiny/app-aco": "0.0.0-unstable.06b2ede40f",
|
|
19
|
+
"@webiny/app-admin": "0.0.0-unstable.06b2ede40f",
|
|
20
|
+
"@webiny/app-security": "0.0.0-unstable.06b2ede40f",
|
|
21
|
+
"@webiny/form": "0.0.0-unstable.06b2ede40f",
|
|
22
|
+
"@webiny/icons": "0.0.0-unstable.06b2ede40f",
|
|
23
|
+
"@webiny/plugins": "0.0.0-unstable.06b2ede40f",
|
|
24
|
+
"@webiny/react-properties": "0.0.0-unstable.06b2ede40f",
|
|
25
|
+
"@webiny/react-router": "0.0.0-unstable.06b2ede40f",
|
|
26
|
+
"@webiny/ui": "0.0.0-unstable.06b2ede40f",
|
|
27
|
+
"date-fns": "2.29.3",
|
|
28
|
+
"emotion": "10.0.27",
|
|
29
|
+
"graphql-tag": "2.12.6",
|
|
30
|
+
"lodash": "4.17.21"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": "18.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/react": "18.2.79",
|
|
37
|
+
"@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
|
|
38
|
+
"execa": "5.1.1",
|
|
39
|
+
"rimraf": "6.0.1",
|
|
40
|
+
"typescript": "5.3.3"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"directory": "dist"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "node ../cli/bin.js run build",
|
|
48
|
+
"watch": "node ../cli/bin.js run watch"
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
51
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { SecurityPermission } from "@webiny/app-security/types";
|
|
3
|
+
interface PageBuilderPermissionsProps {
|
|
4
|
+
value: SecurityPermission;
|
|
5
|
+
onChange: (value: SecurityPermission[]) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const AuditLogsPermissions: ({ value, onChange }: PageBuilderPermissionsProps) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { Fragment, useCallback, useMemo } from "react";
|
|
2
|
+
import { Grid, Cell } from "@webiny/ui/Grid";
|
|
3
|
+
import { Select } from "@webiny/ui/Select";
|
|
4
|
+
import { i18n } from "@webiny/app/i18n";
|
|
5
|
+
import { CannotUseAaclAlert, PermissionInfo, gridWithPaddingClass } from "@webiny/app-admin/components/Permissions";
|
|
6
|
+
import { Form } from "@webiny/form";
|
|
7
|
+
import { useSecurity } from "@webiny/app-security";
|
|
8
|
+
const t = i18n.ns("app-audit-logs/plugins/permissionRenderer");
|
|
9
|
+
const AUDIT_LOGS = "al";
|
|
10
|
+
const AUDIT_LOGS_FULL_ACCESS = "al.*";
|
|
11
|
+
const FULL_ACCESS = "full";
|
|
12
|
+
const NO_ACCESS = "no";
|
|
13
|
+
const CUSTOM_ACCESS = "custom";
|
|
14
|
+
export const AuditLogsPermissions = ({
|
|
15
|
+
value,
|
|
16
|
+
onChange
|
|
17
|
+
}) => {
|
|
18
|
+
const {
|
|
19
|
+
getPermission
|
|
20
|
+
} = useSecurity();
|
|
21
|
+
|
|
22
|
+
// We disable form elements for custom permissions if AACL cannot be used.
|
|
23
|
+
const cannotUseAAcl = useMemo(() => {
|
|
24
|
+
return !getPermission("aacl", true);
|
|
25
|
+
}, []);
|
|
26
|
+
const onFormChange = useCallback(formData => {
|
|
27
|
+
let newValue = [];
|
|
28
|
+
if (Array.isArray(value)) {
|
|
29
|
+
// Let's just filter out the `al*` permission objects, it's easier to build new ones from scratch.
|
|
30
|
+
newValue = value.filter(item => !item.name.startsWith(AUDIT_LOGS));
|
|
31
|
+
}
|
|
32
|
+
if (formData.accessLevel === NO_ACCESS) {
|
|
33
|
+
onChange(newValue);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (formData.accessLevel === FULL_ACCESS) {
|
|
37
|
+
newValue.push({
|
|
38
|
+
name: AUDIT_LOGS_FULL_ACCESS
|
|
39
|
+
});
|
|
40
|
+
onChange(newValue);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Handling custom access level.
|
|
45
|
+
|
|
46
|
+
onChange(newValue);
|
|
47
|
+
}, [value]);
|
|
48
|
+
const formData = useMemo(() => {
|
|
49
|
+
if (!Array.isArray(value)) {
|
|
50
|
+
return {
|
|
51
|
+
accessLevel: NO_ACCESS
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const hasFullAccess = value.find(item => item.name === AUDIT_LOGS_FULL_ACCESS || item.name === "*");
|
|
55
|
+
if (hasFullAccess) {
|
|
56
|
+
return {
|
|
57
|
+
accessLevel: FULL_ACCESS
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const permissions = value.filter(item => item.name.startsWith(AUDIT_LOGS));
|
|
61
|
+
if (!permissions.length) {
|
|
62
|
+
return {
|
|
63
|
+
accessLevel: NO_ACCESS
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const formData = {
|
|
67
|
+
accessLevel: CUSTOM_ACCESS
|
|
68
|
+
};
|
|
69
|
+
return formData;
|
|
70
|
+
}, []);
|
|
71
|
+
return /*#__PURE__*/React.createElement(Form, {
|
|
72
|
+
data: formData,
|
|
73
|
+
onChange: onFormChange
|
|
74
|
+
}, ({
|
|
75
|
+
data,
|
|
76
|
+
Bind
|
|
77
|
+
}) => /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Grid, {
|
|
78
|
+
className: gridWithPaddingClass
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Cell, {
|
|
80
|
+
span: 12
|
|
81
|
+
}, data.accessLevel === "custom" && cannotUseAAcl && /*#__PURE__*/React.createElement(CannotUseAaclAlert, null))), /*#__PURE__*/React.createElement(Grid, {
|
|
82
|
+
className: gridWithPaddingClass
|
|
83
|
+
}, /*#__PURE__*/React.createElement(Cell, {
|
|
84
|
+
span: 6
|
|
85
|
+
}, /*#__PURE__*/React.createElement(PermissionInfo, {
|
|
86
|
+
title: t`Access Level`
|
|
87
|
+
})), /*#__PURE__*/React.createElement(Cell, {
|
|
88
|
+
span: 6
|
|
89
|
+
}, /*#__PURE__*/React.createElement(Bind, {
|
|
90
|
+
name: "accessLevel"
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Select, null, /*#__PURE__*/React.createElement("option", {
|
|
92
|
+
value: NO_ACCESS
|
|
93
|
+
}, t`No access`), /*#__PURE__*/React.createElement("option", {
|
|
94
|
+
value: FULL_ACCESS
|
|
95
|
+
}, t`Full access`), /*#__PURE__*/React.createElement("option", {
|
|
96
|
+
value: CUSTOM_ACCESS
|
|
97
|
+
}, t`Custom access`))))), data.accessLevel === CUSTOM_ACCESS && /*#__PURE__*/React.createElement(React.Fragment, null)));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=AuditLogsPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Fragment","useCallback","useMemo","Grid","Cell","Select","i18n","CannotUseAaclAlert","PermissionInfo","gridWithPaddingClass","Form","useSecurity","t","ns","AUDIT_LOGS","AUDIT_LOGS_FULL_ACCESS","FULL_ACCESS","NO_ACCESS","CUSTOM_ACCESS","AuditLogsPermissions","value","onChange","getPermission","cannotUseAAcl","onFormChange","formData","newValue","Array","isArray","filter","item","name","startsWith","accessLevel","push","hasFullAccess","find","permissions","length","createElement","data","Bind","className","span","title"],"sources":["AuditLogsPermissions.tsx"],"sourcesContent":["import React, { Fragment, useCallback, useMemo } from \"react\";\nimport { Grid, Cell } from \"@webiny/ui/Grid\";\nimport { Select } from \"@webiny/ui/Select\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport {\n CannotUseAaclAlert,\n PermissionInfo,\n gridWithPaddingClass\n} from \"@webiny/app-admin/components/Permissions\";\nimport { Form } from \"@webiny/form\";\nimport { useSecurity } from \"@webiny/app-security\";\nimport type { SecurityPermission } from \"@webiny/app-security/types\";\nimport type { AaclPermission } from \"@webiny/app-admin\";\n\nconst t = i18n.ns(\"app-audit-logs/plugins/permissionRenderer\");\n\nconst AUDIT_LOGS = \"al\";\nconst AUDIT_LOGS_FULL_ACCESS = \"al.*\";\nconst FULL_ACCESS = \"full\";\nconst NO_ACCESS = \"no\";\nconst CUSTOM_ACCESS = \"custom\";\n\ninterface PageBuilderPermissionsProps {\n value: SecurityPermission;\n onChange: (value: SecurityPermission[]) => void;\n}\nexport const AuditLogsPermissions = ({ value, onChange }: PageBuilderPermissionsProps) => {\n const { getPermission } = useSecurity();\n\n // We disable form elements for custom permissions if AACL cannot be used.\n const cannotUseAAcl = useMemo(() => {\n return !getPermission<AaclPermission>(\"aacl\", true);\n }, []);\n\n const onFormChange = useCallback(\n (formData: SecurityPermission) => {\n let newValue: SecurityPermission[] = [];\n if (Array.isArray(value)) {\n // Let's just filter out the `al*` permission objects, it's easier to build new ones from scratch.\n newValue = value.filter(item => !item.name.startsWith(AUDIT_LOGS));\n }\n\n if (formData.accessLevel === NO_ACCESS) {\n onChange(newValue);\n return;\n }\n\n if (formData.accessLevel === FULL_ACCESS) {\n newValue.push({ name: AUDIT_LOGS_FULL_ACCESS });\n onChange(newValue);\n return;\n }\n\n // Handling custom access level.\n\n onChange(newValue);\n },\n [value]\n );\n\n const formData = useMemo(() => {\n if (!Array.isArray(value)) {\n return { accessLevel: NO_ACCESS };\n }\n\n const hasFullAccess = value.find(\n item => item.name === AUDIT_LOGS_FULL_ACCESS || item.name === \"*\"\n );\n if (hasFullAccess) {\n return { accessLevel: FULL_ACCESS };\n }\n\n const permissions = value.filter(item => item.name.startsWith(AUDIT_LOGS));\n if (!permissions.length) {\n return { accessLevel: NO_ACCESS };\n }\n\n const formData = {\n accessLevel: CUSTOM_ACCESS\n };\n\n return formData;\n }, []);\n\n return (\n <Form data={formData} onChange={onFormChange}>\n {({ data, Bind }) => (\n <Fragment>\n <Grid className={gridWithPaddingClass}>\n <Cell span={12}>\n {data.accessLevel === \"custom\" && cannotUseAAcl && (\n <CannotUseAaclAlert />\n )}\n </Cell>\n </Grid>\n <Grid className={gridWithPaddingClass}>\n <Cell span={6}>\n <PermissionInfo title={t`Access Level`} />\n </Cell>\n <Cell span={6}>\n <Bind name={\"accessLevel\"}>\n <Select>\n <option value={NO_ACCESS}>{t`No access`}</option>\n <option value={FULL_ACCESS}>{t`Full access`}</option>\n <option value={CUSTOM_ACCESS}>{t`Custom access`}</option>\n </Select>\n </Bind>\n </Cell>\n </Grid>\n {data.accessLevel === CUSTOM_ACCESS && <></>}\n </Fragment>\n )}\n </Form>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,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EAAE;EAAG,GACVH,IAAI,CAACP,WAAW,KAAK,QAAQ,IAAIV,aAAa,iBAC3CxB,KAAA,CAAAwC,aAAA,CAAChC,kBAAkB,MAAE,CAEvB,CACJ,CAAC,eACPR,KAAA,CAAAwC,aAAA,CAACpC,IAAI;IAACuC,SAAS,EAAEjC;EAAqB,gBAClCV,KAAA,CAAAwC,aAAA,CAACnC,IAAI;IAACuC,IAAI,EAAE;EAAE,gBACV5C,KAAA,CAAAwC,aAAA,CAAC/B,cAAc;IAACoC,KAAK,EAAEhC,CAAC;EAAe,CAAE,CACvC,CAAC,eACPb,KAAA,CAAAwC,aAAA,CAACnC,IAAI;IAACuC,IAAI,EAAE;EAAE,gBACV5C,KAAA,CAAAwC,aAAA,CAACE,IAAI;IAACV,IAAI,EAAE;EAAc,gBACtBhC,KAAA,CAAAwC,aAAA,CAAClC,MAAM,qBACHN,KAAA,CAAAwC,aAAA;IAAQnB,KAAK,EAAEH;EAAU,GAAEL,CAAC,WAAoB,CAAC,eACjDb,KAAA,CAAAwC,aAAA;IAAQnB,KAAK,EAAEJ;EAAY,GAAEJ,CAAC,aAAsB,CAAC,eACrDb,KAAA,CAAAwC,aAAA;IAAQnB,KAAK,EAAEF;EAAc,GAAEN,CAAC,eAAwB,CACpD,CACN,CACJ,CACJ,CAAC,EACN4B,IAAI,CAACP,WAAW,KAAKf,aAAa,iBAAInB,KAAA,CAAAwC,aAAA,CAAAxC,KAAA,CAAAC,QAAA,MAAI,CACrC,CAEZ,CAAC;AAEf,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AuditLogsPermissions: () => null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { ReactComponent as PermissionsIcon } from "@webiny/icons/manage_search.svg";
|
|
3
|
+
import { i18n } from "@webiny/app/i18n";
|
|
4
|
+
import { plugins } from "@webiny/plugins";
|
|
5
|
+
import { Accordion } from "@webiny/admin-ui";
|
|
6
|
+
import { AuditLogsPermissions as AuditLogsPermissionsComponent } from "./AuditLogsPermissions";
|
|
7
|
+
const t = i18n.ns("app-audit-logs/plugins/permissionRenderer");
|
|
8
|
+
const createPermissions = () => {
|
|
9
|
+
return {
|
|
10
|
+
type: "admin-app-permissions-renderer",
|
|
11
|
+
name: "admin-app-permissions-renderer-audit-logs",
|
|
12
|
+
render(props) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(Accordion.Item, {
|
|
14
|
+
icon: /*#__PURE__*/React.createElement(Accordion.Item.Icon, {
|
|
15
|
+
icon: /*#__PURE__*/React.createElement(PermissionsIcon, null),
|
|
16
|
+
label: "Audit Logs Permissions"
|
|
17
|
+
}),
|
|
18
|
+
title: t`Audit Logs`,
|
|
19
|
+
description: t`Manage Audit Logs app access permissions.`,
|
|
20
|
+
"data-testid": "permission.al"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(AuditLogsPermissionsComponent, props));
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export const AuditLogsPermissions = () => {
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
plugins.register(createPermissions());
|
|
28
|
+
}, []);
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","ReactComponent","PermissionsIcon","i18n","plugins","Accordion","AuditLogsPermissions","AuditLogsPermissionsComponent","t","ns","createPermissions","type","name","render","props","createElement","Item","icon","Icon","label","title","description","register"],"sources":["index.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport { ReactComponent as PermissionsIcon } from \"@webiny/icons/manage_search.svg\";\n\nimport { i18n } from \"@webiny/app/i18n\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Accordion } from \"@webiny/admin-ui\";\nimport type { AdminAppPermissionRendererPlugin } from \"@webiny/app-admin/types\";\n\nimport { AuditLogsPermissions as AuditLogsPermissionsComponent } from \"./AuditLogsPermissions\";\n\nconst t = i18n.ns(\"app-audit-logs/plugins/permissionRenderer\");\n\nconst createPermissions = (): AdminAppPermissionRendererPlugin => {\n return {\n type: \"admin-app-permissions-renderer\",\n name: \"admin-app-permissions-renderer-audit-logs\",\n render(props) {\n return (\n <Accordion.Item\n icon={\n <Accordion.Item.Icon\n icon={<PermissionsIcon />}\n label={\"Audit Logs Permissions\"}\n />\n }\n title={t`Audit Logs`}\n description={t`Manage Audit Logs app access permissions.`}\n data-testid={\"permission.al\"}\n >\n <AuditLogsPermissionsComponent {...props} />\n </Accordion.Item>\n );\n }\n };\n};\n\nexport const AuditLogsPermissions = () => {\n useEffect(() => {\n plugins.register(createPermissions());\n }, []);\n return null;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,cAAc,IAAIC,eAAe,QAAQ,iCAAiC;AAEnF,SAASC,IAAI,QAAQ,kBAAkB;AACvC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,SAAS,QAAQ,kBAAkB;AAG5C,SAASC,oBAAoB,IAAIC,6BAA6B;AAE9D,MAAMC,CAAC,GAAGL,IAAI,CAACM,EAAE,CAAC,2CAA2C,CAAC;AAE9D,MAAMC,iBAAiB,GAAGA,CAAA,KAAwC;EAC9D,OAAO;IACHC,IAAI,EAAE,gCAAgC;IACtCC,IAAI,EAAE,2CAA2C;IACjDC,MAAMA,CAACC,KAAK,EAAE;MACV,oBACIf,KAAA,CAAAgB,aAAA,CAACV,SAAS,CAACW,IAAI;QACXC,IAAI,eACAlB,KAAA,CAAAgB,aAAA,CAACV,SAAS,CAACW,IAAI,CAACE,IAAI;UAChBD,IAAI,eAAElB,KAAA,CAAAgB,aAAA,CAACb,eAAe,MAAE,CAAE;UAC1BiB,KAAK,EAAE;QAAyB,CACnC,CACJ;QACDC,KAAK,EAAEZ,CAAC,YAAa;QACrBa,WAAW,EAAEb,CAAC,2CAA4C;QAC1D,eAAa;MAAgB,gBAE7BT,KAAA,CAAAgB,aAAA,CAACR,6BAA6B,EAAKO,KAAQ,CAC/B,CAAC;IAEzB;EACJ,CAAC;AACL,CAAC;AAED,OAAO,MAAMR,oBAAoB,GAAGA,CAAA,KAAM;EACtCN,SAAS,CAAC,MAAM;IACZI,OAAO,CAACkB,QAAQ,CAACZ,iBAAiB,CAAC,CAAC,CAAC;EACzC,CAAC,EAAE,EAAE,CAAC;EACN,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare enum ActionType {
|
|
2
|
+
CREATE = "CREATE",
|
|
3
|
+
UPDATE = "UPDATE",
|
|
4
|
+
DELETE = "DELETE",
|
|
5
|
+
MOVE_TO_TRASH = "MOVE_TO_TRASH",
|
|
6
|
+
RESTORE_FROM_TRASH = "RESTORE_FROM_TRASH",
|
|
7
|
+
PUBLISH = "PUBLISH",
|
|
8
|
+
UNPUBLISH = "UNPUBLISH",
|
|
9
|
+
IMPORT = "IMPORT",
|
|
10
|
+
EXPORT = "EXPORT"
|
|
11
|
+
}
|
|
12
|
+
export interface AuditLog {
|
|
13
|
+
id: string;
|
|
14
|
+
message: string;
|
|
15
|
+
app: string;
|
|
16
|
+
entity: string;
|
|
17
|
+
entityId: string;
|
|
18
|
+
action: ActionType;
|
|
19
|
+
data: string;
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
initiator: string;
|
|
22
|
+
}
|
|
23
|
+
export interface User {
|
|
24
|
+
id: string;
|
|
25
|
+
firstName: string;
|
|
26
|
+
lastName: string;
|
|
27
|
+
groups?: {
|
|
28
|
+
name: string;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
package/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export let ActionType = /*#__PURE__*/function (ActionType) {
|
|
2
|
+
ActionType["CREATE"] = "CREATE";
|
|
3
|
+
ActionType["UPDATE"] = "UPDATE";
|
|
4
|
+
ActionType["DELETE"] = "DELETE";
|
|
5
|
+
ActionType["MOVE_TO_TRASH"] = "MOVE_TO_TRASH";
|
|
6
|
+
ActionType["RESTORE_FROM_TRASH"] = "RESTORE_FROM_TRASH";
|
|
7
|
+
ActionType["PUBLISH"] = "PUBLISH";
|
|
8
|
+
ActionType["UNPUBLISH"] = "UNPUBLISH";
|
|
9
|
+
ActionType["IMPORT"] = "IMPORT";
|
|
10
|
+
ActionType["EXPORT"] = "EXPORT";
|
|
11
|
+
return ActionType;
|
|
12
|
+
}({});
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ActionType"],"sources":["types.ts"],"sourcesContent":["export enum ActionType {\n CREATE = \"CREATE\",\n UPDATE = \"UPDATE\",\n DELETE = \"DELETE\",\n MOVE_TO_TRASH = \"MOVE_TO_TRASH\",\n RESTORE_FROM_TRASH = \"RESTORE_FROM_TRASH\",\n PUBLISH = \"PUBLISH\",\n UNPUBLISH = \"UNPUBLISH\",\n IMPORT = \"IMPORT\",\n EXPORT = \"EXPORT\"\n}\n\nexport interface AuditLog {\n id: string;\n message: string;\n app: string;\n entity: string;\n entityId: string;\n action: ActionType;\n data: string;\n timestamp: Date;\n initiator: string;\n}\n\nexport interface User {\n id: string;\n firstName: string;\n lastName: string;\n groups?: {\n name: string;\n }[];\n}\n"],"mappings":"AAAA,WAAYA,UAAU,0BAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SearchRecordItem } from "@webiny/app-aco/types";
|
|
2
|
+
import type { ActionType, AuditLog, User } from "../types";
|
|
3
|
+
export type Entry = {
|
|
4
|
+
id: string;
|
|
5
|
+
message: string;
|
|
6
|
+
app: string;
|
|
7
|
+
entity: {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
link?: string;
|
|
11
|
+
};
|
|
12
|
+
entityId: string;
|
|
13
|
+
action: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: ActionType;
|
|
16
|
+
};
|
|
17
|
+
data: string;
|
|
18
|
+
savedOn: Date;
|
|
19
|
+
initiator: {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
role: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const transformCmsContentEntriesToRecordEntries: (items: SearchRecordItem<AuditLog>[], users: User[]) => Entry[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { auditLogsApps } from "@webiny/api-audit-logs/config";
|
|
2
|
+
export const transformCmsContentEntriesToRecordEntries = (items, users) => {
|
|
3
|
+
return items.map(({
|
|
4
|
+
id,
|
|
5
|
+
data
|
|
6
|
+
}) => {
|
|
7
|
+
const app = auditLogsApps.find(app => app.app === data.app);
|
|
8
|
+
const entity = app?.entities?.find(entity => entity.type === data.entity);
|
|
9
|
+
const action = entity?.actions?.find(action => action.type === data.action);
|
|
10
|
+
const user = users.find(user => user.id === data.initiator);
|
|
11
|
+
return {
|
|
12
|
+
id,
|
|
13
|
+
message: data.message,
|
|
14
|
+
app: app?.displayName || "-",
|
|
15
|
+
entity: {
|
|
16
|
+
label: entity?.displayName || "-",
|
|
17
|
+
value: data.entity,
|
|
18
|
+
link: entity?.linkToEntity && entity.linkToEntity(encodeURIComponent(data.entityId))
|
|
19
|
+
},
|
|
20
|
+
entityId: data.entityId,
|
|
21
|
+
action: {
|
|
22
|
+
label: action?.displayName || "-",
|
|
23
|
+
value: data.action
|
|
24
|
+
},
|
|
25
|
+
data: data.data,
|
|
26
|
+
savedOn: data.timestamp,
|
|
27
|
+
initiator: {
|
|
28
|
+
id: data.initiator,
|
|
29
|
+
name: `${user?.firstName} ${user?.lastName}`,
|
|
30
|
+
role: user?.groups?.[0]?.name || ""
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=transformCmsContentEntriesToRecordEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["auditLogsApps","transformCmsContentEntriesToRecordEntries","items","users","map","id","data","app","find","entity","entities","type","action","actions","user","initiator","message","displayName","label","value","link","linkToEntity","encodeURIComponent","entityId","savedOn","timestamp","name","firstName","lastName","role","groups"],"sources":["transformCmsContentEntriesToRecordEntries.ts"],"sourcesContent":["import type { SearchRecordItem } from \"@webiny/app-aco/types\";\nimport { auditLogsApps } from \"@webiny/api-audit-logs/config\";\n\nimport type { ActionType, AuditLog, User } from \"~/types\";\n\nexport type Entry = {\n id: string;\n message: string;\n app: string;\n entity: {\n value: string;\n label: string;\n link?: string;\n };\n entityId: string;\n action: {\n label: string;\n value: ActionType;\n };\n data: string;\n savedOn: Date;\n initiator: {\n id: string;\n name: string;\n role: string;\n };\n};\n\nexport const transformCmsContentEntriesToRecordEntries = (\n items: SearchRecordItem<AuditLog>[],\n users: User[]\n): Entry[] => {\n return items.map(({ id, data }) => {\n const app = auditLogsApps.find(app => app.app === data.app);\n const entity = app?.entities?.find(entity => entity.type === data.entity);\n const action = entity?.actions?.find(action => action.type === data.action);\n const user = users.find(user => user.id === data.initiator);\n\n return {\n id,\n message: data.message,\n app: app?.displayName || \"-\",\n entity: {\n label: entity?.displayName || \"-\",\n value: data.entity,\n link: entity?.linkToEntity && entity.linkToEntity(encodeURIComponent(data.entityId))\n },\n entityId: data.entityId,\n action: {\n label: action?.displayName || \"-\",\n value: data.action\n },\n data: data.data,\n savedOn: data.timestamp,\n initiator: {\n id: data.initiator,\n name: `${user?.firstName} ${user?.lastName}`,\n role: user?.groups?.[0]?.name || \"\"\n }\n };\n });\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,+BAA+B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,EAAE;QACPV,EAAE,EAAEC,IAAI,CAACS,SAAS;QAClBW,IAAI,EAAE,GAAGZ,IAAI,EAAEa,SAAS,IAAIb,IAAI,EAAEc,QAAQ,EAAE;QAC5CC,IAAI,EAAEf,IAAI,EAAEgB,MAAM,GAAG,CAAC,CAAC,EAAEJ,IAAI,IAAI;MACrC;IACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { useBind, useForm } from "@webiny/form";
|
|
3
|
+
import { Select } from "@webiny/ui/Select";
|
|
4
|
+
import { auditLogsApps } from "@webiny/api-audit-logs/config";
|
|
5
|
+
const getValidFilterValue = value => {
|
|
6
|
+
if (value === "all" || value === "") {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
export const FilterByAction = () => {
|
|
12
|
+
const {
|
|
13
|
+
data
|
|
14
|
+
} = useForm();
|
|
15
|
+
const bind = useBind({
|
|
16
|
+
name: "data.action",
|
|
17
|
+
beforeChange(value, cb) {
|
|
18
|
+
cb(getValidFilterValue(value));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const appValue = data?.data?.app;
|
|
22
|
+
const entityValue = data?.data?.entity;
|
|
23
|
+
const options = useMemo(() => {
|
|
24
|
+
if (!appValue || !entityValue) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const entities = auditLogsApps.find(app => app.app === appValue)?.entities || [];
|
|
28
|
+
const actions = entities.find(entity => entity.type === entityValue)?.actions || [];
|
|
29
|
+
return [{
|
|
30
|
+
label: "All",
|
|
31
|
+
value: "all"
|
|
32
|
+
}, ...actions.map(entity => ({
|
|
33
|
+
label: entity.displayName,
|
|
34
|
+
value: entity.type
|
|
35
|
+
}))];
|
|
36
|
+
}, [appValue, entityValue]);
|
|
37
|
+
if (!appValue || !entityValue) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return /*#__PURE__*/React.createElement(Select, Object.assign({}, bind, {
|
|
41
|
+
size: "medium",
|
|
42
|
+
placeholder: "Filter by Action",
|
|
43
|
+
options: options
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=FilterByAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","useBind","useForm","Select","auditLogsApps","getValidFilterValue","value","undefined","FilterByAction","data","bind","name","beforeChange","cb","appValue","app","entityValue","entity","options","entities","find","actions","type","label","map","displayName","createElement","Object","assign","size","placeholder"],"sources":["FilterByAction.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\n\nimport { useBind, useForm } from \"@webiny/form\";\nimport { Select } from \"@webiny/ui/Select\";\nimport { auditLogsApps } from \"@webiny/api-audit-logs/config\";\n\nconst getValidFilterValue = (value: string): string | undefined => {\n if (value === \"all\" || value === \"\") {\n return undefined;\n }\n return value;\n};\n\nexport const FilterByAction = () => {\n const { data } = useForm();\n const bind = useBind({\n name: \"data.action\",\n beforeChange(value, cb) {\n cb(getValidFilterValue(value));\n }\n });\n\n const appValue = data?.data?.app;\n const entityValue = data?.data?.entity;\n\n const options = useMemo(() => {\n if (!appValue || !entityValue) {\n return [];\n }\n\n const entities = auditLogsApps.find(app => app.app === appValue)?.entities || [];\n const actions = entities.find(entity => entity.type === entityValue)?.actions || [];\n\n return [\n { label: \"All\", value: \"all\" },\n ...actions.map(entity => ({ label: entity.displayName, value: entity.type }))\n ];\n }, [appValue, entityValue]);\n\n if (!appValue || !entityValue) {\n return null;\n }\n\n return <Select {...bind} size={\"medium\"} placeholder={\"Filter by Action\"} options={options} />;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,SAASC,OAAO,EAAEC,OAAO,QAAQ,cAAc;AAC/C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,aAA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E,WAAW,CAAC,CAAC;EAE3B,IAAI,CAACF,QAAQ,IAAI,CAACE,WAAW,EAAE;IAC3B,OAAO,IAAI;EACf;EAEA,oBAAOjB,KAAA,CAAA2B,aAAA,CAACvB,MAAM,EAAAwB,MAAA,CAAAC,MAAA,KAAKlB,IAAI;IAAEmB,IAAI,EAAE,QAAS;IAACC,WAAW,EAAE,kBAAmB;IAACZ,OAAO,EAAEA;EAAQ,EAAE,CAAC;AAClG,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useBind, useForm } from "@webiny/form";
|
|
3
|
+
import { Select } from "@webiny/ui/Select";
|
|
4
|
+
import { auditLogsApps } from "@webiny/api-audit-logs/config";
|
|
5
|
+
const getValidFilterValue = value => {
|
|
6
|
+
if (value === "all" || value === "") {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
export const FilterByApp = () => {
|
|
12
|
+
const {
|
|
13
|
+
setValue
|
|
14
|
+
} = useForm();
|
|
15
|
+
const bind = useBind({
|
|
16
|
+
name: "data.app",
|
|
17
|
+
beforeChange(value, cb) {
|
|
18
|
+
setValue("data.entity", undefined);
|
|
19
|
+
setValue("data.action", undefined);
|
|
20
|
+
cb(getValidFilterValue(value));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/React.createElement(Select, Object.assign({}, bind, {
|
|
24
|
+
size: "medium",
|
|
25
|
+
placeholder: "Filter by App",
|
|
26
|
+
options: [{
|
|
27
|
+
label: "All",
|
|
28
|
+
value: "all"
|
|
29
|
+
}, ...auditLogsApps.map(app => ({
|
|
30
|
+
label: app.displayName,
|
|
31
|
+
value: app.app
|
|
32
|
+
}))]
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=FilterByApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useBind","useForm","Select","auditLogsApps","getValidFilterValue","value","undefined","FilterByApp","setValue","bind","name","beforeChange","cb","createElement","Object","assign","size","placeholder","options","label","map","app","displayName"],"sources":["FilterByApp.tsx"],"sourcesContent":["import React from \"react\";\n\nimport { useBind, useForm } from \"@webiny/form\";\nimport { Select } from \"@webiny/ui/Select\";\nimport { auditLogsApps } from \"@webiny/api-audit-logs/config\";\n\nconst getValidFilterValue = (value: string): string | undefined => {\n if (value === \"all\" || value === \"\") {\n return undefined;\n }\n return value;\n};\n\nexport const FilterByApp = () => {\n const { setValue } = useForm();\n const bind = useBind({\n name: \"data.app\",\n beforeChange(value, cb) {\n setValue(\"data.entity\", undefined);\n setValue(\"data.action\", undefined);\n cb(getValidFilterValue(value));\n }\n });\n\n return (\n <Select\n {...bind}\n size={\"medium\"}\n placeholder={\"Filter by App\"}\n options={[\n { label: \"All\", value: \"all\" },\n ...auditLogsApps.map(app => ({ label: app.displayName, value: app.app }))\n ]}\n />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,OAAO,EAAEC,OAAO,QAAQ,cAAc;AAC/C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,aAAa,QAAQ,+BAA+B;AAE7D,MAAMC,mBAAmB,GAAIC,KAAa,IAAyB;EAC/D,IAAIA,KAAK,KAAK,KAAK,IAAIA,KAAK,KAAK,EAAE,EAAE;IACjC,OAAOC,SAAS;EACpB;EACA,OAAOD,KAAK;AAChB,CAAC;AAED,OAAO,MAAME,WAAW,GAAGA,CAAA,KAAM;EAC7B,MAAM;IAAEC;EAAS,CAAC,GAAGP,OAAO,CAAC,CAAC;EAC9B,MAAMQ,IAAI,GAAGT,OAAO,CAAC;IACjBU,IAAI,EAAE,UAAU;IAChBC,YAAYA,CAACN,KAAK,EAAEO,EAAE,EAAE;MACpBJ,QAAQ,CAAC,aAAa,EAAEF,SAAS,CAAC;MAClCE,QAAQ,CAAC,aAAa,EAAEF,SAAS,CAAC;MAClCM,EAAE,CAACR,mBAAmB,CAACC,KAAK,CAAC,CAAC;IAClC;EACJ,CAAC,CAAC;EAEF,oBACIN,KAAA,CAAAc,aAAA,CAACX,MAAM,EAAAY,MAAA,CAAAC,MAAA,KACCN,IAAI;IACRO,IAAI,EAAE,QAAS;IACfC,WAAW,EAAE,eAAgB;IAC7BC,OAAO,EAAE,CACL;MAAEC,KAAK,EAAE,KAAK;MAAEd,KAAK,EAAE;IAAM,CAAC,EAC9B,GAAGF,aAAa,CAACiB,GAAG,CAACC,GAAG,KAAK;MAAEF,KAAK,EAAEE,GAAG,CAACC,WAAW;MAAEjB,KAAK,EAAEgB,GAAG,CAACA;IAAI,CAAC,CAAC,CAAC;EAC3E,EACL,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { useBind, useForm } from "@webiny/form";
|
|
3
|
+
import { Select } from "@webiny/ui/Select";
|
|
4
|
+
import { auditLogsApps } from "@webiny/api-audit-logs/config";
|
|
5
|
+
const getValidFilterValue = value => {
|
|
6
|
+
if (value === "all" || value === "") {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
export const FilterByEntity = () => {
|
|
12
|
+
const {
|
|
13
|
+
data,
|
|
14
|
+
setValue
|
|
15
|
+
} = useForm();
|
|
16
|
+
const bind = useBind({
|
|
17
|
+
name: "data.entity",
|
|
18
|
+
beforeChange(value, cb) {
|
|
19
|
+
setValue("data.action", undefined);
|
|
20
|
+
cb(getValidFilterValue(value));
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const appValue = data?.data?.app;
|
|
24
|
+
const options = useMemo(() => {
|
|
25
|
+
if (!appValue) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const entities = auditLogsApps.find(app => app.app === appValue)?.entities || [];
|
|
29
|
+
return [{
|
|
30
|
+
label: "All",
|
|
31
|
+
value: "all"
|
|
32
|
+
}, ...entities.map(entity => ({
|
|
33
|
+
label: entity.displayName,
|
|
34
|
+
value: entity.type
|
|
35
|
+
}))];
|
|
36
|
+
}, [appValue]);
|
|
37
|
+
if (!appValue) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return /*#__PURE__*/React.createElement(Select, Object.assign({}, bind, {
|
|
41
|
+
size: "medium",
|
|
42
|
+
placeholder: "Filter by Entity",
|
|
43
|
+
options: options
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=FilterByEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","useBind","useForm","Select","auditLogsApps","getValidFilterValue","value","undefined","FilterByEntity","data","setValue","bind","name","beforeChange","cb","appValue","app","options","entities","find","label","map","entity","displayName","type","createElement","Object","assign","size","placeholder"],"sources":["FilterByEntity.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\n\nimport { useBind, useForm } from \"@webiny/form\";\nimport { Select } from \"@webiny/ui/Select\";\nimport { auditLogsApps } from \"@webiny/api-audit-logs/config\";\n\nconst getValidFilterValue = (value: string): string | undefined => {\n if (value === \"all\" || value === \"\") {\n return undefined;\n }\n return value;\n};\n\nexport const FilterByEntity = () => {\n const { data, setValue } = useForm();\n const bind = useBind({\n name: \"data.entity\",\n beforeChange(value, cb) {\n setValue(\"data.action\", undefined);\n cb(getValidFilterValue(value));\n }\n });\n\n const appValue = data?.data?.app;\n\n const options = useMemo(() => {\n if (!appValue) {\n return [];\n }\n\n const entities = auditLogsApps.find(app => app.app === appValue)?.entities || [];\n\n return [\n { label: \"All\", value: \"all\" },\n ...entities.map(entity => ({ label: entity.displayName, value: entity.type }))\n ];\n }, [appValue]);\n\n if (!appValue) {\n return null;\n }\n\n return <Select {...bind} size={\"medium\"} placeholder={\"Filter by Entity\"} options={options} />;\n};\n"],"mappings":"AAAA,OAAOA,KA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A,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EAEA,oBAAOhB,KAAA,CAAA0B,aAAA,CAACtB,MAAM,EAAAuB,MAAA,CAAAC,MAAA,KAAKhB,IAAI;IAAEiB,IAAI,EAAE,QAAS;IAACC,WAAW,EAAE,kBAAmB;IAACZ,OAAO,EAAEA;EAAQ,EAAE,CAAC;AAClG,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { useQuery } from "@apollo/react-hooks";
|
|
3
|
+
import { useBind } from "@webiny/form";
|
|
4
|
+
import { Select } from "@webiny/ui/Select";
|
|
5
|
+
import { LIST_USERS } from "../../../graphql";
|
|
6
|
+
const getValidFilterValue = value => {
|
|
7
|
+
if (value === "all" || value === "") {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
export const FilterByInitiator = () => {
|
|
13
|
+
const {
|
|
14
|
+
data: listUsers
|
|
15
|
+
} = useQuery(LIST_USERS);
|
|
16
|
+
const bind = useBind({
|
|
17
|
+
name: "data.initiator",
|
|
18
|
+
beforeChange(value, cb) {
|
|
19
|
+
cb(getValidFilterValue(value));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const options = useMemo(() => {
|
|
23
|
+
const users = listUsers?.adminUsers?.users?.data || [];
|
|
24
|
+
return [{
|
|
25
|
+
label: "All",
|
|
26
|
+
value: "all"
|
|
27
|
+
}, ...users.map(user => ({
|
|
28
|
+
label: `${user.firstName} ${user.lastName}`,
|
|
29
|
+
value: user.id
|
|
30
|
+
}))];
|
|
31
|
+
}, [listUsers]);
|
|
32
|
+
return /*#__PURE__*/React.createElement(Select, Object.assign({}, bind, {
|
|
33
|
+
size: "medium",
|
|
34
|
+
placeholder: "Filter by Initiator",
|
|
35
|
+
options: options
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=FilterByInitiator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","useQuery","useBind","Select","LIST_USERS","getValidFilterValue","value","undefined","FilterByInitiator","data","listUsers","bind","name","beforeChange","cb","options","users","adminUsers","label","map","user","firstName","lastName","id","createElement","Object","assign","size","placeholder"],"sources":["FilterByInitiator.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { useQuery } from \"@apollo/react-hooks\";\n\nimport { useBind } from \"@webiny/form\";\nimport { Select } from \"@webiny/ui/Select\";\n\nimport { LIST_USERS } from \"~/graphql\";\nimport type { User } from \"~/types\";\n\nconst getValidFilterValue = (value: string): string | undefined => {\n if (value === \"all\" || value === \"\") {\n return undefined;\n }\n return value;\n};\n\nexport const FilterByInitiator = () => {\n const { data: listUsers } = useQuery(LIST_USERS);\n const bind = useBind({\n name: \"data.initiator\",\n beforeChange(value, cb) {\n cb(getValidFilterValue(value));\n }\n });\n\n const options = useMemo(() => {\n const users: User[] = listUsers?.adminUsers?.users?.data || [];\n\n return [\n { label: \"All\", value: \"all\" },\n ...users.map(user => ({ label: `${user.firstName} ${user.lastName}`, value: user.id }))\n ];\n }, [listUsers]);\n\n return (\n <Select {...bind} size={\"medium\"} placeholder={\"Filter by Initiator\"} options={options} />\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,QAAQ,QAAQ,qBAAqB;AAE9C,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,SAASC,UAAU;AAGnB,MAAMC,mBAAmB,GAAIC,KAAa,IAAyB;EAC/D,IAAIA,KAAK,KAAK,KAAK,IAAIA,KAAK,KAAK,EAAE,EAAE;IACjC,OAAOC,SAAS;EACpB;EACA,OAAOD,KAAK;AAChB,CAAC;AAED,OAAO,MAAME,iBAAiB,GAAGA,CAAA,KAAM;EACnC,MAAM;IAAEC,IAAI,EAAEC;EAAU,CAAC,GAAGT,QAAQ,CAACG,UAAU,CAAC;EAChD,MAAMO,IAAI,GAAGT,OAAO,CAAC;IACjBU,IAAI,EAAE,gBAAgB;IACtBC,YAAYA,CAACP,KAAK,EAAEQ,EAAE,EAAE;MACpBA,EAAE,CAACT,mBAAmB,CAACC,KAAK,CAAC,CAAC;IAClC;EACJ,CAAC,CAAC;EAEF,MAAMS,OAAO,GAAGf,OAAO,CAAC,MAAM;IAC1B,MAAMgB,KAAa,GAAGN,SAAS,EAAEO,UAAU,EAAED,KAAK,EAAEP,IAAI,IAAI,EAAE;IAE9D,OAAO,CACH;MAAES,KAAK,EAAE,KAAK;MAAEZ,KAAK,EAAE;IAAM,CAAC,EAC9B,GAAGU,KAAK,CAACG,GAAG,CAACC,IAAI,KAAK;MAAEF,KAAK,EAAE,GAAGE,IAAI,CAACC,SAAS,IAAID,IAAI,CAACE,QAAQ,EAAE;MAAEhB,KAAK,EAAEc,IAAI,CAACG;IAAG,CAAC,CAAC,CAAC,CAC1F;EACL,CAAC,EAAE,CAACb,SAAS,CAAC,CAAC;EAEf,oBACIX,KAAA,CAAAyB,aAAA,CAACrB,MAAM,EAAAsB,MAAA,CAAAC,MAAA,KAAKf,IAAI;IAAEgB,IAAI,EAAE,QAAS;IAACC,WAAW,EAAE,qBAAsB;IAACb,OAAO,EAAEA;EAAQ,EAAE,CAAC;AAElG,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { format } from "date-fns";
|
|
3
|
+
import { Input } from "@webiny/ui/Input";
|
|
4
|
+
import { useBind } from "@webiny/form";
|
|
5
|
+
import { TimestampFiltersContainer } from "./styled";
|
|
6
|
+
const formatDateTime = date => {
|
|
7
|
+
if (!date) {
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
return format(new Date(date), "yyyy-MM-dd'T'HH:mm");
|
|
11
|
+
};
|
|
12
|
+
const getValidFilterValue = value => {
|
|
13
|
+
if (value === "") {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return new Date(value);
|
|
17
|
+
};
|
|
18
|
+
export const FilterByTimestamp = () => {
|
|
19
|
+
const bindFrom = useBind({
|
|
20
|
+
name: "data.timestamp_gte",
|
|
21
|
+
beforeChange(value, cb) {
|
|
22
|
+
cb(getValidFilterValue(value));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const bindTo = useBind({
|
|
26
|
+
name: "data.timestamp_lte",
|
|
27
|
+
beforeChange(value, cb) {
|
|
28
|
+
cb(getValidFilterValue(value));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return /*#__PURE__*/React.createElement(TimestampFiltersContainer, null, /*#__PURE__*/React.createElement(Input, Object.assign({}, bindFrom, {
|
|
32
|
+
value: formatDateTime(bindFrom.value),
|
|
33
|
+
type: "datetime-local"
|
|
34
|
+
})), /*#__PURE__*/React.createElement(Input, Object.assign({}, bindTo, {
|
|
35
|
+
value: formatDateTime(bindTo.value),
|
|
36
|
+
type: "datetime-local"
|
|
37
|
+
})));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=FilterByTimestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","format","Input","useBind","TimestampFiltersContainer","formatDateTime","date","Date","getValidFilterValue","value","undefined","FilterByTimestamp","bindFrom","name","beforeChange","cb","bindTo","createElement","Object","assign","type"],"sources":["FilterByTimestamp.tsx"],"sourcesContent":["import React from \"react\";\nimport { format } from \"date-fns\";\n\nimport { Input } from \"@webiny/ui/Input\";\nimport { useBind } from \"@webiny/form\";\n\nimport { TimestampFiltersContainer } from \"./styled\";\n\nconst formatDateTime = (date: string) => {\n if (!date) {\n return \"\";\n }\n\n return format(new Date(date), \"yyyy-MM-dd'T'HH:mm\");\n};\n\nconst getValidFilterValue = (value: string): Date | undefined => {\n if (value === \"\") {\n return undefined;\n }\n\n return new Date(value);\n};\n\nexport const FilterByTimestamp = () => {\n const bindFrom = useBind({\n name: \"data.timestamp_gte\",\n beforeChange(value, cb) {\n cb(getValidFilterValue(value));\n }\n });\n\n const bindTo = useBind({\n name: \"data.timestamp_lte\",\n beforeChange(value, cb) {\n cb(getValidFilterValue(value));\n }\n });\n\n return (\n <TimestampFiltersContainer>\n <Input {...bindFrom} value={formatDateTime(bindFrom.value)} type=\"datetime-local\" />\n <Input {...bindTo} value={formatDateTime(bindTo.value)} type=\"datetime-local\" />\n </TimestampFiltersContainer>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,UAAU;AAEjC,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,OAAO,QAAQ,cAAc;AAEtC,SAASC,yBAAyB;AAElC,MAAMC,cAAc,GAAIC,IAAY,IAAK;EACrC,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,EAAE;EACb;EAEA,OAAOL,MAAM,CAAC,IAAIM,IAAI,CAACD,IAAI,CAAC,EAAE,oBAAoB,CAAC;AACvD,CAAC;AAED,MAAME,mBAAmB,GAAIC,KAAa,IAAuB;EAC7D,IAAIA,KAAK,KAAK,EAAE,EAAE;IACd,OAAOC,SAAS;EACpB;EAEA,OAAO,IAAIH,IAAI,CAACE,KAAK,CAAC;AAC1B,CAAC;AAED,OAAO,MAAME,iBAAiB,GAAGA,CAAA,KAAM;EACnC,MAAMC,QAAQ,GAAGT,OAAO,CAAC;IACrBU,IAAI,EAAE,oBAAoB;IAC1BC,YAAYA,CAACL,KAAK,EAAEM,EAAE,EAAE;MACpBA,EAAE,CAACP,mBAAmB,CAACC,KAAK,CAAC,CAAC;IAClC;EACJ,CAAC,CAAC;EAEF,MAAMO,MAAM,GAAGb,OAAO,CAAC;IACnBU,IAAI,EAAE,oBAAoB;IAC1BC,YAAYA,CAACL,KAAK,EAAEM,EAAE,EAAE;MACpBA,EAAE,CAACP,mBAAmB,CAACC,KAAK,CAAC,CAAC;IAClC;EACJ,CAAC,CAAC;EAEF,oBACIT,KAAA,CAAAiB,aAAA,CAACb,yBAAyB,qBACtBJ,KAAA,CAAAiB,aAAA,CAACf,KAAK,EAAAgB,MAAA,CAAAC,MAAA,KAAKP,QAAQ;IAAEH,KAAK,EAAEJ,cAAc,CAACO,QAAQ,CAACH,KAAK,CAAE;IAACW,IAAI,EAAC;EAAgB,EAAE,CAAC,eACpFpB,KAAA,CAAAiB,aAAA,CAACf,KAAK,EAAAgB,MAAA,CAAAC,MAAA,KAAKH,MAAM;IAAEP,KAAK,EAAEJ,cAAc,CAACW,MAAM,CAACP,KAAK,CAAE;IAACW,IAAI,EAAC;EAAgB,EAAE,CACxD,CAAC;AAEpC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type FiltersProps = {
|
|
3
|
+
showingFilters: boolean;
|
|
4
|
+
setFilters: (data: Record<string, any>) => void;
|
|
5
|
+
hasAccessToUsers: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const Filters: ({ showingFilters, setFilters, hasAccessToUsers }: FiltersProps) => React.JSX.Element;
|
|
8
|
+
export {};
|