node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
'use strict';
var admin = require('@strapi/strapi/admin');
var yup = require('yup');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
const createRoleSchema = yup__namespace.object().shape({
name: yup__namespace.string().required(admin.translatedErrors.required.id),
description: yup__namespace.string().required(admin.translatedErrors.required.id)
});
exports.createRoleSchema = createRoleSchema;
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sources":["../../../../admin/src/pages/Roles/constants.js"],"sourcesContent":["import { translatedErrors } from '@strapi/strapi/admin';\nimport * as yup from 'yup';\n\nexport const createRoleSchema = yup.object().shape({\n name: yup.string().required(translatedErrors.required.id),\n description: yup.string().required(translatedErrors.required.id),\n});\n"],"names":["createRoleSchema","yup","object","shape","name","string","required","translatedErrors","id","description"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;MAGaA,gBAAmBC,GAAAA,cAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;IACjDC,IAAMH,EAAAA,cAAAA,CAAII,MAAM,EAAGC,CAAAA,QAAQ,CAACC,sBAAiBD,CAAAA,QAAQ,CAACE,EAAE,CAAA;IACxDC,WAAaR,EAAAA,cAAAA,CAAII,MAAM,EAAGC,CAAAA,QAAQ,CAACC,sBAAiBD,CAAAA,QAAQ,CAACE,EAAE;AACjE,CAAG;;;;"}

View File

@@ -0,0 +1,10 @@
import { translatedErrors } from '@strapi/strapi/admin';
import * as yup from 'yup';
const createRoleSchema = yup.object().shape({
name: yup.string().required(translatedErrors.required.id),
description: yup.string().required(translatedErrors.required.id)
});
export { createRoleSchema };
//# sourceMappingURL=constants.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constants.mjs","sources":["../../../../admin/src/pages/Roles/constants.js"],"sourcesContent":["import { translatedErrors } from '@strapi/strapi/admin';\nimport * as yup from 'yup';\n\nexport const createRoleSchema = yup.object().shape({\n name: yup.string().required(translatedErrors.required.id),\n description: yup.string().required(translatedErrors.required.id),\n});\n"],"names":["createRoleSchema","yup","object","shape","name","string","required","translatedErrors","id","description"],"mappings":";;;MAGaA,gBAAmBC,GAAAA,GAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;IACjDC,IAAMH,EAAAA,GAAAA,CAAII,MAAM,EAAGC,CAAAA,QAAQ,CAACC,gBAAiBD,CAAAA,QAAQ,CAACE,EAAE,CAAA;IACxDC,WAAaR,EAAAA,GAAAA,CAAII,MAAM,EAAGC,CAAAA,QAAQ,CAACC,gBAAiBD,CAAAA,QAAQ,CAACE,EAAE;AACjE,CAAG;;;;"}

View File

@@ -0,0 +1,78 @@
'use strict';
var React = require('react');
var admin = require('@strapi/strapi/admin');
var reactQuery = require('react-query');
var cleanPermissions = require('../../../utils/cleanPermissions.js');
var getTrad = require('../../../utils/getTrad.js');
const usePlugins = ()=>{
const { toggleNotification } = admin.useNotification();
const { get } = admin.useFetchClient();
const { formatAPIError } = admin.useAPIErrorHandler(getTrad);
const [{ data: permissions, isLoading: isLoadingPermissions, error: permissionsError, refetch: refetchPermissions }, { data: routes, isLoading: isLoadingRoutes, error: routesError, refetch: refetchRoutes }] = reactQuery.useQueries([
{
queryKey: [
'users-permissions',
'permissions'
],
async queryFn () {
const { data: { permissions } } = await get(`/users-permissions/permissions`);
return permissions;
}
},
{
queryKey: [
'users-permissions',
'routes'
],
async queryFn () {
const { data: { routes } } = await get(`/users-permissions/routes`);
return routes;
}
}
]);
const refetchQueries = async ()=>{
await Promise.all([
refetchPermissions(),
refetchRoutes()
]);
};
React.useEffect(()=>{
if (permissionsError) {
toggleNotification({
type: 'danger',
message: formatAPIError(permissionsError)
});
}
}, [
toggleNotification,
permissionsError,
formatAPIError
]);
React.useEffect(()=>{
if (routesError) {
toggleNotification({
type: 'danger',
message: formatAPIError(routesError)
});
}
}, [
toggleNotification,
routesError,
formatAPIError
]);
const isLoading = isLoadingPermissions || isLoadingRoutes;
return {
// TODO: these return values need to be memoized, otherwise
// they will create infinite rendering loops when used as
// effect dependencies
permissions: permissions ? cleanPermissions(permissions) : {},
routes: routes ?? {},
getData: refetchQueries,
isLoading
};
};
exports.usePlugins = usePlugins;
//# sourceMappingURL=usePlugins.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"usePlugins.js","sources":["../../../../../admin/src/pages/Roles/hooks/usePlugins.js"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';\nimport { useQueries } from 'react-query';\n\nimport { cleanPermissions, getTrad } from '../../../utils';\n\nexport const usePlugins = () => {\n const { toggleNotification } = useNotification();\n const { get } = useFetchClient();\n const { formatAPIError } = useAPIErrorHandler(getTrad);\n\n const [\n {\n data: permissions,\n isLoading: isLoadingPermissions,\n error: permissionsError,\n refetch: refetchPermissions,\n },\n { data: routes, isLoading: isLoadingRoutes, error: routesError, refetch: refetchRoutes },\n ] = useQueries([\n {\n queryKey: ['users-permissions', 'permissions'],\n async queryFn() {\n const {\n data: { permissions },\n } = await get(`/users-permissions/permissions`);\n\n return permissions;\n },\n },\n {\n queryKey: ['users-permissions', 'routes'],\n async queryFn() {\n const {\n data: { routes },\n } = await get(`/users-permissions/routes`);\n\n return routes;\n },\n },\n ]);\n\n const refetchQueries = async () => {\n await Promise.all([refetchPermissions(), refetchRoutes()]);\n };\n\n useEffect(() => {\n if (permissionsError) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(permissionsError),\n });\n }\n }, [toggleNotification, permissionsError, formatAPIError]);\n\n useEffect(() => {\n if (routesError) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(routesError),\n });\n }\n }, [toggleNotification, routesError, formatAPIError]);\n\n const isLoading = isLoadingPermissions || isLoadingRoutes;\n\n return {\n // TODO: these return values need to be memoized, otherwise\n // they will create infinite rendering loops when used as\n // effect dependencies\n permissions: permissions ? cleanPermissions(permissions) : {},\n routes: routes ?? {},\n\n getData: refetchQueries,\n isLoading,\n };\n};\n"],"names":["usePlugins","toggleNotification","useNotification","get","useFetchClient","formatAPIError","useAPIErrorHandler","getTrad","data","permissions","isLoading","isLoadingPermissions","error","permissionsError","refetch","refetchPermissions","routes","isLoadingRoutes","routesError","refetchRoutes","useQueries","queryKey","queryFn","refetchQueries","Promise","all","useEffect","type","message","cleanPermissions","getData"],"mappings":";;;;;;;;MAOaA,UAAa,GAAA,IAAA;IACxB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,qBAAAA,EAAAA;IAC/B,MAAM,EAAEC,GAAG,EAAE,GAAGC,oBAAAA,EAAAA;AAChB,IAAA,MAAM,EAAEC,cAAc,EAAE,GAAGC,wBAAmBC,CAAAA,OAAAA,CAAAA;AAE9C,IAAA,MAAM,CACJ,EACEC,IAAMC,EAAAA,WAAW,EACjBC,SAAAA,EAAWC,oBAAoB,EAC/BC,KAAOC,EAAAA,gBAAgB,EACvBC,OAAAA,EAASC,kBAAkB,EAC5B,EACD,EAAEP,IAAAA,EAAMQ,MAAM,EAAEN,SAAWO,EAAAA,eAAe,EAAEL,KAAAA,EAAOM,WAAW,EAAEJ,OAASK,EAAAA,aAAa,EAAE,CACzF,GAAGC,qBAAW,CAAA;AACb,QAAA;YACEC,QAAU,EAAA;AAAC,gBAAA,mBAAA;AAAqB,gBAAA;AAAc,aAAA;YAC9C,MAAMC,OAAAA,CAAAA,GAAAA;gBACJ,MAAM,EACJd,IAAM,EAAA,EAAEC,WAAW,EAAE,EACtB,GAAG,MAAMN,GAAAA,CAAI,CAAC,8BAA8B,CAAC,CAAA;gBAE9C,OAAOM,WAAAA;AACT;AACF,SAAA;AACA,QAAA;YACEY,QAAU,EAAA;AAAC,gBAAA,mBAAA;AAAqB,gBAAA;AAAS,aAAA;YACzC,MAAMC,OAAAA,CAAAA,GAAAA;gBACJ,MAAM,EACJd,IAAM,EAAA,EAAEQ,MAAM,EAAE,EACjB,GAAG,MAAMb,GAAAA,CAAI,CAAC,yBAAyB,CAAC,CAAA;gBAEzC,OAAOa,MAAAA;AACT;AACF;AACD,KAAA,CAAA;AAED,IAAA,MAAMO,cAAiB,GAAA,UAAA;QACrB,MAAMC,OAAAA,CAAQC,GAAG,CAAC;AAACV,YAAAA,kBAAAA,EAAAA;AAAsBI,YAAAA,aAAAA;AAAgB,SAAA,CAAA;AAC3D,KAAA;IAEAO,eAAU,CAAA,IAAA;AACR,QAAA,IAAIb,gBAAkB,EAAA;YACpBZ,kBAAmB,CAAA;gBACjB0B,IAAM,EAAA,QAAA;AACNC,gBAAAA,OAAAA,EAASvB,cAAeQ,CAAAA,gBAAAA;AAC1B,aAAA,CAAA;AACF;KACC,EAAA;AAACZ,QAAAA,kBAAAA;AAAoBY,QAAAA,gBAAAA;AAAkBR,QAAAA;AAAe,KAAA,CAAA;IAEzDqB,eAAU,CAAA,IAAA;AACR,QAAA,IAAIR,WAAa,EAAA;YACfjB,kBAAmB,CAAA;gBACjB0B,IAAM,EAAA,QAAA;AACNC,gBAAAA,OAAAA,EAASvB,cAAea,CAAAA,WAAAA;AAC1B,aAAA,CAAA;AACF;KACC,EAAA;AAACjB,QAAAA,kBAAAA;AAAoBiB,QAAAA,WAAAA;AAAab,QAAAA;AAAe,KAAA,CAAA;AAEpD,IAAA,MAAMK,YAAYC,oBAAwBM,IAAAA,eAAAA;IAE1C,OAAO;;;;QAILR,WAAaA,EAAAA,WAAAA,GAAcoB,gBAAiBpB,CAAAA,WAAAA,CAAAA,GAAe,EAAC;AAC5DO,QAAAA,MAAAA,EAAQA,UAAU,EAAC;QAEnBc,OAASP,EAAAA,cAAAA;AACTb,QAAAA;AACF,KAAA;AACF;;;;"}

View File

@@ -0,0 +1,76 @@
import { useEffect } from 'react';
import { useNotification, useFetchClient, useAPIErrorHandler } from '@strapi/strapi/admin';
import { useQueries } from 'react-query';
import cleanPermissions from '../../../utils/cleanPermissions.mjs';
import getTrad from '../../../utils/getTrad.mjs';
const usePlugins = ()=>{
const { toggleNotification } = useNotification();
const { get } = useFetchClient();
const { formatAPIError } = useAPIErrorHandler(getTrad);
const [{ data: permissions, isLoading: isLoadingPermissions, error: permissionsError, refetch: refetchPermissions }, { data: routes, isLoading: isLoadingRoutes, error: routesError, refetch: refetchRoutes }] = useQueries([
{
queryKey: [
'users-permissions',
'permissions'
],
async queryFn () {
const { data: { permissions } } = await get(`/users-permissions/permissions`);
return permissions;
}
},
{
queryKey: [
'users-permissions',
'routes'
],
async queryFn () {
const { data: { routes } } = await get(`/users-permissions/routes`);
return routes;
}
}
]);
const refetchQueries = async ()=>{
await Promise.all([
refetchPermissions(),
refetchRoutes()
]);
};
useEffect(()=>{
if (permissionsError) {
toggleNotification({
type: 'danger',
message: formatAPIError(permissionsError)
});
}
}, [
toggleNotification,
permissionsError,
formatAPIError
]);
useEffect(()=>{
if (routesError) {
toggleNotification({
type: 'danger',
message: formatAPIError(routesError)
});
}
}, [
toggleNotification,
routesError,
formatAPIError
]);
const isLoading = isLoadingPermissions || isLoadingRoutes;
return {
// TODO: these return values need to be memoized, otherwise
// they will create infinite rendering loops when used as
// effect dependencies
permissions: permissions ? cleanPermissions(permissions) : {},
routes: routes ?? {},
getData: refetchQueries,
isLoading
};
};
export { usePlugins };
//# sourceMappingURL=usePlugins.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"usePlugins.mjs","sources":["../../../../../admin/src/pages/Roles/hooks/usePlugins.js"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useAPIErrorHandler, useNotification, useFetchClient } from '@strapi/strapi/admin';\nimport { useQueries } from 'react-query';\n\nimport { cleanPermissions, getTrad } from '../../../utils';\n\nexport const usePlugins = () => {\n const { toggleNotification } = useNotification();\n const { get } = useFetchClient();\n const { formatAPIError } = useAPIErrorHandler(getTrad);\n\n const [\n {\n data: permissions,\n isLoading: isLoadingPermissions,\n error: permissionsError,\n refetch: refetchPermissions,\n },\n { data: routes, isLoading: isLoadingRoutes, error: routesError, refetch: refetchRoutes },\n ] = useQueries([\n {\n queryKey: ['users-permissions', 'permissions'],\n async queryFn() {\n const {\n data: { permissions },\n } = await get(`/users-permissions/permissions`);\n\n return permissions;\n },\n },\n {\n queryKey: ['users-permissions', 'routes'],\n async queryFn() {\n const {\n data: { routes },\n } = await get(`/users-permissions/routes`);\n\n return routes;\n },\n },\n ]);\n\n const refetchQueries = async () => {\n await Promise.all([refetchPermissions(), refetchRoutes()]);\n };\n\n useEffect(() => {\n if (permissionsError) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(permissionsError),\n });\n }\n }, [toggleNotification, permissionsError, formatAPIError]);\n\n useEffect(() => {\n if (routesError) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(routesError),\n });\n }\n }, [toggleNotification, routesError, formatAPIError]);\n\n const isLoading = isLoadingPermissions || isLoadingRoutes;\n\n return {\n // TODO: these return values need to be memoized, otherwise\n // they will create infinite rendering loops when used as\n // effect dependencies\n permissions: permissions ? cleanPermissions(permissions) : {},\n routes: routes ?? {},\n\n getData: refetchQueries,\n isLoading,\n };\n};\n"],"names":["usePlugins","toggleNotification","useNotification","get","useFetchClient","formatAPIError","useAPIErrorHandler","getTrad","data","permissions","isLoading","isLoadingPermissions","error","permissionsError","refetch","refetchPermissions","routes","isLoadingRoutes","routesError","refetchRoutes","useQueries","queryKey","queryFn","refetchQueries","Promise","all","useEffect","type","message","cleanPermissions","getData"],"mappings":";;;;;;MAOaA,UAAa,GAAA,IAAA;IACxB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,eAAAA,EAAAA;IAC/B,MAAM,EAAEC,GAAG,EAAE,GAAGC,cAAAA,EAAAA;AAChB,IAAA,MAAM,EAAEC,cAAc,EAAE,GAAGC,kBAAmBC,CAAAA,OAAAA,CAAAA;AAE9C,IAAA,MAAM,CACJ,EACEC,IAAMC,EAAAA,WAAW,EACjBC,SAAAA,EAAWC,oBAAoB,EAC/BC,KAAOC,EAAAA,gBAAgB,EACvBC,OAAAA,EAASC,kBAAkB,EAC5B,EACD,EAAEP,IAAAA,EAAMQ,MAAM,EAAEN,SAAWO,EAAAA,eAAe,EAAEL,KAAAA,EAAOM,WAAW,EAAEJ,OAASK,EAAAA,aAAa,EAAE,CACzF,GAAGC,UAAW,CAAA;AACb,QAAA;YACEC,QAAU,EAAA;AAAC,gBAAA,mBAAA;AAAqB,gBAAA;AAAc,aAAA;YAC9C,MAAMC,OAAAA,CAAAA,GAAAA;gBACJ,MAAM,EACJd,IAAM,EAAA,EAAEC,WAAW,EAAE,EACtB,GAAG,MAAMN,GAAAA,CAAI,CAAC,8BAA8B,CAAC,CAAA;gBAE9C,OAAOM,WAAAA;AACT;AACF,SAAA;AACA,QAAA;YACEY,QAAU,EAAA;AAAC,gBAAA,mBAAA;AAAqB,gBAAA;AAAS,aAAA;YACzC,MAAMC,OAAAA,CAAAA,GAAAA;gBACJ,MAAM,EACJd,IAAM,EAAA,EAAEQ,MAAM,EAAE,EACjB,GAAG,MAAMb,GAAAA,CAAI,CAAC,yBAAyB,CAAC,CAAA;gBAEzC,OAAOa,MAAAA;AACT;AACF;AACD,KAAA,CAAA;AAED,IAAA,MAAMO,cAAiB,GAAA,UAAA;QACrB,MAAMC,OAAAA,CAAQC,GAAG,CAAC;AAACV,YAAAA,kBAAAA,EAAAA;AAAsBI,YAAAA,aAAAA;AAAgB,SAAA,CAAA;AAC3D,KAAA;IAEAO,SAAU,CAAA,IAAA;AACR,QAAA,IAAIb,gBAAkB,EAAA;YACpBZ,kBAAmB,CAAA;gBACjB0B,IAAM,EAAA,QAAA;AACNC,gBAAAA,OAAAA,EAASvB,cAAeQ,CAAAA,gBAAAA;AAC1B,aAAA,CAAA;AACF;KACC,EAAA;AAACZ,QAAAA,kBAAAA;AAAoBY,QAAAA,gBAAAA;AAAkBR,QAAAA;AAAe,KAAA,CAAA;IAEzDqB,SAAU,CAAA,IAAA;AACR,QAAA,IAAIR,WAAa,EAAA;YACfjB,kBAAmB,CAAA;gBACjB0B,IAAM,EAAA,QAAA;AACNC,gBAAAA,OAAAA,EAASvB,cAAea,CAAAA,WAAAA;AAC1B,aAAA,CAAA;AACF;KACC,EAAA;AAACjB,QAAAA,kBAAAA;AAAoBiB,QAAAA,WAAAA;AAAab,QAAAA;AAAe,KAAA,CAAA;AAEpD,IAAA,MAAMK,YAAYC,oBAAwBM,IAAAA,eAAAA;IAE1C,OAAO;;;;QAILR,WAAaA,EAAAA,WAAAA,GAAcoB,gBAAiBpB,CAAAA,WAAAA,CAAAA,GAAe,EAAC;AAC5DO,QAAAA,MAAAA,EAAQA,UAAU,EAAC;QAEnBc,OAASP,EAAAA,cAAAA;AACTb,QAAAA;AACF,KAAA;AACF;;;;"}

View File

@@ -0,0 +1,35 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var admin = require('@strapi/strapi/admin');
var reactRouterDom = require('react-router-dom');
var constants = require('../../constants.js');
var CreatePage = require('./pages/CreatePage.js');
var EditPage = require('./pages/EditPage.js');
var index = require('./pages/ListPage/index.js');
const Roles = ()=>{
return /*#__PURE__*/ jsxRuntime.jsx(admin.Page.Protect, {
permissions: constants.PERMISSIONS.accessRoles,
children: /*#__PURE__*/ jsxRuntime.jsxs(reactRouterDom.Routes, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(reactRouterDom.Route, {
index: true,
element: /*#__PURE__*/ jsxRuntime.jsx(index.ProtectedRolesListPage, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(reactRouterDom.Route, {
path: "new",
element: /*#__PURE__*/ jsxRuntime.jsx(CreatePage.ProtectedRolesCreatePage, {})
}),
/*#__PURE__*/ jsxRuntime.jsx(reactRouterDom.Route, {
path: ":id",
element: /*#__PURE__*/ jsxRuntime.jsx(EditPage.ProtectedRolesEditPage, {})
})
]
})
});
};
module.exports = Roles;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../admin/src/pages/Roles/index.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page } from '@strapi/strapi/admin';\nimport { Route, Routes } from 'react-router-dom';\n\nimport { PERMISSIONS } from '../../constants';\n\nimport { ProtectedRolesCreatePage } from './pages/CreatePage';\nimport { ProtectedRolesEditPage } from './pages/EditPage';\nimport { ProtectedRolesListPage } from './pages/ListPage';\n\nconst Roles = () => {\n return (\n <Page.Protect permissions={PERMISSIONS.accessRoles}>\n <Routes>\n <Route index element={<ProtectedRolesListPage />} />\n <Route path=\"new\" element={<ProtectedRolesCreatePage />} />\n <Route path=\":id\" element={<ProtectedRolesEditPage />} />\n </Routes>\n </Page.Protect>\n );\n};\n\nexport default Roles;\n"],"names":["Roles","_jsx","Page","Protect","permissions","PERMISSIONS","accessRoles","_jsxs","Routes","Route","index","element","ProtectedRolesListPage","path","ProtectedRolesCreatePage","ProtectedRolesEditPage"],"mappings":";;;;;;;;;;;AAWA,MAAMA,KAAQ,GAAA,IAAA;IACZ,qBACEC,cAAA,CAACC,WAAKC,OAAO,EAAA;AAACC,QAAAA,WAAAA,EAAaC,sBAAYC,WAAW;AAChD,QAAA,QAAA,gBAAAC,eAACC,CAAAA,qBAAAA,EAAAA;;8BACCP,cAACQ,CAAAA,oBAAAA,EAAAA;oBAAMC,KAAK,EAAA,IAAA;AAACC,oBAAAA,OAAAA,gBAASV,cAACW,CAAAA,4BAAAA,EAAAA,EAAAA;;8BACvBX,cAACQ,CAAAA,oBAAAA,EAAAA;oBAAMI,IAAK,EAAA,KAAA;AAAMF,oBAAAA,OAAAA,gBAASV,cAACa,CAAAA,mCAAAA,EAAAA,EAAAA;;8BAC5Bb,cAACQ,CAAAA,oBAAAA,EAAAA;oBAAMI,IAAK,EAAA,KAAA;AAAMF,oBAAAA,OAAAA,gBAASV,cAACc,CAAAA,+BAAAA,EAAAA,EAAAA;;;;;AAIpC;;;;"}

View File

@@ -0,0 +1,33 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import 'react';
import { Page } from '@strapi/strapi/admin';
import { Routes, Route } from 'react-router-dom';
import { PERMISSIONS } from '../../constants.mjs';
import { ProtectedRolesCreatePage } from './pages/CreatePage.mjs';
import { ProtectedRolesEditPage } from './pages/EditPage.mjs';
import { ProtectedRolesListPage } from './pages/ListPage/index.mjs';
const Roles = ()=>{
return /*#__PURE__*/ jsx(Page.Protect, {
permissions: PERMISSIONS.accessRoles,
children: /*#__PURE__*/ jsxs(Routes, {
children: [
/*#__PURE__*/ jsx(Route, {
index: true,
element: /*#__PURE__*/ jsx(ProtectedRolesListPage, {})
}),
/*#__PURE__*/ jsx(Route, {
path: "new",
element: /*#__PURE__*/ jsx(ProtectedRolesCreatePage, {})
}),
/*#__PURE__*/ jsx(Route, {
path: ":id",
element: /*#__PURE__*/ jsx(ProtectedRolesEditPage, {})
})
]
})
});
};
export { Roles as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../admin/src/pages/Roles/index.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Page } from '@strapi/strapi/admin';\nimport { Route, Routes } from 'react-router-dom';\n\nimport { PERMISSIONS } from '../../constants';\n\nimport { ProtectedRolesCreatePage } from './pages/CreatePage';\nimport { ProtectedRolesEditPage } from './pages/EditPage';\nimport { ProtectedRolesListPage } from './pages/ListPage';\n\nconst Roles = () => {\n return (\n <Page.Protect permissions={PERMISSIONS.accessRoles}>\n <Routes>\n <Route index element={<ProtectedRolesListPage />} />\n <Route path=\"new\" element={<ProtectedRolesCreatePage />} />\n <Route path=\":id\" element={<ProtectedRolesEditPage />} />\n </Routes>\n </Page.Protect>\n );\n};\n\nexport default Roles;\n"],"names":["Roles","_jsx","Page","Protect","permissions","PERMISSIONS","accessRoles","_jsxs","Routes","Route","index","element","ProtectedRolesListPage","path","ProtectedRolesCreatePage","ProtectedRolesEditPage"],"mappings":";;;;;;;;;AAWA,MAAMA,KAAQ,GAAA,IAAA;IACZ,qBACEC,GAAA,CAACC,KAAKC,OAAO,EAAA;AAACC,QAAAA,WAAAA,EAAaC,YAAYC,WAAW;AAChD,QAAA,QAAA,gBAAAC,IAACC,CAAAA,MAAAA,EAAAA;;8BACCP,GAACQ,CAAAA,KAAAA,EAAAA;oBAAMC,KAAK,EAAA,IAAA;AAACC,oBAAAA,OAAAA,gBAASV,GAACW,CAAAA,sBAAAA,EAAAA,EAAAA;;8BACvBX,GAACQ,CAAAA,KAAAA,EAAAA;oBAAMI,IAAK,EAAA,KAAA;AAAMF,oBAAAA,OAAAA,gBAASV,GAACa,CAAAA,wBAAAA,EAAAA,EAAAA;;8BAC5Bb,GAACQ,CAAAA,KAAAA,EAAAA;oBAAMI,IAAK,EAAA,KAAA;AAAMF,oBAAAA,OAAAA,gBAASV,GAACc,CAAAA,sBAAAA,EAAAA,EAAAA;;;;;AAIpC;;;;"}

View File

@@ -0,0 +1,225 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var admin = require('@strapi/strapi/admin');
var formik = require('formik');
var reactIntl = require('react-intl');
var reactQuery = require('react-query');
var reactRouterDom = require('react-router-dom');
var index = require('../../../components/UsersPermissions/index.js');
var constants = require('../../../constants.js');
var getTrad = require('../../../utils/getTrad.js');
var constants$1 = require('../constants.js');
var usePlugins = require('../hooks/usePlugins.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const CreatePage = ()=>{
const { formatMessage } = reactIntl.useIntl();
const { toggleNotification } = admin.useNotification();
const navigate = reactRouterDom.useNavigate();
const { isLoading: isLoadingPlugins, permissions, routes } = usePlugins.usePlugins();
const { trackUsage } = admin.useTracking();
const permissionsRef = React__namespace.useRef();
const { post } = admin.useFetchClient();
const mutation = reactQuery.useMutation((body)=>post(`/users-permissions/roles`, body), {
onError () {
toggleNotification({
type: 'danger',
message: formatMessage({
id: 'notification.error',
defaultMessage: 'An error occurred'
})
});
},
onSuccess () {
trackUsage('didCreateRole');
toggleNotification({
type: 'success',
message: formatMessage({
id: getTrad('Settings.roles.created'),
defaultMessage: 'Role created'
})
});
// Forcing redirecting since we don't have the id in the response
navigate(-1);
}
});
const handleCreateRoleSubmit = async (data)=>{
// TODO: refactor. Child -> parent component communication is evil;
// We should either move the provider one level up or move the state
// straight into redux.
const permissions = permissionsRef.current.getPermissions();
await mutation.mutate({
...data,
...permissions,
users: []
});
};
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Main, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(admin.Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: 'Roles'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(formik.Formik, {
enableReinitialize: true,
initialValues: {
name: '',
description: ''
},
onSubmit: handleCreateRoleSubmit,
validationSchema: constants$1.createRoleSchema,
children: ({ handleSubmit, values, handleChange, errors })=>/*#__PURE__*/ jsxRuntime.jsxs(formik.Form, {
noValidate: true,
onSubmit: handleSubmit,
children: [
/*#__PURE__*/ jsxRuntime.jsx(admin.Layouts.Header, {
primaryAction: !isLoadingPlugins && /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
type: "submit",
loading: mutation.isLoading,
startIcon: /*#__PURE__*/ jsxRuntime.jsx(icons.Check, {}),
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
}),
title: formatMessage({
id: 'Settings.roles.create.title',
defaultMessage: 'Create a role'
}),
subtitle: formatMessage({
id: 'Settings.roles.create.description',
defaultMessage: 'Define the rights given to the role'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(admin.Layouts.Content, {
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
background: "neutral0",
direction: "column",
alignItems: "stretch",
gap: 7,
hasRadius: true,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
shadow: "filterShadow",
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: getTrad('EditPage.form.roles'),
defaultMessage: 'Role details'
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Root, {
gap: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
name: "name",
error: errors?.name ? formatMessage({
id: errors.name,
defaultMessage: 'Name is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
children: formatMessage({
id: 'global.name',
defaultMessage: 'Name'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.TextInput, {
value: values.name || '',
onChange: handleChange
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {})
]
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
name: "description",
error: errors?.description ? formatMessage({
id: errors.description,
defaultMessage: 'Description is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
children: formatMessage({
id: 'global.description',
defaultMessage: 'Description'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Textarea, {
value: values.description || '',
onChange: handleChange
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {})
]
})
})
]
})
]
}),
!isLoadingPlugins && /*#__PURE__*/ jsxRuntime.jsx(index, {
ref: permissionsRef,
permissions: permissions,
routes: routes
})
]
})
})
]
})
})
]
});
};
const ProtectedRolesCreatePage = ()=>/*#__PURE__*/ jsxRuntime.jsx(admin.Page.Protect, {
permissions: constants.PERMISSIONS.createRole,
children: /*#__PURE__*/ jsxRuntime.jsx(CreatePage, {})
});
exports.CreatePage = CreatePage;
exports.ProtectedRolesCreatePage = ProtectedRolesCreatePage;
//# sourceMappingURL=CreatePage.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,203 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import * as React from 'react';
import { Main, Button, Flex, Typography, Grid, Field, TextInput, Textarea } from '@strapi/design-system';
import { Check } from '@strapi/icons';
import { Page, useNotification, useTracking, useFetchClient, Layouts } from '@strapi/strapi/admin';
import { Formik, Form } from 'formik';
import { useIntl } from 'react-intl';
import { useMutation } from 'react-query';
import { useNavigate } from 'react-router-dom';
import UsersPermissions from '../../../components/UsersPermissions/index.mjs';
import { PERMISSIONS } from '../../../constants.mjs';
import getTrad from '../../../utils/getTrad.mjs';
import { createRoleSchema } from '../constants.mjs';
import { usePlugins } from '../hooks/usePlugins.mjs';
const CreatePage = ()=>{
const { formatMessage } = useIntl();
const { toggleNotification } = useNotification();
const navigate = useNavigate();
const { isLoading: isLoadingPlugins, permissions, routes } = usePlugins();
const { trackUsage } = useTracking();
const permissionsRef = React.useRef();
const { post } = useFetchClient();
const mutation = useMutation((body)=>post(`/users-permissions/roles`, body), {
onError () {
toggleNotification({
type: 'danger',
message: formatMessage({
id: 'notification.error',
defaultMessage: 'An error occurred'
})
});
},
onSuccess () {
trackUsage('didCreateRole');
toggleNotification({
type: 'success',
message: formatMessage({
id: getTrad('Settings.roles.created'),
defaultMessage: 'Role created'
})
});
// Forcing redirecting since we don't have the id in the response
navigate(-1);
}
});
const handleCreateRoleSubmit = async (data)=>{
// TODO: refactor. Child -> parent component communication is evil;
// We should either move the provider one level up or move the state
// straight into redux.
const permissions = permissionsRef.current.getPermissions();
await mutation.mutate({
...data,
...permissions,
users: []
});
};
return /*#__PURE__*/ jsxs(Main, {
children: [
/*#__PURE__*/ jsx(Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: 'Roles'
})
}),
/*#__PURE__*/ jsx(Formik, {
enableReinitialize: true,
initialValues: {
name: '',
description: ''
},
onSubmit: handleCreateRoleSubmit,
validationSchema: createRoleSchema,
children: ({ handleSubmit, values, handleChange, errors })=>/*#__PURE__*/ jsxs(Form, {
noValidate: true,
onSubmit: handleSubmit,
children: [
/*#__PURE__*/ jsx(Layouts.Header, {
primaryAction: !isLoadingPlugins && /*#__PURE__*/ jsx(Button, {
type: "submit",
loading: mutation.isLoading,
startIcon: /*#__PURE__*/ jsx(Check, {}),
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
}),
title: formatMessage({
id: 'Settings.roles.create.title',
defaultMessage: 'Create a role'
}),
subtitle: formatMessage({
id: 'Settings.roles.create.description',
defaultMessage: 'Define the rights given to the role'
})
}),
/*#__PURE__*/ jsx(Layouts.Content, {
children: /*#__PURE__*/ jsxs(Flex, {
background: "neutral0",
direction: "column",
alignItems: "stretch",
gap: 7,
hasRadius: true,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
shadow: "filterShadow",
children: [
/*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
children: [
/*#__PURE__*/ jsx(Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: getTrad('EditPage.form.roles'),
defaultMessage: 'Role details'
})
}),
/*#__PURE__*/ jsxs(Grid.Root, {
gap: 4,
children: [
/*#__PURE__*/ jsx(Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxs(Field.Root, {
name: "name",
error: errors?.name ? formatMessage({
id: errors.name,
defaultMessage: 'Name is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsx(Field.Label, {
children: formatMessage({
id: 'global.name',
defaultMessage: 'Name'
})
}),
/*#__PURE__*/ jsx(TextInput, {
value: values.name || '',
onChange: handleChange
}),
/*#__PURE__*/ jsx(Field.Error, {})
]
})
}),
/*#__PURE__*/ jsx(Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxs(Field.Root, {
name: "description",
error: errors?.description ? formatMessage({
id: errors.description,
defaultMessage: 'Description is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsx(Field.Label, {
children: formatMessage({
id: 'global.description',
defaultMessage: 'Description'
})
}),
/*#__PURE__*/ jsx(Textarea, {
value: values.description || '',
onChange: handleChange
}),
/*#__PURE__*/ jsx(Field.Error, {})
]
})
})
]
})
]
}),
!isLoadingPlugins && /*#__PURE__*/ jsx(UsersPermissions, {
ref: permissionsRef,
permissions: permissions,
routes: routes
})
]
})
})
]
})
})
]
});
};
const ProtectedRolesCreatePage = ()=>/*#__PURE__*/ jsx(Page.Protect, {
permissions: PERMISSIONS.createRole,
children: /*#__PURE__*/ jsx(CreatePage, {})
});
export { CreatePage, ProtectedRolesCreatePage };
//# sourceMappingURL=CreatePage.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,229 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var admin = require('@strapi/strapi/admin');
var formik = require('formik');
var reactIntl = require('react-intl');
var reactQuery = require('react-query');
var reactRouterDom = require('react-router-dom');
var index = require('../../../components/UsersPermissions/index.js');
var constants = require('../../../constants.js');
var getTrad = require('../../../utils/getTrad.js');
var constants$1 = require('../constants.js');
var usePlugins = require('../hooks/usePlugins.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const EditPage = ()=>{
const { formatMessage } = reactIntl.useIntl();
const { toggleNotification } = admin.useNotification();
const { params: { id } } = reactRouterDom.useMatch(`/settings/users-permissions/roles/:id`);
const { get } = admin.useFetchClient();
const { isLoading: isLoadingPlugins, routes } = usePlugins.usePlugins();
const { data: role, isLoading: isLoadingRole, refetch: refetchRole } = reactQuery.useQuery([
'users-permissions',
'role',
id
], async ()=>{
// TODO: why doesn't this endpoint follow the admin API conventions?
const { data: { role } } = await get(`/users-permissions/roles/${id}`);
return role;
});
const permissionsRef = React__namespace.useRef();
const { put } = admin.useFetchClient();
const { formatAPIError } = admin.useAPIErrorHandler();
const mutation = reactQuery.useMutation((body)=>put(`/users-permissions/roles/${id}`, body), {
onError (error) {
toggleNotification({
type: 'danger',
message: formatAPIError(error)
});
},
async onSuccess () {
toggleNotification({
type: 'success',
message: formatMessage({
id: getTrad('Settings.roles.created'),
defaultMessage: 'Role edited'
})
});
await refetchRole();
}
});
const handleEditRoleSubmit = async (data)=>{
const permissions = permissionsRef.current.getPermissions();
await mutation.mutate({
...data,
...permissions,
users: []
});
};
if (isLoadingRole) {
return /*#__PURE__*/ jsxRuntime.jsx(admin.Page.Loading, {});
}
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Main, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(admin.Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: 'Roles'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(formik.Formik, {
enableReinitialize: true,
initialValues: {
name: role.name,
description: role.description
},
onSubmit: handleEditRoleSubmit,
validationSchema: constants$1.createRoleSchema,
children: ({ handleSubmit, values, handleChange, errors })=>/*#__PURE__*/ jsxRuntime.jsxs(formik.Form, {
noValidate: true,
onSubmit: handleSubmit,
children: [
/*#__PURE__*/ jsxRuntime.jsx(admin.Layouts.Header, {
primaryAction: !isLoadingPlugins ? /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
disabled: role.code === 'strapi-super-admin',
type: "submit",
loading: mutation.isLoading,
startIcon: /*#__PURE__*/ jsxRuntime.jsx(icons.Check, {}),
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
}) : null,
title: role.name,
subtitle: role.description,
navigationAction: /*#__PURE__*/ jsxRuntime.jsx(admin.BackButton, {
fallback: ".."
})
}),
/*#__PURE__*/ jsxRuntime.jsx(admin.Layouts.Content, {
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
background: "neutral0",
direction: "column",
alignItems: "stretch",
gap: 7,
hasRadius: true,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
shadow: "filterShadow",
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: getTrad('EditPage.form.roles'),
defaultMessage: 'Role details'
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Root, {
gap: 4,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
name: "name",
error: errors?.name ? formatMessage({
id: errors.name,
defaultMessage: 'Name is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
children: formatMessage({
id: 'global.name',
defaultMessage: 'Name'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.TextInput, {
value: values.name || '',
onChange: handleChange
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {})
]
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
name: "description",
error: errors?.description ? formatMessage({
id: errors.description,
defaultMessage: 'Description is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
children: formatMessage({
id: 'global.description',
defaultMessage: 'Description'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Textarea, {
value: values.description || '',
onChange: handleChange
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {})
]
})
})
]
})
]
}),
!isLoadingPlugins && /*#__PURE__*/ jsxRuntime.jsx(index, {
ref: permissionsRef,
permissions: role.permissions,
routes: routes
})
]
})
})
]
})
})
]
});
};
const ProtectedRolesEditPage = ()=>/*#__PURE__*/ jsxRuntime.jsx(admin.Page.Protect, {
permissions: constants.PERMISSIONS.updateRole,
children: /*#__PURE__*/ jsxRuntime.jsx(EditPage, {})
});
exports.EditPage = EditPage;
exports.ProtectedRolesEditPage = ProtectedRolesEditPage;
//# sourceMappingURL=EditPage.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,207 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import * as React from 'react';
import { Main, Button, Flex, Typography, Grid, Field, TextInput, Textarea } from '@strapi/design-system';
import { Check } from '@strapi/icons';
import { Page, useNotification, useFetchClient, useAPIErrorHandler, Layouts, BackButton } from '@strapi/strapi/admin';
import { Formik, Form } from 'formik';
import { useIntl } from 'react-intl';
import { useQuery, useMutation } from 'react-query';
import { useMatch } from 'react-router-dom';
import UsersPermissions from '../../../components/UsersPermissions/index.mjs';
import { PERMISSIONS } from '../../../constants.mjs';
import getTrad from '../../../utils/getTrad.mjs';
import { createRoleSchema } from '../constants.mjs';
import { usePlugins } from '../hooks/usePlugins.mjs';
const EditPage = ()=>{
const { formatMessage } = useIntl();
const { toggleNotification } = useNotification();
const { params: { id } } = useMatch(`/settings/users-permissions/roles/:id`);
const { get } = useFetchClient();
const { isLoading: isLoadingPlugins, routes } = usePlugins();
const { data: role, isLoading: isLoadingRole, refetch: refetchRole } = useQuery([
'users-permissions',
'role',
id
], async ()=>{
// TODO: why doesn't this endpoint follow the admin API conventions?
const { data: { role } } = await get(`/users-permissions/roles/${id}`);
return role;
});
const permissionsRef = React.useRef();
const { put } = useFetchClient();
const { formatAPIError } = useAPIErrorHandler();
const mutation = useMutation((body)=>put(`/users-permissions/roles/${id}`, body), {
onError (error) {
toggleNotification({
type: 'danger',
message: formatAPIError(error)
});
},
async onSuccess () {
toggleNotification({
type: 'success',
message: formatMessage({
id: getTrad('Settings.roles.created'),
defaultMessage: 'Role edited'
})
});
await refetchRole();
}
});
const handleEditRoleSubmit = async (data)=>{
const permissions = permissionsRef.current.getPermissions();
await mutation.mutate({
...data,
...permissions,
users: []
});
};
if (isLoadingRole) {
return /*#__PURE__*/ jsx(Page.Loading, {});
}
return /*#__PURE__*/ jsxs(Main, {
children: [
/*#__PURE__*/ jsx(Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: 'Roles'
})
}),
/*#__PURE__*/ jsx(Formik, {
enableReinitialize: true,
initialValues: {
name: role.name,
description: role.description
},
onSubmit: handleEditRoleSubmit,
validationSchema: createRoleSchema,
children: ({ handleSubmit, values, handleChange, errors })=>/*#__PURE__*/ jsxs(Form, {
noValidate: true,
onSubmit: handleSubmit,
children: [
/*#__PURE__*/ jsx(Layouts.Header, {
primaryAction: !isLoadingPlugins ? /*#__PURE__*/ jsx(Button, {
disabled: role.code === 'strapi-super-admin',
type: "submit",
loading: mutation.isLoading,
startIcon: /*#__PURE__*/ jsx(Check, {}),
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
}) : null,
title: role.name,
subtitle: role.description,
navigationAction: /*#__PURE__*/ jsx(BackButton, {
fallback: ".."
})
}),
/*#__PURE__*/ jsx(Layouts.Content, {
children: /*#__PURE__*/ jsxs(Flex, {
background: "neutral0",
direction: "column",
alignItems: "stretch",
gap: 7,
hasRadius: true,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
shadow: "filterShadow",
children: [
/*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
/*#__PURE__*/ jsx(Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: getTrad('EditPage.form.roles'),
defaultMessage: 'Role details'
})
}),
/*#__PURE__*/ jsxs(Grid.Root, {
gap: 4,
children: [
/*#__PURE__*/ jsx(Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxs(Field.Root, {
name: "name",
error: errors?.name ? formatMessage({
id: errors.name,
defaultMessage: 'Name is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsx(Field.Label, {
children: formatMessage({
id: 'global.name',
defaultMessage: 'Name'
})
}),
/*#__PURE__*/ jsx(TextInput, {
value: values.name || '',
onChange: handleChange
}),
/*#__PURE__*/ jsx(Field.Error, {})
]
})
}),
/*#__PURE__*/ jsx(Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxs(Field.Root, {
name: "description",
error: errors?.description ? formatMessage({
id: errors.description,
defaultMessage: 'Description is required'
}) : false,
required: true,
children: [
/*#__PURE__*/ jsx(Field.Label, {
children: formatMessage({
id: 'global.description',
defaultMessage: 'Description'
})
}),
/*#__PURE__*/ jsx(Textarea, {
value: values.description || '',
onChange: handleChange
}),
/*#__PURE__*/ jsx(Field.Error, {})
]
})
})
]
})
]
}),
!isLoadingPlugins && /*#__PURE__*/ jsx(UsersPermissions, {
ref: permissionsRef,
permissions: role.permissions,
routes: routes
})
]
})
})
]
})
})
]
});
};
const ProtectedRolesEditPage = ()=>/*#__PURE__*/ jsx(Page.Protect, {
permissions: PERMISSIONS.updateRole,
children: /*#__PURE__*/ jsx(EditPage, {})
});
export { EditPage, ProtectedRolesEditPage };
//# sourceMappingURL=EditPage.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,125 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
var reactRouterDom = require('react-router-dom');
var styledComponents = require('styled-components');
const EditLink = styledComponents.styled(designSystem.Link)`
align-items: center;
height: 3.2rem;
width: 3.2rem;
display: flex;
justify-content: center;
padding: ${({ theme })=>`${theme.spaces[2]}`};
svg {
height: 1.6rem;
width: 1.6rem;
path {
fill: ${({ theme })=>theme.colors.neutral500};
}
}
&:hover,
&:focus {
svg {
path {
fill: ${({ theme })=>theme.colors.neutral800};
}
}
}
`;
const TableBody = ({ sortedRoles, canDelete, canUpdate, setRoleToDelete, onDelete })=>{
const { formatMessage } = reactIntl.useIntl();
const navigate = reactRouterDom.useNavigate();
const [showConfirmDelete, setShowConfirmDelete] = onDelete;
const checkCanDeleteRole = (role)=>canDelete && ![
'public',
'authenticated'
].includes(role.type);
const handleClickDelete = (id)=>{
setRoleToDelete(id);
setShowConfirmDelete(!showConfirmDelete);
};
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Tbody, {
children: sortedRoles?.map((role)=>/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tr, {
cursor: "pointer",
onClick: ()=>navigate(role.id.toString()),
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
width: "20%",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
children: role.name
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
width: "50%",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
children: role.description
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
width: "30%",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
children: formatMessage({
id: 'Roles.RoleRow.user-count',
defaultMessage: '{number, plural, =0 {# user} one {# user} other {# users}}'
}, {
number: role.nb_users
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
justifyContent: "end",
onClick: (e)=>e.stopPropagation(),
children: [
canUpdate ? /*#__PURE__*/ jsxRuntime.jsx(EditLink, {
tag: reactRouterDom.NavLink,
to: role.id.toString(),
"aria-label": formatMessage({
id: 'app.component.table.edit',
defaultMessage: 'Edit {target}'
}, {
target: `${role.name}`
}),
children: /*#__PURE__*/ jsxRuntime.jsx(icons.Pencil, {})
}) : null,
checkCanDeleteRole(role) && /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
onClick: ()=>handleClickDelete(role.id.toString()),
variant: "ghost",
label: formatMessage({
id: 'global.delete-target',
defaultMessage: 'Delete {target}'
}, {
target: `${role.name}`
}),
children: /*#__PURE__*/ jsxRuntime.jsx(icons.Trash, {})
})
]
})
})
]
}, role.name))
});
};
TableBody.defaultProps = {
canDelete: false,
canUpdate: false
};
TableBody.propTypes = {
onDelete: PropTypes.array.isRequired,
setRoleToDelete: PropTypes.func.isRequired,
sortedRoles: PropTypes.array.isRequired,
canDelete: PropTypes.bool,
canUpdate: PropTypes.bool
};
module.exports = TableBody;
//# sourceMappingURL=TableBody.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,123 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import 'react';
import { Link, Tbody, Tr, Td, Typography, Flex, IconButton } from '@strapi/design-system';
import { Pencil, Trash } from '@strapi/icons';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { useNavigate, NavLink } from 'react-router-dom';
import { styled } from 'styled-components';
const EditLink = styled(Link)`
align-items: center;
height: 3.2rem;
width: 3.2rem;
display: flex;
justify-content: center;
padding: ${({ theme })=>`${theme.spaces[2]}`};
svg {
height: 1.6rem;
width: 1.6rem;
path {
fill: ${({ theme })=>theme.colors.neutral500};
}
}
&:hover,
&:focus {
svg {
path {
fill: ${({ theme })=>theme.colors.neutral800};
}
}
}
`;
const TableBody = ({ sortedRoles, canDelete, canUpdate, setRoleToDelete, onDelete })=>{
const { formatMessage } = useIntl();
const navigate = useNavigate();
const [showConfirmDelete, setShowConfirmDelete] = onDelete;
const checkCanDeleteRole = (role)=>canDelete && ![
'public',
'authenticated'
].includes(role.type);
const handleClickDelete = (id)=>{
setRoleToDelete(id);
setShowConfirmDelete(!showConfirmDelete);
};
return /*#__PURE__*/ jsx(Tbody, {
children: sortedRoles?.map((role)=>/*#__PURE__*/ jsxs(Tr, {
cursor: "pointer",
onClick: ()=>navigate(role.id.toString()),
children: [
/*#__PURE__*/ jsx(Td, {
width: "20%",
children: /*#__PURE__*/ jsx(Typography, {
children: role.name
})
}),
/*#__PURE__*/ jsx(Td, {
width: "50%",
children: /*#__PURE__*/ jsx(Typography, {
children: role.description
})
}),
/*#__PURE__*/ jsx(Td, {
width: "30%",
children: /*#__PURE__*/ jsx(Typography, {
children: formatMessage({
id: 'Roles.RoleRow.user-count',
defaultMessage: '{number, plural, =0 {# user} one {# user} other {# users}}'
}, {
number: role.nb_users
})
})
}),
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsxs(Flex, {
justifyContent: "end",
onClick: (e)=>e.stopPropagation(),
children: [
canUpdate ? /*#__PURE__*/ jsx(EditLink, {
tag: NavLink,
to: role.id.toString(),
"aria-label": formatMessage({
id: 'app.component.table.edit',
defaultMessage: 'Edit {target}'
}, {
target: `${role.name}`
}),
children: /*#__PURE__*/ jsx(Pencil, {})
}) : null,
checkCanDeleteRole(role) && /*#__PURE__*/ jsx(IconButton, {
onClick: ()=>handleClickDelete(role.id.toString()),
variant: "ghost",
label: formatMessage({
id: 'global.delete-target',
defaultMessage: 'Delete {target}'
}, {
target: `${role.name}`
}),
children: /*#__PURE__*/ jsx(Trash, {})
})
]
})
})
]
}, role.name))
});
};
TableBody.defaultProps = {
canDelete: false,
canUpdate: false
};
TableBody.propTypes = {
onDelete: PropTypes.array.isRequired,
setRoleToDelete: PropTypes.func.isRequired,
sortedRoles: PropTypes.array.isRequired,
canDelete: PropTypes.bool,
canUpdate: PropTypes.bool
};
export { TableBody as default };
//# sourceMappingURL=TableBody.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,237 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var admin = require('@strapi/strapi/admin');
var reactIntl = require('react-intl');
var reactQuery = require('react-query');
var reactRouterDom = require('react-router-dom');
var constants = require('../../../../constants.js');
require('lodash/isEmpty');
var getTrad = require('../../../../utils/getTrad.js');
var TableBody = require('./components/TableBody.js');
const RolesListPage = ()=>{
const { trackUsage } = admin.useTracking();
const { formatMessage, locale } = reactIntl.useIntl();
const { toggleNotification } = admin.useNotification();
const { notifyStatus } = designSystem.useNotifyAT();
const [{ query }] = admin.useQueryParams();
const _q = query?._q || '';
const [showConfirmDelete, setShowConfirmDelete] = React.useState(false);
const [roleToDelete, setRoleToDelete] = React.useState();
const { del, get } = admin.useFetchClient();
const { isLoading: isLoadingForPermissions, allowedActions: { canRead, canDelete, canCreate, canUpdate } } = admin.useRBAC({
create: constants.PERMISSIONS.createRole,
read: constants.PERMISSIONS.readRoles,
update: constants.PERMISSIONS.updateRole,
delete: constants.PERMISSIONS.deleteRole
});
const { isLoading: isLoadingForData, data: { roles }, isFetching, refetch } = reactQuery.useQuery('get-roles', ()=>fetchData(toggleNotification, formatMessage, notifyStatus), {
initialData: {},
enabled: canRead
});
const { contains } = designSystem.useFilter(locale, {
sensitivity: 'base'
});
/**
* @type {Intl.Collator}
*/ const formatter = designSystem.useCollator(locale, {
sensitivity: 'base'
});
const isLoading = isLoadingForData || isFetching || isLoadingForPermissions;
const handleShowConfirmDelete = ()=>{
setShowConfirmDelete(!showConfirmDelete);
};
const deleteData = async (id, formatMessage, toggleNotification)=>{
try {
await del(`/users-permissions/roles/${id}`);
} catch (error) {
toggleNotification({
type: 'danger',
message: formatMessage({
id: 'notification.error',
defaultMessage: 'An error occured'
})
});
}
};
const fetchData = async (toggleNotification, formatMessage, notifyStatus)=>{
try {
const { data } = await get('/users-permissions/roles');
notifyStatus('The roles have loaded successfully');
return data;
} catch (err) {
toggleNotification({
type: 'danger',
message: formatMessage({
id: 'notification.error',
defaultMessage: 'An error occurred'
})
});
throw new Error(err);
}
};
const emptyLayout = {
roles: {
id: getTrad('Roles.empty'),
defaultMessage: "You don't have any roles yet."
},
search: {
id: getTrad('Roles.empty.search'),
defaultMessage: 'No roles match the search.'
}
};
const pageTitle = formatMessage({
id: 'global.roles',
defaultMessage: 'Roles'
});
const deleteMutation = reactQuery.useMutation((id)=>deleteData(id, formatMessage, toggleNotification), {
async onSuccess () {
await refetch();
}
});
const handleConfirmDelete = async ()=>{
await deleteMutation.mutateAsync(roleToDelete);
setShowConfirmDelete(!showConfirmDelete);
};
const sortedRoles = (roles || []).filter((role)=>contains(role.name, _q) || contains(role.description, _q)).sort((a, b)=>formatter.compare(a.name, b.name) || formatter.compare(a.description, b.description));
const emptyContent = _q && !sortedRoles.length ? 'search' : 'roles';
const colCount = 4;
const rowCount = (roles?.length || 0) + 1;
if (isLoading) {
return /*#__PURE__*/ jsxRuntime.jsx(admin.Page.Loading, {});
}
return /*#__PURE__*/ jsxRuntime.jsxs(admin.Layouts.Root, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(admin.Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: pageTitle
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(admin.Page.Main, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(admin.Layouts.Header, {
title: formatMessage({
id: 'global.roles',
defaultMessage: 'Roles'
}),
subtitle: formatMessage({
id: 'Settings.roles.list.description',
defaultMessage: 'List of roles'
}),
primaryAction: canCreate ? /*#__PURE__*/ jsxRuntime.jsx(designSystem.LinkButton, {
to: "new",
tag: reactRouterDom.NavLink,
onClick: ()=>trackUsage('willCreateRole'),
startIcon: /*#__PURE__*/ jsxRuntime.jsx(icons.Plus, {}),
size: "S",
children: formatMessage({
id: getTrad('List.button.roles'),
defaultMessage: 'Add new role'
})
}) : null
}),
/*#__PURE__*/ jsxRuntime.jsx(admin.Layouts.Action, {
startActions: /*#__PURE__*/ jsxRuntime.jsx(admin.SearchInput, {
label: formatMessage({
id: 'app.component.search.label',
defaultMessage: 'Search'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(admin.Layouts.Content, {
children: [
!canRead && /*#__PURE__*/ jsxRuntime.jsx(admin.Page.NoPermissions, {}),
canRead && sortedRoles && sortedRoles?.length ? /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Table, {
colCount: colCount,
rowCount: rowCount,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Thead, {
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tr, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Th, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: 'global.name',
defaultMessage: 'Name'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Th, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: 'global.description',
defaultMessage: 'Description'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Th, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: 'global.users',
defaultMessage: 'Users'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Th, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: formatMessage({
id: 'global.actions',
defaultMessage: 'Actions'
})
})
})
]
})
}),
/*#__PURE__*/ jsxRuntime.jsx(TableBody, {
sortedRoles: sortedRoles,
canDelete: canDelete,
canUpdate: canUpdate,
permissions: constants.PERMISSIONS,
setRoleToDelete: setRoleToDelete,
onDelete: [
showConfirmDelete,
setShowConfirmDelete
]
})
]
}) : /*#__PURE__*/ jsxRuntime.jsx(designSystem.EmptyStateLayout, {
content: formatMessage(emptyLayout[emptyContent])
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Dialog.Root, {
open: showConfirmDelete,
onOpenChange: handleShowConfirmDelete,
children: /*#__PURE__*/ jsxRuntime.jsx(admin.ConfirmDialog, {
onConfirm: handleConfirmDelete
})
})
]
})
]
});
};
const ProtectedRolesListPage = ()=>{
return /*#__PURE__*/ jsxRuntime.jsx(admin.Page.Protect, {
permissions: constants.PERMISSIONS.accessRoles,
children: /*#__PURE__*/ jsxRuntime.jsx(RolesListPage, {})
});
};
exports.ProtectedRolesListPage = ProtectedRolesListPage;
exports.RolesListPage = RolesListPage;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,234 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import { useState } from 'react';
import { useNotifyAT, useFilter, useCollator, LinkButton, Table, Thead, Tr, Th, Typography, VisuallyHidden, EmptyStateLayout, Dialog } from '@strapi/design-system';
import { Plus } from '@strapi/icons';
import { Page, useTracking, useNotification, useQueryParams, useFetchClient, useRBAC, Layouts, SearchInput, ConfirmDialog } from '@strapi/strapi/admin';
import { useIntl } from 'react-intl';
import { useQuery, useMutation } from 'react-query';
import { NavLink } from 'react-router-dom';
import { PERMISSIONS } from '../../../../constants.mjs';
import 'lodash/isEmpty';
import getTrad from '../../../../utils/getTrad.mjs';
import TableBody from './components/TableBody.mjs';
const RolesListPage = ()=>{
const { trackUsage } = useTracking();
const { formatMessage, locale } = useIntl();
const { toggleNotification } = useNotification();
const { notifyStatus } = useNotifyAT();
const [{ query }] = useQueryParams();
const _q = query?._q || '';
const [showConfirmDelete, setShowConfirmDelete] = useState(false);
const [roleToDelete, setRoleToDelete] = useState();
const { del, get } = useFetchClient();
const { isLoading: isLoadingForPermissions, allowedActions: { canRead, canDelete, canCreate, canUpdate } } = useRBAC({
create: PERMISSIONS.createRole,
read: PERMISSIONS.readRoles,
update: PERMISSIONS.updateRole,
delete: PERMISSIONS.deleteRole
});
const { isLoading: isLoadingForData, data: { roles }, isFetching, refetch } = useQuery('get-roles', ()=>fetchData(toggleNotification, formatMessage, notifyStatus), {
initialData: {},
enabled: canRead
});
const { contains } = useFilter(locale, {
sensitivity: 'base'
});
/**
* @type {Intl.Collator}
*/ const formatter = useCollator(locale, {
sensitivity: 'base'
});
const isLoading = isLoadingForData || isFetching || isLoadingForPermissions;
const handleShowConfirmDelete = ()=>{
setShowConfirmDelete(!showConfirmDelete);
};
const deleteData = async (id, formatMessage, toggleNotification)=>{
try {
await del(`/users-permissions/roles/${id}`);
} catch (error) {
toggleNotification({
type: 'danger',
message: formatMessage({
id: 'notification.error',
defaultMessage: 'An error occured'
})
});
}
};
const fetchData = async (toggleNotification, formatMessage, notifyStatus)=>{
try {
const { data } = await get('/users-permissions/roles');
notifyStatus('The roles have loaded successfully');
return data;
} catch (err) {
toggleNotification({
type: 'danger',
message: formatMessage({
id: 'notification.error',
defaultMessage: 'An error occurred'
})
});
throw new Error(err);
}
};
const emptyLayout = {
roles: {
id: getTrad('Roles.empty'),
defaultMessage: "You don't have any roles yet."
},
search: {
id: getTrad('Roles.empty.search'),
defaultMessage: 'No roles match the search.'
}
};
const pageTitle = formatMessage({
id: 'global.roles',
defaultMessage: 'Roles'
});
const deleteMutation = useMutation((id)=>deleteData(id, formatMessage, toggleNotification), {
async onSuccess () {
await refetch();
}
});
const handleConfirmDelete = async ()=>{
await deleteMutation.mutateAsync(roleToDelete);
setShowConfirmDelete(!showConfirmDelete);
};
const sortedRoles = (roles || []).filter((role)=>contains(role.name, _q) || contains(role.description, _q)).sort((a, b)=>formatter.compare(a.name, b.name) || formatter.compare(a.description, b.description));
const emptyContent = _q && !sortedRoles.length ? 'search' : 'roles';
const colCount = 4;
const rowCount = (roles?.length || 0) + 1;
if (isLoading) {
return /*#__PURE__*/ jsx(Page.Loading, {});
}
return /*#__PURE__*/ jsxs(Layouts.Root, {
children: [
/*#__PURE__*/ jsx(Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: pageTitle
})
}),
/*#__PURE__*/ jsxs(Page.Main, {
children: [
/*#__PURE__*/ jsx(Layouts.Header, {
title: formatMessage({
id: 'global.roles',
defaultMessage: 'Roles'
}),
subtitle: formatMessage({
id: 'Settings.roles.list.description',
defaultMessage: 'List of roles'
}),
primaryAction: canCreate ? /*#__PURE__*/ jsx(LinkButton, {
to: "new",
tag: NavLink,
onClick: ()=>trackUsage('willCreateRole'),
startIcon: /*#__PURE__*/ jsx(Plus, {}),
size: "S",
children: formatMessage({
id: getTrad('List.button.roles'),
defaultMessage: 'Add new role'
})
}) : null
}),
/*#__PURE__*/ jsx(Layouts.Action, {
startActions: /*#__PURE__*/ jsx(SearchInput, {
label: formatMessage({
id: 'app.component.search.label',
defaultMessage: 'Search'
})
})
}),
/*#__PURE__*/ jsxs(Layouts.Content, {
children: [
!canRead && /*#__PURE__*/ jsx(Page.NoPermissions, {}),
canRead && sortedRoles && sortedRoles?.length ? /*#__PURE__*/ jsxs(Table, {
colCount: colCount,
rowCount: rowCount,
children: [
/*#__PURE__*/ jsx(Thead, {
children: /*#__PURE__*/ jsxs(Tr, {
children: [
/*#__PURE__*/ jsx(Th, {
children: /*#__PURE__*/ jsx(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: 'global.name',
defaultMessage: 'Name'
})
})
}),
/*#__PURE__*/ jsx(Th, {
children: /*#__PURE__*/ jsx(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: 'global.description',
defaultMessage: 'Description'
})
})
}),
/*#__PURE__*/ jsx(Th, {
children: /*#__PURE__*/ jsx(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: 'global.users',
defaultMessage: 'Users'
})
})
}),
/*#__PURE__*/ jsx(Th, {
children: /*#__PURE__*/ jsx(VisuallyHidden, {
children: formatMessage({
id: 'global.actions',
defaultMessage: 'Actions'
})
})
})
]
})
}),
/*#__PURE__*/ jsx(TableBody, {
sortedRoles: sortedRoles,
canDelete: canDelete,
canUpdate: canUpdate,
permissions: PERMISSIONS,
setRoleToDelete: setRoleToDelete,
onDelete: [
showConfirmDelete,
setShowConfirmDelete
]
})
]
}) : /*#__PURE__*/ jsx(EmptyStateLayout, {
content: formatMessage(emptyLayout[emptyContent])
})
]
}),
/*#__PURE__*/ jsx(Dialog.Root, {
open: showConfirmDelete,
onOpenChange: handleShowConfirmDelete,
children: /*#__PURE__*/ jsx(ConfirmDialog, {
onConfirm: handleConfirmDelete
})
})
]
})
]
});
};
const ProtectedRolesListPage = ()=>{
return /*#__PURE__*/ jsx(Page.Protect, {
permissions: PERMISSIONS.accessRoles,
children: /*#__PURE__*/ jsx(RolesListPage, {})
});
};
export { ProtectedRolesListPage, RolesListPage };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long