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,49 @@
'use strict';
const getMethodColor = (verb)=>{
switch(verb){
case 'POST':
{
return {
text: 'success600',
border: 'success200',
background: 'success100'
};
}
case 'GET':
{
return {
text: 'secondary600',
border: 'secondary200',
background: 'secondary100'
};
}
case 'PUT':
{
return {
text: 'warning600',
border: 'warning200',
background: 'warning100'
};
}
case 'DELETE':
{
return {
text: 'danger600',
border: 'danger200',
background: 'danger100'
};
}
default:
{
return {
text: 'neutral600',
border: 'neutral200',
background: 'neutral100'
};
}
}
};
module.exports = getMethodColor;
//# sourceMappingURL=getMethodColor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getMethodColor.js","sources":["../../../../admin/src/components/BoundRoute/getMethodColor.js"],"sourcesContent":["const getMethodColor = (verb) => {\n switch (verb) {\n case 'POST': {\n return {\n text: 'success600',\n border: 'success200',\n background: 'success100',\n };\n }\n case 'GET': {\n return {\n text: 'secondary600',\n border: 'secondary200',\n background: 'secondary100',\n };\n }\n case 'PUT': {\n return {\n text: 'warning600',\n border: 'warning200',\n background: 'warning100',\n };\n }\n case 'DELETE': {\n return {\n text: 'danger600',\n border: 'danger200',\n background: 'danger100',\n };\n }\n default: {\n return {\n text: 'neutral600',\n border: 'neutral200',\n background: 'neutral100',\n };\n }\n }\n};\n\nexport default getMethodColor;\n"],"names":["getMethodColor","verb","text","border","background"],"mappings":";;AAAA,MAAMA,iBAAiB,CAACC,IAAAA,GAAAA;IACtB,OAAQA,IAAAA;QACN,KAAK,MAAA;AAAQ,YAAA;gBACX,OAAO;oBACLC,IAAM,EAAA,YAAA;oBACNC,MAAQ,EAAA,YAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;QACA,KAAK,KAAA;AAAO,YAAA;gBACV,OAAO;oBACLF,IAAM,EAAA,cAAA;oBACNC,MAAQ,EAAA,cAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;QACA,KAAK,KAAA;AAAO,YAAA;gBACV,OAAO;oBACLF,IAAM,EAAA,YAAA;oBACNC,MAAQ,EAAA,YAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;QACA,KAAK,QAAA;AAAU,YAAA;gBACb,OAAO;oBACLF,IAAM,EAAA,WAAA;oBACNC,MAAQ,EAAA,WAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;AACA,QAAA;AAAS,YAAA;gBACP,OAAO;oBACLF,IAAM,EAAA,YAAA;oBACNC,MAAQ,EAAA,YAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;AACF;AACF;;;;"}

View File

@@ -0,0 +1,47 @@
const getMethodColor = (verb)=>{
switch(verb){
case 'POST':
{
return {
text: 'success600',
border: 'success200',
background: 'success100'
};
}
case 'GET':
{
return {
text: 'secondary600',
border: 'secondary200',
background: 'secondary100'
};
}
case 'PUT':
{
return {
text: 'warning600',
border: 'warning200',
background: 'warning100'
};
}
case 'DELETE':
{
return {
text: 'danger600',
border: 'danger200',
background: 'danger100'
};
}
default:
{
return {
text: 'neutral600',
border: 'neutral200',
background: 'neutral100'
};
}
}
};
export { getMethodColor as default };
//# sourceMappingURL=getMethodColor.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"getMethodColor.mjs","sources":["../../../../admin/src/components/BoundRoute/getMethodColor.js"],"sourcesContent":["const getMethodColor = (verb) => {\n switch (verb) {\n case 'POST': {\n return {\n text: 'success600',\n border: 'success200',\n background: 'success100',\n };\n }\n case 'GET': {\n return {\n text: 'secondary600',\n border: 'secondary200',\n background: 'secondary100',\n };\n }\n case 'PUT': {\n return {\n text: 'warning600',\n border: 'warning200',\n background: 'warning100',\n };\n }\n case 'DELETE': {\n return {\n text: 'danger600',\n border: 'danger200',\n background: 'danger100',\n };\n }\n default: {\n return {\n text: 'neutral600',\n border: 'neutral200',\n background: 'neutral100',\n };\n }\n }\n};\n\nexport default getMethodColor;\n"],"names":["getMethodColor","verb","text","border","background"],"mappings":"AAAA,MAAMA,iBAAiB,CAACC,IAAAA,GAAAA;IACtB,OAAQA,IAAAA;QACN,KAAK,MAAA;AAAQ,YAAA;gBACX,OAAO;oBACLC,IAAM,EAAA,YAAA;oBACNC,MAAQ,EAAA,YAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;QACA,KAAK,KAAA;AAAO,YAAA;gBACV,OAAO;oBACLF,IAAM,EAAA,cAAA;oBACNC,MAAQ,EAAA,cAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;QACA,KAAK,KAAA;AAAO,YAAA;gBACV,OAAO;oBACLF,IAAM,EAAA,YAAA;oBACNC,MAAQ,EAAA,YAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;QACA,KAAK,QAAA;AAAU,YAAA;gBACb,OAAO;oBACLF,IAAM,EAAA,WAAA;oBACNC,MAAQ,EAAA,WAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;AACA,QAAA;AAAS,YAAA;gBACP,OAAO;oBACLF,IAAM,EAAA,YAAA;oBACNC,MAAQ,EAAA,YAAA;oBACRC,UAAY,EAAA;AACd,iBAAA;AACF;AACF;AACF;;;;"}

View File

@@ -0,0 +1,98 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var map = require('lodash/map');
var tail = require('lodash/tail');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
var styledComponents = require('styled-components');
var getMethodColor = require('./getMethodColor.js');
const MethodBox = styledComponents.styled(designSystem.Box)`
margin: -1px;
border-radius: ${({ theme })=>theme.spaces[1]} 0 0 ${({ theme })=>theme.spaces[1]};
`;
function BoundRoute({ route }) {
const { formatMessage } = reactIntl.useIntl();
const { method, handler: title, path } = route;
const formattedRoute = path ? tail(path.split('/')) : [];
const [controller = '', action = ''] = title ? title.split('.') : [];
const colors = getMethodColor(route.method);
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Typography, {
variant: "delta",
tag: "h3",
children: [
formatMessage({
id: 'users-permissions.BoundRoute.title',
defaultMessage: 'Bound route to'
}),
" ",
/*#__PURE__*/ jsxRuntime.jsx("span", {
children: controller
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Typography, {
variant: "delta",
textColor: "primary600",
children: [
".",
action
]
})
]
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
hasRadius: true,
background: "neutral0",
borderColor: "neutral200",
gap: 0,
children: [
/*#__PURE__*/ jsxRuntime.jsx(MethodBox, {
background: colors.background,
borderColor: colors.border,
padding: 2,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
fontWeight: "bold",
textColor: colors.text,
children: method
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingLeft: 2,
paddingRight: 2,
children: map(formattedRoute, (value)=>/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Typography, {
textColor: value.includes(':') ? 'neutral600' : 'neutral900',
children: [
"/",
value
]
}, value))
})
]
})
]
});
}
BoundRoute.defaultProps = {
route: {
handler: 'Nocontroller.error',
method: 'GET',
path: '/there-is-no-path'
}
};
BoundRoute.propTypes = {
route: PropTypes.shape({
handler: PropTypes.string,
method: PropTypes.string,
path: PropTypes.string
})
};
module.exports = BoundRoute;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../admin/src/components/BoundRoute/index.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Flex, Typography } from '@strapi/design-system';\nimport map from 'lodash/map';\nimport tail from 'lodash/tail';\nimport PropTypes from 'prop-types';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport getMethodColor from './getMethodColor';\n\nconst MethodBox = styled(Box)`\n margin: -1px;\n border-radius: ${({ theme }) => theme.spaces[1]} 0 0 ${({ theme }) => theme.spaces[1]};\n`;\n\nfunction BoundRoute({ route }) {\n const { formatMessage } = useIntl();\n\n const { method, handler: title, path } = route;\n const formattedRoute = path ? tail(path.split('/')) : [];\n const [controller = '', action = ''] = title ? title.split('.') : [];\n const colors = getMethodColor(route.method);\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n <Typography variant=\"delta\" tag=\"h3\">\n {formatMessage({\n id: 'users-permissions.BoundRoute.title',\n defaultMessage: 'Bound route to',\n })}\n &nbsp;\n <span>{controller}</span>\n <Typography variant=\"delta\" textColor=\"primary600\">\n .{action}\n </Typography>\n </Typography>\n <Flex hasRadius background=\"neutral0\" borderColor=\"neutral200\" gap={0}>\n <MethodBox background={colors.background} borderColor={colors.border} padding={2}>\n <Typography fontWeight=\"bold\" textColor={colors.text}>\n {method}\n </Typography>\n </MethodBox>\n <Box paddingLeft={2} paddingRight={2}>\n {map(formattedRoute, (value) => (\n <Typography key={value} textColor={value.includes(':') ? 'neutral600' : 'neutral900'}>\n /{value}\n </Typography>\n ))}\n </Box>\n </Flex>\n </Flex>\n );\n}\n\nBoundRoute.defaultProps = {\n route: {\n handler: 'Nocontroller.error',\n method: 'GET',\n path: '/there-is-no-path',\n },\n};\n\nBoundRoute.propTypes = {\n route: PropTypes.shape({\n handler: PropTypes.string,\n method: PropTypes.string,\n path: PropTypes.string,\n }),\n};\n\nexport default BoundRoute;\n"],"names":["MethodBox","styled","Box","theme","spaces","BoundRoute","route","formatMessage","useIntl","method","handler","title","path","formattedRoute","tail","split","controller","action","colors","getMethodColor","_jsxs","Flex","direction","alignItems","gap","Typography","variant","tag","id","defaultMessage","_jsx","span","textColor","hasRadius","background","borderColor","border","padding","fontWeight","text","paddingLeft","paddingRight","map","value","includes","defaultProps","propTypes","PropTypes","shape","string"],"mappings":";;;;;;;;;;;;AAWA,MAAMA,SAAAA,GAAYC,uBAAOC,CAAAA,gBAAAA,CAAI;;iBAEZ,EAAE,CAAC,EAAEC,KAAK,EAA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/design-system';
import map from 'lodash/map';
import tail from 'lodash/tail';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { styled } from 'styled-components';
import getMethodColor from './getMethodColor.mjs';
const MethodBox = styled(Box)`
margin: -1px;
border-radius: ${({ theme })=>theme.spaces[1]} 0 0 ${({ theme })=>theme.spaces[1]};
`;
function BoundRoute({ route }) {
const { formatMessage } = useIntl();
const { method, handler: title, path } = route;
const formattedRoute = path ? tail(path.split('/')) : [];
const [controller = '', action = ''] = title ? title.split('.') : [];
const colors = getMethodColor(route.method);
return /*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
/*#__PURE__*/ jsxs(Typography, {
variant: "delta",
tag: "h3",
children: [
formatMessage({
id: 'users-permissions.BoundRoute.title',
defaultMessage: 'Bound route to'
}),
" ",
/*#__PURE__*/ jsx("span", {
children: controller
}),
/*#__PURE__*/ jsxs(Typography, {
variant: "delta",
textColor: "primary600",
children: [
".",
action
]
})
]
}),
/*#__PURE__*/ jsxs(Flex, {
hasRadius: true,
background: "neutral0",
borderColor: "neutral200",
gap: 0,
children: [
/*#__PURE__*/ jsx(MethodBox, {
background: colors.background,
borderColor: colors.border,
padding: 2,
children: /*#__PURE__*/ jsx(Typography, {
fontWeight: "bold",
textColor: colors.text,
children: method
})
}),
/*#__PURE__*/ jsx(Box, {
paddingLeft: 2,
paddingRight: 2,
children: map(formattedRoute, (value)=>/*#__PURE__*/ jsxs(Typography, {
textColor: value.includes(':') ? 'neutral600' : 'neutral900',
children: [
"/",
value
]
}, value))
})
]
})
]
});
}
BoundRoute.defaultProps = {
route: {
handler: 'Nocontroller.error',
method: 'GET',
path: '/there-is-no-path'
}
};
BoundRoute.propTypes = {
route: PropTypes.shape({
handler: PropTypes.string,
method: PropTypes.string,
path: PropTypes.string
})
};
export { BoundRoute as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../admin/src/components/BoundRoute/index.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, Flex, Typography } from '@strapi/design-system';\nimport map from 'lodash/map';\nimport tail from 'lodash/tail';\nimport PropTypes from 'prop-types';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport getMethodColor from './getMethodColor';\n\nconst MethodBox = styled(Box)`\n margin: -1px;\n border-radius: ${({ theme }) => theme.spaces[1]} 0 0 ${({ theme }) => theme.spaces[1]};\n`;\n\nfunction BoundRoute({ route }) {\n const { formatMessage } = useIntl();\n\n const { method, handler: title, path } = route;\n const formattedRoute = path ? tail(path.split('/')) : [];\n const [controller = '', action = ''] = title ? title.split('.') : [];\n const colors = getMethodColor(route.method);\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n <Typography variant=\"delta\" tag=\"h3\">\n {formatMessage({\n id: 'users-permissions.BoundRoute.title',\n defaultMessage: 'Bound route to',\n })}\n &nbsp;\n <span>{controller}</span>\n <Typography variant=\"delta\" textColor=\"primary600\">\n .{action}\n </Typography>\n </Typography>\n <Flex hasRadius background=\"neutral0\" borderColor=\"neutral200\" gap={0}>\n <MethodBox background={colors.background} borderColor={colors.border} padding={2}>\n <Typography fontWeight=\"bold\" textColor={colors.text}>\n {method}\n </Typography>\n </MethodBox>\n <Box paddingLeft={2} paddingRight={2}>\n {map(formattedRoute, (value) => (\n <Typography key={value} textColor={value.includes(':') ? 'neutral600' : 'neutral900'}>\n /{value}\n </Typography>\n ))}\n </Box>\n </Flex>\n </Flex>\n );\n}\n\nBoundRoute.defaultProps = {\n route: {\n handler: 'Nocontroller.error',\n method: 'GET',\n path: '/there-is-no-path',\n },\n};\n\nBoundRoute.propTypes = {\n route: PropTypes.shape({\n handler: PropTypes.string,\n method: PropTypes.string,\n path: PropTypes.string,\n }),\n};\n\nexport default BoundRoute;\n"],"names":["MethodBox","styled","Box","theme","spaces","BoundRoute","route","formatMessage","useIntl","method","handler","title","path","formattedRoute","tail","split","controller","action","colors","getMethodColor","_jsxs","Flex","direction","alignItems","gap","Typography","variant","tag","id","defaultMessage","_jsx","span","textColor","hasRadius","background","borderColor","border","padding","fontWeight","text","paddingLeft","paddingRight","map","value","includes","defaultProps","propTypes","PropTypes","shape","string"],"mappings":";;;;;;;;;;AAWA,MAAMA,SAAAA,GAAYC,MAAOC,CAAAA,GAAAA,CAAI;;iBAEZ,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAE,CAAA,CAAC,KAAK,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC,CAAA,CAAE,CAAC;AACxF,CAAC;AAED,SAASC,UAAAA,CAAW,EAAEC,KAAK,EAAE,EAAA;IAC3B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAE1B,MAAM,EAAEC,MAAM,EAAEC,OAAAA,EAASC,KAAK,EAAEC,IAAI,EAAE,GAAGN,KAAAA;AACzC,IAAA,MAAMO,iBAAiBD,IAAOE,GAAAA,IAAAA,CAAKF,KAAKG,KAAK,CAAC,QAAQ,EAAE;AACxD,IAAA,MAAM,CAACC,UAAAA,GAAa,EAAE,EAAEC,MAAS,GAAA,EAAE,CAAC,GAAGN,KAAQA,GAAAA,KAAAA,CAAMI,KAAK,CAAC,OAAO,EAAE;IACpE,MAAMG,MAAAA,GAASC,cAAeb,CAAAA,KAAAA,CAAMG,MAAM,CAAA;AAE1C,IAAA,qBACEW,IAACC,CAAAA,IAAAA,EAAAA;QAAKC,SAAU,EAAA,QAAA;QAASC,UAAW,EAAA,SAAA;QAAUC,GAAK,EAAA,CAAA;;0BACjDJ,IAACK,CAAAA,UAAAA,EAAAA;gBAAWC,OAAQ,EAAA,OAAA;gBAAQC,GAAI,EAAA,IAAA;;oBAC7BpB,aAAc,CAAA;wBACbqB,EAAI,EAAA,oCAAA;wBACJC,cAAgB,EAAA;AAClB,qBAAA,CAAA;AAAG,oBAAA,GAAA;kCAEHC,GAACC,C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AAC;AACrBtC,QAAAA,OAAAA,EAASqC,UAAUE,MAAM;AACzBxC,QAAAA,MAAAA,EAAQsC,UAAUE,MAAM;AACxBrC,QAAAA,IAAAA,EAAMmC,UAAUE;AAClB,KAAA;AACF,CAAA;;;;"}

View File

@@ -0,0 +1,123 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
const Input = ({ description, disabled, intlLabel, error, name, onChange, placeholder, providerToEditName, type, value })=>{
const { formatMessage } = reactIntl.useIntl();
const inputValue = name === 'noName' ? `${window.strapi.backendURL}/api/connect/${providerToEditName}/callback` : value;
const label = formatMessage({
id: intlLabel.id,
defaultMessage: intlLabel.defaultMessage
}, {
provider: providerToEditName,
...intlLabel.values
});
const hint = description ? formatMessage({
id: description.id,
defaultMessage: description.defaultMessage
}, {
provider: providerToEditName,
...description.values
}) : '';
if (type === 'bool') {
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
hint: hint,
name: name,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
children: label
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Toggle, {
"aria-label": name,
checked: value,
disabled: disabled,
offLabel: formatMessage({
id: 'app.components.ToggleCheckbox.off-label',
defaultMessage: 'Off'
}),
onLabel: formatMessage({
id: 'app.components.ToggleCheckbox.on-label',
defaultMessage: 'On'
}),
onChange: (e)=>{
onChange({
target: {
name,
value: e.target.checked
}
});
}
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Hint, {})
]
});
}
const formattedPlaceholder = placeholder ? formatMessage({
id: placeholder.id,
defaultMessage: placeholder.defaultMessage
}, {
...placeholder.values
}) : '';
const errorMessage = error ? formatMessage({
id: error,
defaultMessage: error
}) : '';
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
error: errorMessage,
name: name,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
children: label
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.TextInput, {
disabled: disabled,
onChange: onChange,
placeholder: formattedPlaceholder,
type: type,
value: inputValue
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {})
]
});
};
Input.defaultProps = {
description: null,
disabled: false,
error: '',
placeholder: null,
value: ''
};
Input.propTypes = {
description: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,
values: PropTypes.object
}),
disabled: PropTypes.bool,
error: PropTypes.string,
intlLabel: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,
values: PropTypes.object
}).isRequired,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
placeholder: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,
values: PropTypes.object
}),
providerToEditName: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
value: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string
])
};
module.exports = Input;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,121 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import 'react';
import { Field, Toggle, TextInput } from '@strapi/design-system';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
const Input = ({ description, disabled, intlLabel, error, name, onChange, placeholder, providerToEditName, type, value })=>{
const { formatMessage } = useIntl();
const inputValue = name === 'noName' ? `${window.strapi.backendURL}/api/connect/${providerToEditName}/callback` : value;
const label = formatMessage({
id: intlLabel.id,
defaultMessage: intlLabel.defaultMessage
}, {
provider: providerToEditName,
...intlLabel.values
});
const hint = description ? formatMessage({
id: description.id,
defaultMessage: description.defaultMessage
}, {
provider: providerToEditName,
...description.values
}) : '';
if (type === 'bool') {
return /*#__PURE__*/ jsxs(Field.Root, {
hint: hint,
name: name,
children: [
/*#__PURE__*/ jsx(Field.Label, {
children: label
}),
/*#__PURE__*/ jsx(Toggle, {
"aria-label": name,
checked: value,
disabled: disabled,
offLabel: formatMessage({
id: 'app.components.ToggleCheckbox.off-label',
defaultMessage: 'Off'
}),
onLabel: formatMessage({
id: 'app.components.ToggleCheckbox.on-label',
defaultMessage: 'On'
}),
onChange: (e)=>{
onChange({
target: {
name,
value: e.target.checked
}
});
}
}),
/*#__PURE__*/ jsx(Field.Hint, {})
]
});
}
const formattedPlaceholder = placeholder ? formatMessage({
id: placeholder.id,
defaultMessage: placeholder.defaultMessage
}, {
...placeholder.values
}) : '';
const errorMessage = error ? formatMessage({
id: error,
defaultMessage: error
}) : '';
return /*#__PURE__*/ jsxs(Field.Root, {
error: errorMessage,
name: name,
children: [
/*#__PURE__*/ jsx(Field.Label, {
children: label
}),
/*#__PURE__*/ jsx(TextInput, {
disabled: disabled,
onChange: onChange,
placeholder: formattedPlaceholder,
type: type,
value: inputValue
}),
/*#__PURE__*/ jsx(Field.Error, {})
]
});
};
Input.defaultProps = {
description: null,
disabled: false,
error: '',
placeholder: null,
value: ''
};
Input.propTypes = {
description: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,
values: PropTypes.object
}),
disabled: PropTypes.bool,
error: PropTypes.string,
intlLabel: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,
values: PropTypes.object
}).isRequired,
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
placeholder: PropTypes.shape({
id: PropTypes.string.isRequired,
defaultMessage: PropTypes.string.isRequired,
values: PropTypes.object
}),
providerToEditName: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
value: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.string
])
};
export { Input as default };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,110 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var formik = require('formik');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
var index = require('./Input/index.js');
const FormModal = ({ headerBreadcrumbs, initialData, isSubmiting, layout, isOpen, onSubmit, onToggle, providerToEditName })=>{
const { formatMessage } = reactIntl.useIntl();
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Root, {
open: isOpen,
onOpenChange: onToggle,
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Content, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Header, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Breadcrumbs, {
label: headerBreadcrumbs.join(', '),
children: headerBreadcrumbs.map((crumb, index, arr)=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Crumb, {
isCurrent: index === arr.length - 1,
children: crumb
}, crumb))
})
}),
/*#__PURE__*/ jsxRuntime.jsx(formik.Formik, {
onSubmit: (values)=>onSubmit(values),
initialValues: initialData,
validationSchema: layout.schema,
validateOnChange: false,
children: ({ errors, handleChange, values })=>{
return /*#__PURE__*/ jsxRuntime.jsxs(formik.Form, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Body, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 1,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Root, {
gap: 5,
children: layout.form.map((row)=>{
return row.map((input)=>{
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: input.size,
xs: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(index, {
...input,
error: errors[input.name],
onChange: handleChange,
value: values[input.name],
providerToEditName: providerToEditName
})
}, input.name);
});
})
})
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Footer, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
variant: "tertiary",
onClick: onToggle,
type: "button",
children: formatMessage({
id: 'app.components.Button.cancel',
defaultMessage: 'Cancel'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
type: "submit",
loading: isSubmiting,
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
})
]
})
]
});
}
})
]
})
});
};
FormModal.defaultProps = {
initialData: null,
providerToEditName: null
};
FormModal.propTypes = {
headerBreadcrumbs: PropTypes.arrayOf(PropTypes.string).isRequired,
initialData: PropTypes.object,
layout: PropTypes.shape({
form: PropTypes.arrayOf(PropTypes.array),
schema: PropTypes.object
}).isRequired,
isOpen: PropTypes.bool.isRequired,
isSubmiting: PropTypes.bool.isRequired,
onSubmit: PropTypes.func.isRequired,
onToggle: PropTypes.func.isRequired,
providerToEditName: PropTypes.string
};
module.exports = FormModal;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,108 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import 'react';
import { Modal, Breadcrumbs, Crumb, Flex, Grid, Button } from '@strapi/design-system';
import { Formik, Form } from 'formik';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import Input from './Input/index.mjs';
const FormModal = ({ headerBreadcrumbs, initialData, isSubmiting, layout, isOpen, onSubmit, onToggle, providerToEditName })=>{
const { formatMessage } = useIntl();
return /*#__PURE__*/ jsx(Modal.Root, {
open: isOpen,
onOpenChange: onToggle,
children: /*#__PURE__*/ jsxs(Modal.Content, {
children: [
/*#__PURE__*/ jsx(Modal.Header, {
children: /*#__PURE__*/ jsx(Breadcrumbs, {
label: headerBreadcrumbs.join(', '),
children: headerBreadcrumbs.map((crumb, index, arr)=>/*#__PURE__*/ jsx(Crumb, {
isCurrent: index === arr.length - 1,
children: crumb
}, crumb))
})
}),
/*#__PURE__*/ jsx(Formik, {
onSubmit: (values)=>onSubmit(values),
initialValues: initialData,
validationSchema: layout.schema,
validateOnChange: false,
children: ({ errors, handleChange, values })=>{
return /*#__PURE__*/ jsxs(Form, {
children: [
/*#__PURE__*/ jsx(Modal.Body, {
children: /*#__PURE__*/ jsx(Flex, {
direction: "column",
alignItems: "stretch",
gap: 1,
children: /*#__PURE__*/ jsx(Grid.Root, {
gap: 5,
children: layout.form.map((row)=>{
return row.map((input)=>{
return /*#__PURE__*/ jsx(Grid.Item, {
col: input.size,
xs: 12,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(Input, {
...input,
error: errors[input.name],
onChange: handleChange,
value: values[input.name],
providerToEditName: providerToEditName
})
}, input.name);
});
})
})
})
}),
/*#__PURE__*/ jsxs(Modal.Footer, {
children: [
/*#__PURE__*/ jsx(Button, {
variant: "tertiary",
onClick: onToggle,
type: "button",
children: formatMessage({
id: 'app.components.Button.cancel',
defaultMessage: 'Cancel'
})
}),
/*#__PURE__*/ jsx(Button, {
type: "submit",
loading: isSubmiting,
children: formatMessage({
id: 'global.save',
defaultMessage: 'Save'
})
})
]
})
]
});
}
})
]
})
});
};
FormModal.defaultProps = {
initialData: null,
providerToEditName: null
};
FormModal.propTypes = {
headerBreadcrumbs: PropTypes.arrayOf(PropTypes.string).isRequired,
initialData: PropTypes.object,
layout: PropTypes.shape({
form: PropTypes.arrayOf(PropTypes.array),
schema: PropTypes.object
}).isRequired,
isOpen: PropTypes.bool.isRequired,
isSubmiting: PropTypes.bool.isRequired,
onSubmit: PropTypes.func.isRequired,
onToggle: PropTypes.func.isRequired,
providerToEditName: PropTypes.string
};
export { FormModal as default };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
'use strict';
var designSystem = require('@strapi/design-system');
var styledComponents = require('styled-components');
const activeCheckboxWrapperStyles = styledComponents.css`
background: ${(props)=>props.theme.colors.primary100};
#cog {
opacity: 1;
}
`;
const CheckboxWrapper = styledComponents.styled(designSystem.Box)`
display: flex;
justify-content: space-between;
align-items: center;
#cog {
opacity: 0;
path {
fill: ${(props)=>props.theme.colors.primary600};
}
}
/* Show active style both on hover and when the action is selected */
${(props)=>props.isActive && activeCheckboxWrapperStyles}
&:hover {
${activeCheckboxWrapperStyles}
}
`;
module.exports = CheckboxWrapper;
//# sourceMappingURL=CheckboxWrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CheckboxWrapper.js","sources":["../../../../../admin/src/components/Permissions/PermissionRow/CheckboxWrapper.jsx"],"sourcesContent":["import { Box } from '@strapi/design-system';\nimport { styled, css } from 'styled-components';\n\nconst activeCheckboxWrapperStyles = css`\n background: ${(props) => props.theme.colors.primary100};\n\n #cog {\n opacity: 1;\n }\n`;\n\nconst CheckboxWrapper = styled(Box)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n #cog {\n opacity: 0;\n path {\n fill: ${(props) => props.theme.colors.primary600};\n }\n }\n\n /* Show active style both on hover and when the action is selected */\n ${(props) => props.isActive && activeCheckboxWrapperStyles}\n &:hover {\n ${activeCheckboxWrapperStyles}\n }\n`;\n\nexport default CheckboxWrapper;\n"],"names":["activeCheckboxWrapperStyles","css","props","theme","colors","primary100","CheckboxWrapper","styled","Box","primary600","isActive"],"mappings":";;;;;AAGA,MAAMA,2BAAAA,GAA8BC,oBAAG;cACzB,EAAE,CAACC,QAAUA,KAAMC,CAAAA,KAAK,CAACC,MAAM,CAACC,UAAU,CAAC;;;;;AAKzD,CAAC;AAEKC,MAAAA,eAAAA,GAAkBC,uBAAOC,CAAAA,gBAAAA,CAAI;;;;;;;;YAQvB,EAAE,CAACN,QAAUA,KAAMC,CAAAA,KAAK,CAACC,MAAM,CAACK,UAAU,CAAC;;;;;AAKrD,EAAA,EAAE,CAACP,KAAAA,GAAUA,KAAMQ,CAAAA,QAAQ,IAAIV,2BAA4B;;AAEzD,IAAA,EAAEA,2BAA4B;;AAElC;;;;"}

View File

@@ -0,0 +1,31 @@
import { Box } from '@strapi/design-system';
import { css, styled } from 'styled-components';
const activeCheckboxWrapperStyles = css`
background: ${(props)=>props.theme.colors.primary100};
#cog {
opacity: 1;
}
`;
const CheckboxWrapper = styled(Box)`
display: flex;
justify-content: space-between;
align-items: center;
#cog {
opacity: 0;
path {
fill: ${(props)=>props.theme.colors.primary600};
}
}
/* Show active style both on hover and when the action is selected */
${(props)=>props.isActive && activeCheckboxWrapperStyles}
&:hover {
${activeCheckboxWrapperStyles}
}
`;
export { CheckboxWrapper as default };
//# sourceMappingURL=CheckboxWrapper.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"CheckboxWrapper.mjs","sources":["../../../../../admin/src/components/Permissions/PermissionRow/CheckboxWrapper.jsx"],"sourcesContent":["import { Box } from '@strapi/design-system';\nimport { styled, css } from 'styled-components';\n\nconst activeCheckboxWrapperStyles = css`\n background: ${(props) => props.theme.colors.primary100};\n\n #cog {\n opacity: 1;\n }\n`;\n\nconst CheckboxWrapper = styled(Box)`\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n #cog {\n opacity: 0;\n path {\n fill: ${(props) => props.theme.colors.primary600};\n }\n }\n\n /* Show active style both on hover and when the action is selected */\n ${(props) => props.isActive && activeCheckboxWrapperStyles}\n &:hover {\n ${activeCheckboxWrapperStyles}\n }\n`;\n\nexport default CheckboxWrapper;\n"],"names":["activeCheckboxWrapperStyles","css","props","theme","colors","primary100","CheckboxWrapper","styled","Box","primary600","isActive"],"mappings":";;;AAGA,MAAMA,2BAAAA,GAA8BC,GAAG;cACzB,EAAE,CAACC,QAAUA,KAAMC,CAAAA,KAAK,CAACC,MAAM,CAACC,UAAU,CAAC;;;;;AAKzD,CAAC;AAEKC,MAAAA,eAAAA,GAAkBC,MAAOC,CAAAA,GAAAA,CAAI;;;;;;;;YAQvB,EAAE,CAACN,QAAUA,KAAMC,CAAAA,KAAK,CAACC,MAAM,CAACK,UAAU,CAAC;;;;;AAKrD,EAAA,EAAE,CAACP,KAAAA,GAAUA,KAAMQ,CAAAA,QAAQ,IAAIV,2BAA4B;;AAEzD,IAAA,EAAEA,2BAA4B;;AAElC;;;;"}

View File

@@ -0,0 +1,156 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var get = require('lodash/get');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
var styledComponents = require('styled-components');
var index = require('../../../contexts/UsersPermissionsContext/index.js');
var CheckboxWrapper = require('./CheckboxWrapper.js');
const Border = styledComponents.styled.div`
flex: 1;
align-self: center;
border-top: 1px solid ${({ theme })=>theme.colors.neutral150};
`;
const SubCategory = ({ subCategory })=>{
const { formatMessage } = reactIntl.useIntl();
const { onChange, onChangeSelectAll, onSelectedAction, selectedAction, modifiedData } = index.useUsersPermissions();
const currentScopedModifiedData = React.useMemo(()=>{
return get(modifiedData, subCategory.name, {});
}, [
modifiedData,
subCategory
]);
const hasAllActionsSelected = React.useMemo(()=>{
return Object.values(currentScopedModifiedData).every((action)=>action.enabled === true);
}, [
currentScopedModifiedData
]);
const hasSomeActionsSelected = React.useMemo(()=>{
return Object.values(currentScopedModifiedData).some((action)=>action.enabled === true) && !hasAllActionsSelected;
}, [
currentScopedModifiedData,
hasAllActionsSelected
]);
const handleChangeSelectAll = React.useCallback(({ target: { name } })=>{
onChangeSelectAll({
target: {
name,
value: !hasAllActionsSelected
}
});
}, [
hasAllActionsSelected,
onChangeSelectAll
]);
const isActionSelected = React.useCallback((actionName)=>{
return selectedAction === actionName;
}, [
selectedAction
]);
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Box, {
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
justifyContent: "space-between",
alignItems: "center",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingRight: 4,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "sigma",
textColor: "neutral600",
children: subCategory.label
})
}),
/*#__PURE__*/ jsxRuntime.jsx(Border, {}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
paddingLeft: 4,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Checkbox, {
name: subCategory.name,
checked: hasSomeActionsSelected ? 'indeterminate' : hasAllActionsSelected,
onCheckedChange: (value)=>handleChangeSelectAll({
target: {
name: subCategory.name,
value
}
}),
children: formatMessage({
id: 'app.utils.select-all',
defaultMessage: 'Select all'
})
})
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
paddingTop: 6,
paddingBottom: 6,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Root, {
gap: 2,
style: {
flex: 1
},
children: subCategory.actions.map((action)=>{
const name = `${action.name}.enabled`;
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsxs(CheckboxWrapper, {
isActive: isActionSelected(action.name),
padding: 2,
hasRadius: true,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Checkbox, {
checked: get(modifiedData, name, false),
name: name,
onCheckedChange: (value)=>onChange({
target: {
name,
value
}
}),
children: action.label
}),
/*#__PURE__*/ jsxRuntime.jsxs("button", {
type: "button",
onClick: ()=>onSelectedAction(action.name),
style: {
display: 'inline-flex',
alignItems: 'center'
},
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
tag: "span",
children: formatMessage({
id: 'app.utils.show-bound-route',
defaultMessage: 'Show bound route for {route}'
}, {
route: action.name
})
}),
/*#__PURE__*/ jsxRuntime.jsx(icons.Cog, {
id: "cog",
cursor: "pointer"
})
]
})
]
})
}, action.name);
})
})
})
]
});
};
SubCategory.propTypes = {
subCategory: PropTypes.object.isRequired
};
module.exports = SubCategory;
//# sourceMappingURL=SubCategory.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,154 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import { useMemo, useCallback } from 'react';
import { Box, Flex, Typography, Checkbox, Grid, VisuallyHidden } from '@strapi/design-system';
import { Cog } from '@strapi/icons';
import get from 'lodash/get';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { styled } from 'styled-components';
import { useUsersPermissions } from '../../../contexts/UsersPermissionsContext/index.mjs';
import CheckboxWrapper from './CheckboxWrapper.mjs';
const Border = styled.div`
flex: 1;
align-self: center;
border-top: 1px solid ${({ theme })=>theme.colors.neutral150};
`;
const SubCategory = ({ subCategory })=>{
const { formatMessage } = useIntl();
const { onChange, onChangeSelectAll, onSelectedAction, selectedAction, modifiedData } = useUsersPermissions();
const currentScopedModifiedData = useMemo(()=>{
return get(modifiedData, subCategory.name, {});
}, [
modifiedData,
subCategory
]);
const hasAllActionsSelected = useMemo(()=>{
return Object.values(currentScopedModifiedData).every((action)=>action.enabled === true);
}, [
currentScopedModifiedData
]);
const hasSomeActionsSelected = useMemo(()=>{
return Object.values(currentScopedModifiedData).some((action)=>action.enabled === true) && !hasAllActionsSelected;
}, [
currentScopedModifiedData,
hasAllActionsSelected
]);
const handleChangeSelectAll = useCallback(({ target: { name } })=>{
onChangeSelectAll({
target: {
name,
value: !hasAllActionsSelected
}
});
}, [
hasAllActionsSelected,
onChangeSelectAll
]);
const isActionSelected = useCallback((actionName)=>{
return selectedAction === actionName;
}, [
selectedAction
]);
return /*#__PURE__*/ jsxs(Box, {
children: [
/*#__PURE__*/ jsxs(Flex, {
justifyContent: "space-between",
alignItems: "center",
children: [
/*#__PURE__*/ jsx(Box, {
paddingRight: 4,
children: /*#__PURE__*/ jsx(Typography, {
variant: "sigma",
textColor: "neutral600",
children: subCategory.label
})
}),
/*#__PURE__*/ jsx(Border, {}),
/*#__PURE__*/ jsx(Box, {
paddingLeft: 4,
children: /*#__PURE__*/ jsx(Checkbox, {
name: subCategory.name,
checked: hasSomeActionsSelected ? 'indeterminate' : hasAllActionsSelected,
onCheckedChange: (value)=>handleChangeSelectAll({
target: {
name: subCategory.name,
value
}
}),
children: formatMessage({
id: 'app.utils.select-all',
defaultMessage: 'Select all'
})
})
})
]
}),
/*#__PURE__*/ jsx(Flex, {
paddingTop: 6,
paddingBottom: 6,
children: /*#__PURE__*/ jsx(Grid.Root, {
gap: 2,
style: {
flex: 1
},
children: subCategory.actions.map((action)=>{
const name = `${action.name}.enabled`;
return /*#__PURE__*/ jsx(Grid.Item, {
col: 6,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxs(CheckboxWrapper, {
isActive: isActionSelected(action.name),
padding: 2,
hasRadius: true,
children: [
/*#__PURE__*/ jsx(Checkbox, {
checked: get(modifiedData, name, false),
name: name,
onCheckedChange: (value)=>onChange({
target: {
name,
value
}
}),
children: action.label
}),
/*#__PURE__*/ jsxs("button", {
type: "button",
onClick: ()=>onSelectedAction(action.name),
style: {
display: 'inline-flex',
alignItems: 'center'
},
children: [
/*#__PURE__*/ jsx(VisuallyHidden, {
tag: "span",
children: formatMessage({
id: 'app.utils.show-bound-route',
defaultMessage: 'Show bound route for {route}'
}, {
route: action.name
})
}),
/*#__PURE__*/ jsx(Cog, {
id: "cog",
cursor: "pointer"
})
]
})
]
})
}, action.name);
})
})
})
]
});
};
SubCategory.propTypes = {
subCategory: PropTypes.object.isRequired
};
export { SubCategory as default };
//# sourceMappingURL=SubCategory.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,50 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var sortBy = require('lodash/sortBy');
var PropTypes = require('prop-types');
var SubCategory = require('./SubCategory.js');
const PermissionRow = ({ name, permissions })=>{
const subCategories = React.useMemo(()=>{
return sortBy(Object.values(permissions.controllers).reduce((acc, curr, index)=>{
const currentName = `${name}.controllers.${Object.keys(permissions.controllers)[index]}`;
const actions = sortBy(Object.keys(curr).reduce((acc, current)=>{
return [
...acc,
{
...curr[current],
label: current,
name: `${currentName}.${current}`
}
];
}, []), 'label');
return [
...acc,
{
actions,
label: Object.keys(permissions.controllers)[index],
name: currentName
}
];
}, []), 'label');
}, [
name,
permissions
]);
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
padding: 6,
children: subCategories.map((subCategory)=>/*#__PURE__*/ jsxRuntime.jsx(SubCategory, {
subCategory: subCategory
}, subCategory.name))
});
};
PermissionRow.propTypes = {
name: PropTypes.string.isRequired,
permissions: PropTypes.object.isRequired
};
module.exports = PermissionRow;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../admin/src/components/Permissions/PermissionRow/index.jsx"],"sourcesContent":["import React, { useMemo } from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport sortBy from 'lodash/sortBy';\nimport PropTypes from 'prop-types';\n\nimport SubCategory from './SubCategory';\n\nconst PermissionRow = ({ name, permissions }) => {\n const subCategories = useMemo(() => {\n return sortBy(\n Object.values(permissions.controllers).reduce((acc, curr, index) => {\n const currentName = `${name}.controllers.${Object.keys(permissions.controllers)[index]}`;\n const actions = sortBy(\n Object.keys(curr).reduce((acc, current) => {\n return [\n ...acc,\n {\n ...curr[current],\n label: current,\n name: `${currentName}.${current}`,\n },\n ];\n }, []),\n 'label'\n );\n\n return [\n ...acc,\n {\n actions,\n label: Object.keys(permissions.controllers)[index],\n name: currentName,\n },\n ];\n }, []),\n 'label'\n );\n }, [name, permissions]);\n\n return (\n <Box padding={6}>\n {subCategories.map((subCategory) => (\n <SubCategory key={subCategory.name} subCategory={subCategory} />\n ))}\n </Box>\n );\n};\n\nPermissionRow.propTypes = {\n name: PropTypes.string.isRequired,\n permissions: PropTypes.object.isRequired,\n};\n\nexport default PermissionRow;\n"],"names":["PermissionRow","name","permissions","subCategories","useMemo","sortBy","Object","values","controllers","reduce","acc","curr","index","currentName","keys","actions","current","label","_jsx","Box","padding","map","subCategory","SubCategory","propTypes","PropTypes","string","isRequired","object"],"mappings":";;;;;;;;;AAQA,MAAMA,gBAAgB,CAAC,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAA;AAC1C,IAAA,MAAMC,gBAAgBC,aAAQ,CAAA,IAAA;QAC5B,OAAOC,MAAAA,CACLC,MAAOC,CAAAA,MAAM,CAACL,WAAAA,CAAYM,WAAW,CAAA,CAAEC,MAAM,CAAC,CAACC,GAAAA,EAAK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AACC,UAAU;IACjCzB,WAAauB,EAAAA,SAAAA,CAAUG,MAAM,CAACD;AAChC,CAAA;;;;"}

View File

@@ -0,0 +1,48 @@
import { jsx } from 'react/jsx-runtime';
import { useMemo } from 'react';
import { Box } from '@strapi/design-system';
import sortBy from 'lodash/sortBy';
import PropTypes from 'prop-types';
import SubCategory from './SubCategory.mjs';
const PermissionRow = ({ name, permissions })=>{
const subCategories = useMemo(()=>{
return sortBy(Object.values(permissions.controllers).reduce((acc, curr, index)=>{
const currentName = `${name}.controllers.${Object.keys(permissions.controllers)[index]}`;
const actions = sortBy(Object.keys(curr).reduce((acc, current)=>{
return [
...acc,
{
...curr[current],
label: current,
name: `${currentName}.${current}`
}
];
}, []), 'label');
return [
...acc,
{
actions,
label: Object.keys(permissions.controllers)[index],
name: currentName
}
];
}, []), 'label');
}, [
name,
permissions
]);
return /*#__PURE__*/ jsx(Box, {
padding: 6,
children: subCategories.map((subCategory)=>/*#__PURE__*/ jsx(SubCategory, {
subCategory: subCategory
}, subCategory.name))
});
};
PermissionRow.propTypes = {
name: PropTypes.string.isRequired,
permissions: PropTypes.object.isRequired
};
export { PermissionRow as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../admin/src/components/Permissions/PermissionRow/index.jsx"],"sourcesContent":["import React, { useMemo } from 'react';\n\nimport { Box } from '@strapi/design-system';\nimport sortBy from 'lodash/sortBy';\nimport PropTypes from 'prop-types';\n\nimport SubCategory from './SubCategory';\n\nconst PermissionRow = ({ name, permissions }) => {\n const subCategories = useMemo(() => {\n return sortBy(\n Object.values(permissions.controllers).reduce((acc, curr, index) => {\n const currentName = `${name}.controllers.${Object.keys(permissions.controllers)[index]}`;\n const actions = sortBy(\n Object.keys(curr).reduce((acc, current) => {\n return [\n ...acc,\n {\n ...curr[current],\n label: current,\n name: `${currentName}.${current}`,\n },\n ];\n }, []),\n 'label'\n );\n\n return [\n ...acc,\n {\n actions,\n label: Object.keys(permissions.controllers)[index],\n name: currentName,\n },\n ];\n }, []),\n 'label'\n );\n }, [name, permissions]);\n\n return (\n <Box padding={6}>\n {subCategories.map((subCategory) => (\n <SubCategory key={subCategory.name} subCategory={subCategory} />\n ))}\n </Box>\n );\n};\n\nPermissionRow.propTypes = {\n name: PropTypes.string.isRequired,\n permissions: PropTypes.object.isRequired,\n};\n\nexport default PermissionRow;\n"],"names":["PermissionRow","name","permissions","subCategories","useMemo","sortBy","Object","values","controllers","reduce","acc","curr","index","currentName","keys","actions","current","label","_jsx","Box","padding","map","subCategory","SubCategory","propTypes","PropTypes","string","isRequired","object"],"mappings":";;;;;;;AAQA,MAAMA,gBAAgB,CAAC,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAA;AAC1C,IAAA,MAAMC,gBAAgBC,OAAQ,CAAA,IAAA;QAC5B,OAAOC,MAAAA,CACLC,MAAOC,CAAAA,MAAM,CAACL,WAAAA,CAAYM,WAAW,CAAA,CAAEC,MAAM,CAAC,CAACC,GAAAA,EAAKC,IAAMC,EAAAA,KAAAA,GAAAA;AACxD,YAAA,MAAMC,WAAc,GAAA,CAAC,EAAEZ,IAAAA,CAAK,aAAa,EAAEK,MAAAA,CAAOQ,IAAI,CAACZ,YAAYM,WAAW,CAAC,CAACI,KAAAA,CAAM,CAAC,CAAC;YACxF,MAAMG,OAAAA,GAAUV,OACdC,MAAOQ,CAAAA,IAAI,CAACH,IAAMF,CAAAA,CAAAA,MAAM,CAAC,CAACC,GAAKM,EAAAA,OAAAA,GAAAA;gBAC7B,OAAO;AACFN,oBAAAA,GAAAA,GAAAA;AACH,oBAAA;wBACE,GAAGC,IAAI,CAACK,OAAQ,CAAA;wBAChBC,KAAOD,EAAAA,OAAAA;AACPf,wBAAAA,IAAAA,EAAM,CAAC,EAAEY,WAAAA,CAAY,CAAC,EAAEG,QAAQ;AAClC;AACD,iBAAA;AACH,aAAA,EAAG,EAAE,CACL,EAAA,OAAA,CAAA;YAGF,OAAO;AACFN,gBAAAA,GAAAA,GAAAA;AACH,gBAAA;AACEK,oBAAAA,OAAAA;AACAE,oBAAAA,KAAAA,EAAOX,OAAOQ,IAAI,CAACZ,YAAYM,WAAW,CAAC,CAACI,KAAM,CAAA;oBAClDX,IAAMY,EAAAA;AACR;AACD,aAAA;AACH,SAAA,EAAG,EAAE,CACL,EAAA,OAAA,CAAA;KAED,EAAA;AAACZ,QAAAA,IAAAA;AAAMC,QAAAA;AAAY,KAAA,CAAA;AAEtB,IAAA,qBACEgB,GAACC,CAAAA,GAAAA,EAAAA;QAAIC,OAAS,EAAA,CAAA;AACXjB,QAAAA,QAAAA,EAAAA,aAAAA,CAAckB,GAAG,CAAC,CAACC,WAAAA,iBAClBJ,GAACK,CAAAA,WAAAA,EAAAA;gBAAmCD,WAAaA,EAAAA;AAA/BA,aAAAA,EAAAA,WAAAA,CAAYrB,IAAI,CAAA;;AAI1C;AAEAD,aAAAA,CAAcwB,SAAS,GAAG;IACxBvB,IAAMwB,EAAAA,SAAAA,CAAUC,MAAM,CAACC,UAAU;IACjCzB,WAAauB,EAAAA,SAAAA,CAAUG,MAAM,CAACD;AAChC,CAAA;;;;"}

View File

@@ -0,0 +1,52 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var reactIntl = require('react-intl');
var index = require('../../contexts/UsersPermissionsContext/index.js');
var formatPluginName = require('../../utils/formatPluginName.js');
var init = require('./init.js');
var index$1 = require('./PermissionRow/index.js');
var reducer = require('./reducer.js');
const Permissions = ()=>{
const { modifiedData } = index.useUsersPermissions();
const { formatMessage } = reactIntl.useIntl();
const [{ collapses }] = React.useReducer(reducer.reducer, reducer.initialState, (state)=>init(state, modifiedData));
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Accordion.Root, {
size: "M",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 1,
children: collapses.map((collapse, index)=>/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Accordion.Item, {
value: collapse.name,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Accordion.Header, {
variant: index % 2 === 0 ? 'secondary' : undefined,
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Accordion.Trigger, {
caretPosition: "right",
description: formatMessage({
id: 'users-permissions.Plugin.permissions.plugins.description',
defaultMessage: 'Define all allowed actions for the {name} plugin.'
}, {
name: collapse.name
}),
children: formatPluginName(collapse.name)
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Accordion.Content, {
children: /*#__PURE__*/ jsxRuntime.jsx(index$1, {
permissions: modifiedData[collapse.name],
name: collapse.name
})
})
]
}, collapse.name))
})
});
};
module.exports = Permissions;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../admin/src/components/Permissions/index.jsx"],"sourcesContent":["import React, { useReducer } from 'react';\n\nimport { Accordion, Flex } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useUsersPermissions } from '../../contexts/UsersPermissionsContext';\nimport formatPluginName from '../../utils/formatPluginName';\n\nimport init from './init';\nimport PermissionRow from './PermissionRow';\nimport { initialState, reducer } from './reducer';\n\nconst Permissions = () => {\n const { modifiedData } = useUsersPermissions();\n const { formatMessage } = useIntl();\n const [{ collapses }] = useReducer(reducer, initialState, (state) => init(state, modifiedData));\n\n return (\n <Accordion.Root size=\"M\">\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n {collapses.map((collapse, index) => (\n <Accordion.Item key={collapse.name} value={collapse.name}>\n <Accordion.Header variant={index % 2 === 0 ? 'secondary' : undefined}>\n <Accordion.Trigger\n caretPosition=\"right\"\n description={formatMessage(\n {\n id: 'users-permissions.Plugin.permissions.plugins.description',\n defaultMessage: 'Define all allowed actions for the {name} plugin.',\n },\n { name: collapse.name }\n )}\n >\n {formatPluginName(collapse.name)}\n </Accordion.Trigger>\n </Accordion.Header>\n <Accordion.Content>\n <PermissionRow permissions={modifiedData[collapse.name]} name={collapse.name} />\n </Accordion.Content>\n </Accordion.Item>\n ))}\n </Flex>\n </Accordion.Root>\n );\n};\n\nexport default Permissions;\n"],"names":["Permissions","modifiedData","useUsersPermissions","formatMessage","useIntl","collapses","useReducer","reducer","initialState","state","init","_jsx","Accordion","Root","size","Flex","direction","alignItems","gap","map","collapse","index","_jsxs","Item","value","name","Header","variant","undefined","Trigger","caretPosition","description","id","defaultMessage","formatPluginName","Content","PermissionRow","permissions"],"mappings":";;;;;;;;;;;;AAYA,MAAMA,WAAc,GAAA,IAAA;IAClB,MAAM,EAAEC,YAAY,EAAE,GAAGC,yBAAAA,EAAAA;IACzB,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,CAAC,EAAEC,SAAS,EAAE,CAAC,GAAGC,gBAAWC,CAAAA,eAAAA,EAASC,oBAAc,EAAA,CAACC,KAAUC,GAAAA,IAAAA,CAAKD,KAAOR,EAAAA,YAAAA,CAAAA,CAAAA;IAEjF,qBACEU,cAAA,CAACC,uBAAUC,IAAI,EAAA;QAACC,IAAK,EAAA,GAAA;AACnB,QAAA,QAAA,gBAAAH,cAACI,CAAAA,iBAAAA,EAAAA;YAAKC,SAAU,EAAA,QAAA;YAASC,UAAW,EAAA,SAAA;YAAUC,GAAK,EAAA,CAAA;AAChDb,YAAAA,QAAAA,EAAAA,SAAAA,CAAUc,GAAG,CAAC,CAACC,UAAUC,KACxB,iBAAAC,eAAA,CAACV,uBAAUW,IAAI,EAAA;AAAqBC,oBAAAA,KAAAA,EAAOJ,SAASK,IAAI;;AACtD,sCAAAd,cAAA,CAACC,uBAAUc,MAAM,EAAA;4BAACC,OAASN,EAAAA,KAAAA,GAAQ,CAAM,KAAA,CAAA,GAAI,WAAcO,GAAAA,SAAAA;oDACzDjB,cAAA,CAACC,uBAAUiB,OAAO,EAAA;gCAChBC,aAAc,EAAA,OAAA;AACdC,gCAAAA,WAAAA,EAAa5B,aACX,CAAA;oCACE6B,EAAI,EAAA,0DAAA;oCACJC,cAAgB,EAAA;iCAElB,EAAA;AAAER,oCAAAA,IAAAA,EAAML,SAASK;AAAK,iCAAA,CAAA;AAGvBS,gCAAAA,QAAAA,EAAAA,gBAAAA,CAAiBd,SAASK,IAAI;;;AAGnC,sCAAAd,cAAA,CAACC,uBAAUuB,OAAO,EAAA;AAChB,4BAAA,QAAA,gBAAAxB,cAACyB,CAAAA,OAAAA,EAAAA;AAAcC,gCAAAA,WAAAA,EAAapC,YAAY,CAACmB,QAASK,CAAAA,IAAI,CAAC;AAAEA,gCAAAA,IAAAA,EAAML,SAASK;;;;AAhBvDL,iBAAAA,EAAAA,QAAAA,CAASK,IAAI,CAAA;;;AAuB5C;;;;"}

View File

@@ -0,0 +1,50 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import { useReducer } from 'react';
import { Accordion, Flex } from '@strapi/design-system';
import { useIntl } from 'react-intl';
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext/index.mjs';
import formatPluginName from '../../utils/formatPluginName.mjs';
import init from './init.mjs';
import PermissionRow from './PermissionRow/index.mjs';
import { reducer, initialState } from './reducer.mjs';
const Permissions = ()=>{
const { modifiedData } = useUsersPermissions();
const { formatMessage } = useIntl();
const [{ collapses }] = useReducer(reducer, initialState, (state)=>init(state, modifiedData));
return /*#__PURE__*/ jsx(Accordion.Root, {
size: "M",
children: /*#__PURE__*/ jsx(Flex, {
direction: "column",
alignItems: "stretch",
gap: 1,
children: collapses.map((collapse, index)=>/*#__PURE__*/ jsxs(Accordion.Item, {
value: collapse.name,
children: [
/*#__PURE__*/ jsx(Accordion.Header, {
variant: index % 2 === 0 ? 'secondary' : undefined,
children: /*#__PURE__*/ jsx(Accordion.Trigger, {
caretPosition: "right",
description: formatMessage({
id: 'users-permissions.Plugin.permissions.plugins.description',
defaultMessage: 'Define all allowed actions for the {name} plugin.'
}, {
name: collapse.name
}),
children: formatPluginName(collapse.name)
})
}),
/*#__PURE__*/ jsx(Accordion.Content, {
children: /*#__PURE__*/ jsx(PermissionRow, {
permissions: modifiedData[collapse.name],
name: collapse.name
})
})
]
}, collapse.name))
})
});
};
export { Permissions as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../admin/src/components/Permissions/index.jsx"],"sourcesContent":["import React, { useReducer } from 'react';\n\nimport { Accordion, Flex } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useUsersPermissions } from '../../contexts/UsersPermissionsContext';\nimport formatPluginName from '../../utils/formatPluginName';\n\nimport init from './init';\nimport PermissionRow from './PermissionRow';\nimport { initialState, reducer } from './reducer';\n\nconst Permissions = () => {\n const { modifiedData } = useUsersPermissions();\n const { formatMessage } = useIntl();\n const [{ collapses }] = useReducer(reducer, initialState, (state) => init(state, modifiedData));\n\n return (\n <Accordion.Root size=\"M\">\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n {collapses.map((collapse, index) => (\n <Accordion.Item key={collapse.name} value={collapse.name}>\n <Accordion.Header variant={index % 2 === 0 ? 'secondary' : undefined}>\n <Accordion.Trigger\n caretPosition=\"right\"\n description={formatMessage(\n {\n id: 'users-permissions.Plugin.permissions.plugins.description',\n defaultMessage: 'Define all allowed actions for the {name} plugin.',\n },\n { name: collapse.name }\n )}\n >\n {formatPluginName(collapse.name)}\n </Accordion.Trigger>\n </Accordion.Header>\n <Accordion.Content>\n <PermissionRow permissions={modifiedData[collapse.name]} name={collapse.name} />\n </Accordion.Content>\n </Accordion.Item>\n ))}\n </Flex>\n </Accordion.Root>\n );\n};\n\nexport default Permissions;\n"],"names":["Permissions","modifiedData","useUsersPermissions","formatMessage","useIntl","collapses","useReducer","reducer","initialState","state","init","_jsx","Accordion","Root","size","Flex","direction","alignItems","gap","map","collapse","index","_jsxs","Item","value","name","Header","variant","undefined","Trigger","caretPosition","description","id","defaultMessage","formatPluginName","Content","PermissionRow","permissions"],"mappings":";;;;;;;;;;AAYA,MAA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AAI,CAAC;AAAEA,gCAAAA,IAAAA,EAAML,SAASK;;;;AAhBvDL,iBAAAA,EAAAA,QAAAA,CAASK,IAAI,CAAA;;;AAuB5C;;;;"}

View File

@@ -0,0 +1,15 @@
'use strict';
const init = (initialState, permissions)=>{
const collapses = Object.keys(permissions).sort().map((name)=>({
name,
isOpen: false
}));
return {
...initialState,
collapses
};
};
module.exports = init;
//# sourceMappingURL=init.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"init.js","sources":["../../../../admin/src/components/Permissions/init.js"],"sourcesContent":["const init = (initialState, permissions) => {\n const collapses = Object.keys(permissions)\n .sort()\n .map((name) => ({ name, isOpen: false }));\n\n return { ...initialState, collapses };\n};\n\nexport default init;\n"],"names":["init","initialState","permissions","collapses","Object","keys","sort","map","name","isOpen"],"mappings":";;AAAMA,MAAAA,IAAAA,GAAO,CAACC,YAAcC,EAAAA,WAAAA,GAAAA;IAC1B,MAAMC,SAAAA,GAAYC,MAAOC,CAAAA,IAAI,CAACH,WAAAA,CAAAA,CAC3BI,IAAI,EAAA,CACJC,GAAG,CAAC,CAACC,IAAAA,IAAU;AAAEA,YAAAA,IAAAA;YAAMC,MAAQ,EAAA;SAAM,CAAA,CAAA;IAExC,OAAO;AAAE,QAAA,GAAGR,YAAY;AAAEE,QAAAA;AAAU,KAAA;AACtC;;;;"}

View File

@@ -0,0 +1,13 @@
const init = (initialState, permissions)=>{
const collapses = Object.keys(permissions).sort().map((name)=>({
name,
isOpen: false
}));
return {
...initialState,
collapses
};
};
export { init as default };
//# sourceMappingURL=init.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"init.mjs","sources":["../../../../admin/src/components/Permissions/init.js"],"sourcesContent":["const init = (initialState, permissions) => {\n const collapses = Object.keys(permissions)\n .sort()\n .map((name) => ({ name, isOpen: false }));\n\n return { ...initialState, collapses };\n};\n\nexport default init;\n"],"names":["init","initialState","permissions","collapses","Object","keys","sort","map","name","isOpen"],"mappings":"AAAMA,MAAAA,IAAAA,GAAO,CAACC,YAAcC,EAAAA,WAAAA,GAAAA;IAC1B,MAAMC,SAAAA,GAAYC,MAAOC,CAAAA,IAAI,CAACH,WAAAA,CAAAA,CAC3BI,IAAI,EAAA,CACJC,GAAG,CAAC,CAACC,IAAAA,IAAU;AAAEA,YAAAA,IAAAA;YAAMC,MAAQ,EAAA;SAAM,CAAA,CAAA;IAExC,OAAO;AAAE,QAAA,GAAGR,YAAY;AAAEE,QAAAA;AAAU,KAAA;AACtC;;;;"}

View File

@@ -0,0 +1,34 @@
'use strict';
var immer = require('immer');
const initialState = {
collapses: []
};
const reducer = (state, action)=>// eslint-disable-next-line consistent-return
immer.produce(state, (draftState)=>{
switch(action.type){
case 'TOGGLE_COLLAPSE':
{
draftState.collapses = state.collapses.map((collapse, index)=>{
if (index === action.index) {
return {
...collapse,
isOpen: !collapse.isOpen
};
}
return {
...collapse,
isOpen: false
};
});
break;
}
default:
return draftState;
}
});
exports.initialState = initialState;
exports.reducer = reducer;
//# sourceMappingURL=reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reducer.js","sources":["../../../../admin/src/components/Permissions/reducer.js"],"sourcesContent":["import { produce } from 'immer';\n\nconst initialState = {\n collapses: [],\n};\n\nconst reducer = (state, action) =>\n // eslint-disable-next-line consistent-return\n produce(state, (draftState) => {\n switch (action.type) {\n case 'TOGGLE_COLLAPSE': {\n draftState.collapses = state.collapses.map((collapse, index) => {\n if (index === action.index) {\n return { ...collapse, isOpen: !collapse.isOpen };\n }\n\n return { ...collapse, isOpen: false };\n });\n\n break;\n }\n default:\n return draftState;\n }\n });\n\nexport { initialState, reducer };\n"],"names":["initialState","collapses","reducer","state","action","produce","draftState","type","map","collapse","index","isOpen"],"mappings":";;;;AAEA,MAAMA,YAAe,GAAA;AACnBC,IAAAA,SAAAA,EAAW;AACb;AAEA,MAAMC,OAAU,GAAA,CAACC,KAAOC,EAAAA,MAAAA;AAEtBC,IAAAA,aAAAA,CAAQF,OAAO,CAACG,UAAAA,GAAAA;AACd,QAAA,OAAQF,OAAOG,IAAI;YACjB,KAAK,iBAAA;AAAmB,gBAAA;oBACtBD,UAAWL,CAAAA,SAAS,GAAGE,KAAMF,CAAAA,SAAS,CAACO,GAAG,CAAC,CAACC,QAAUC,EAAAA,KAAAA,GAAAA;wBACpD,IAAIA,KAAAA,KAAUN,MAAOM,CAAAA,KAAK,EAAE;4BAC1B,OAAO;AAAE,gCAAA,GAAGD,QAAQ;gCAAEE,MAAQ,EAAA,CAACF,SAASE;AAAO,6BAAA;AACjD;wBAEA,OAAO;AAAE,4BAAA,GAAGF,QAAQ;4BAAEE,MAAQ,EAAA;AAAM,yBAAA;AACtC,qBAAA,CAAA;AAEA,oBAAA;AACF;AACA,YAAA;gBACE,OAAOL,UAAAA;AACX;AACF,KAAA;;;;;"}

View File

@@ -0,0 +1,31 @@
import { produce } from 'immer';
const initialState = {
collapses: []
};
const reducer = (state, action)=>// eslint-disable-next-line consistent-return
produce(state, (draftState)=>{
switch(action.type){
case 'TOGGLE_COLLAPSE':
{
draftState.collapses = state.collapses.map((collapse, index)=>{
if (index === action.index) {
return {
...collapse,
isOpen: !collapse.isOpen
};
}
return {
...collapse,
isOpen: false
};
});
break;
}
default:
return draftState;
}
});
export { initialState, reducer };
//# sourceMappingURL=reducer.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reducer.mjs","sources":["../../../../admin/src/components/Permissions/reducer.js"],"sourcesContent":["import { produce } from 'immer';\n\nconst initialState = {\n collapses: [],\n};\n\nconst reducer = (state, action) =>\n // eslint-disable-next-line consistent-return\n produce(state, (draftState) => {\n switch (action.type) {\n case 'TOGGLE_COLLAPSE': {\n draftState.collapses = state.collapses.map((collapse, index) => {\n if (index === action.index) {\n return { ...collapse, isOpen: !collapse.isOpen };\n }\n\n return { ...collapse, isOpen: false };\n });\n\n break;\n }\n default:\n return draftState;\n }\n });\n\nexport { initialState, reducer };\n"],"names":["initialState","collapses","reducer","state","action","produce","draftState","type","map","collapse","index","isOpen"],"mappings":";;AAEA,MAAMA,YAAe,GAAA;AACnBC,IAAAA,SAAAA,EAAW;AACb;AAEA,MAAMC,OAAU,GAAA,CAACC,KAAOC,EAAAA,MAAAA;AAEtBC,IAAAA,OAAAA,CAAQF,OAAO,CAACG,UAAAA,GAAAA;AACd,QAAA,OAAQF,OAAOG,IAAI;YACjB,KAAK,iBAAA;AAAmB,gBAAA;oBACtBD,UAAWL,CAAAA,SAAS,GAAGE,KAAMF,CAAAA,SAAS,CAACO,GAAG,CAAC,CAACC,QAAUC,EAAAA,KAAAA,GAAAA;wBACpD,IAAIA,KAAAA,KAAUN,MAAOM,CAAAA,KAAK,EAAE;4BAC1B,OAAO;AAAE,gCAAA,GAAGD,QAAQ;gCAAEE,MAAQ,EAAA,CAACF,SAASE;AAAO,6BAAA;AACjD;wBAEA,OAAO;AAAE,4BAAA,GAAGF,QAAQ;4BAAEE,MAAQ,EAAA;AAAM,yBAAA;AACtC,qBAAA,CAAA;AAEA,oBAAA;AACF;AACA,YAAA;gBACE,OAAOL,UAAAA;AACX;AACF,KAAA;;;;"}

View File

@@ -0,0 +1,67 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var get = require('lodash/get');
var isEmpty = require('lodash/isEmpty');
var without = require('lodash/without');
var reactIntl = require('react-intl');
var index = require('../../contexts/UsersPermissionsContext/index.js');
var index$1 = require('../BoundRoute/index.js');
const Policies = ()=>{
const { formatMessage } = reactIntl.useIntl();
const { selectedAction, routes } = index.useUsersPermissions();
const path = without(selectedAction.split('.'), 'controllers');
const controllerRoutes = get(routes, path[0]);
const pathResolved = path.slice(1).join('.');
const displayedRoutes = isEmpty(controllerRoutes) ? [] : controllerRoutes.filter((o)=>o.handler.endsWith(pathResolved));
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 5,
background: "neutral150",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
style: {
minHeight: '100%'
},
direction: "column",
alignItems: "stretch",
children: selectedAction ? /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: displayedRoutes.map((route, key)=>// eslint-disable-next-line react/no-array-index-key
/*#__PURE__*/ jsxRuntime.jsx(index$1, {
route: route
}, key))
}) : /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "delta",
tag: "h3",
children: formatMessage({
id: 'users-permissions.Policies.header.title',
defaultMessage: 'Advanced settings'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
tag: "p",
textColor: "neutral600",
children: formatMessage({
id: 'users-permissions.Policies.header.hint',
defaultMessage: "Select the application's actions or the plugin's actions and click on the cog icon to display the bound route"
})
})
]
})
});
};
module.exports = Policies;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../admin/src/components/Policies/index.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Flex, Grid, Typography } from '@strapi/design-system';\nimport get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\nimport without from 'lodash/without';\nimport { useIntl } from 'react-intl';\n\nimport { useUsersPermissions } from '../../contexts/UsersPermissionsContext';\nimport BoundRoute from '../BoundRoute';\n\nconst Policies = () => {\n const { formatMessage } = useIntl();\n const { selectedAction, routes } = useUsersPermissions();\n\n const path = without(selectedAction.split('.'), 'controllers');\n const controllerRoutes = get(routes, path[0]);\n const pathResolved = path.slice(1).join('.');\n\n const displayedRoutes = isEmpty(controllerRoutes)\n ? []\n : controllerRoutes.filter((o) => o.handler.endsWith(pathResolved));\n\n return (\n <Grid.Item\n col={5}\n background=\"neutral150\"\n paddingTop={6}\n paddingBottom={6}\n paddingLeft={7}\n paddingRight={7}\n style={{ minHeight: '100%' }}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {selectedAction ? (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n {displayedRoutes.map((route, key) => (\n // eslint-disable-next-line react/no-array-index-key\n <BoundRoute key={key} route={route} />\n ))}\n </Flex>\n ) : (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n <Typography variant=\"delta\" tag=\"h3\">\n {formatMessage({\n id: 'users-permissions.Policies.header.title',\n defaultMessage: 'Advanced settings',\n })}\n </Typography>\n <Typography tag=\"p\" textColor=\"neutral600\">\n {formatMessage({\n id: 'users-permissions.Policies.header.hint',\n defaultMessage:\n \"Select the application's actions or the plugin's actions and click on the cog icon to display the bound route\",\n })}\n </Typography>\n </Flex>\n )}\n </Grid.Item>\n );\n};\n\nexport default Policies;\n"],"names":["Policies","formatMessage","useIntl","selectedAction","routes","useUsersPermissions","path","without","split","controllerRoutes","get","pathResolved","slice","join","displayedRoutes","isEmpty","filter","o","handler","endsWith","_jsx","Grid","Item","col","background","paddingTop","paddingBottom","paddingLeft","paddingRight","style","minHeight","direction","alignItems","Flex","gap","map","route","key","BoundRoute","_jsxs","Typography","variant","tag","id","defaultMessage","textColor"],"mappings":";;;;;;;;;;;;AAWA,MAAMA,QAAW,GAAA,IAAA;IACf,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,cAAc,EAAEC,MAAM,EAAE,GAAGC,yBAAAA,EAAAA;AAEnC,IAAA,MAAMC,IAAOC,GAAAA,OAAAA,CAAQJ,cAAeK,CAAAA,KAAK,CAAC,GAAM,CAAA,EAAA,aAAA,CAAA;AAChD,IAAA,MAAMC,gBAAmBC,GAAAA,GAAAA,CAAIN,MAAQE,EAAAA,IAAI,CAAC,CAAE,CAAA,CAAA;AAC5C,IAAA,MAAMK,eAAeL,IAAKM,CAAAA,KAAK,CAAC,CAAA,CAAA,CAAGC,IAAI,CAAC,GAAA,CAAA;AAExC,IAAA,MAAMC,eAAkBC,GAAAA,OAAAA,CAAQN,gBA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AMZ;;;;"}

View File

@@ -0,0 +1,65 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import 'react';
import { Grid, Flex, Typography } from '@strapi/design-system';
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import without from 'lodash/without';
import { useIntl } from 'react-intl';
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext/index.mjs';
import BoundRoute from '../BoundRoute/index.mjs';
const Policies = ()=>{
const { formatMessage } = useIntl();
const { selectedAction, routes } = useUsersPermissions();
const path = without(selectedAction.split('.'), 'controllers');
const controllerRoutes = get(routes, path[0]);
const pathResolved = path.slice(1).join('.');
const displayedRoutes = isEmpty(controllerRoutes) ? [] : controllerRoutes.filter((o)=>o.handler.endsWith(pathResolved));
return /*#__PURE__*/ jsx(Grid.Item, {
col: 5,
background: "neutral150",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
style: {
minHeight: '100%'
},
direction: "column",
alignItems: "stretch",
children: selectedAction ? /*#__PURE__*/ jsx(Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: displayedRoutes.map((route, key)=>// eslint-disable-next-line react/no-array-index-key
/*#__PURE__*/ jsx(BoundRoute, {
route: route
}, key))
}) : /*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
/*#__PURE__*/ jsx(Typography, {
variant: "delta",
tag: "h3",
children: formatMessage({
id: 'users-permissions.Policies.header.title',
defaultMessage: 'Advanced settings'
})
}),
/*#__PURE__*/ jsx(Typography, {
tag: "p",
textColor: "neutral600",
children: formatMessage({
id: 'users-permissions.Policies.header.hint',
defaultMessage: "Select the application's actions or the plugin's actions and click on the cog icon to display the bound route"
})
})
]
})
});
};
export { Policies as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../admin/src/components/Policies/index.jsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Flex, Grid, Typography } from '@strapi/design-system';\nimport get from 'lodash/get';\nimport isEmpty from 'lodash/isEmpty';\nimport without from 'lodash/without';\nimport { useIntl } from 'react-intl';\n\nimport { useUsersPermissions } from '../../contexts/UsersPermissionsContext';\nimport BoundRoute from '../BoundRoute';\n\nconst Policies = () => {\n const { formatMessage } = useIntl();\n const { selectedAction, routes } = useUsersPermissions();\n\n const path = without(selectedAction.split('.'), 'controllers');\n const controllerRoutes = get(routes, path[0]);\n const pathResolved = path.slice(1).join('.');\n\n const displayedRoutes = isEmpty(controllerRoutes)\n ? []\n : controllerRoutes.filter((o) => o.handler.endsWith(pathResolved));\n\n return (\n <Grid.Item\n col={5}\n background=\"neutral150\"\n paddingTop={6}\n paddingBottom={6}\n paddingLeft={7}\n paddingRight={7}\n style={{ minHeight: '100%' }}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {selectedAction ? (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n {displayedRoutes.map((route, key) => (\n // eslint-disable-next-line react/no-array-index-key\n <BoundRoute key={key} route={route} />\n ))}\n </Flex>\n ) : (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={2}>\n <Typography variant=\"delta\" tag=\"h3\">\n {formatMessage({\n id: 'users-permissions.Policies.header.title',\n defaultMessage: 'Advanced settings',\n })}\n </Typography>\n <Typography tag=\"p\" textColor=\"neutral600\">\n {formatMessage({\n id: 'users-permissions.Policies.header.hint',\n defaultMessage:\n \"Select the application's actions or the plugin's actions and click on the cog icon to display the bound route\",\n })}\n </Typography>\n </Flex>\n )}\n </Grid.Item>\n );\n};\n\nexport default Policies;\n"],"names":["Policies","formatMessage","useIntl","selectedAction","routes","useUsersPermissions","path","without","split","controllerRoutes","get","pathResolved","slice","join","displayedRoutes","isEmpty","filter","o","handler","endsWith","_jsx","Grid","Item","col","background","paddingTop","paddingBottom","paddingLeft","paddingRight","style","minHeight","direction","alignItems","Flex","gap","map","route","key","BoundRoute","_jsxs","Typography","variant","tag","id","defaultMessage","textColor"],"mappings":";;;;;;;;;;AAWA,M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AAAA,EAAAA,GAAAA,CAAAA;2BAIrBE,IAACN,CAAAA,IAAAA,EAAAA;YAAKF,SAAU,EAAA,QAAA;YAASC,UAAW,EAAA,SAAA;YAAUE,GAAK,EAAA,CAAA;;8BACjDd,GAACoB,CAAAA,UAAAA,EAAAA;oBAAWC,OAAQ,EAAA,OAAA;oBAAQC,GAAI,EAAA,IAAA;8BAC7BzC,aAAc,CAAA;wBACb0C,EAAI,EAAA,yCAAA;wBACJC,cAAgB,EAAA;AAClB,qBAAA;;8BAEFxB,GAACoB,CAAAA,UAAAA,EAAAA;oBAAWE,GAAI,EAAA,GAAA;oBAAIG,SAAU,EAAA,YAAA;8BAC3B5C,aAAc,CAAA;wBACb0C,EAAI,EAAA,wCAAA;wBACJC,cACE,EAAA;AACJ,qBAAA;;;;;AAMZ;;;;"}

View File

@@ -0,0 +1,115 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var designSystem = require('@strapi/design-system');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
var index = require('../../contexts/UsersPermissionsContext/index.js');
var getTrad = require('../../utils/getTrad.js');
var index$1 = require('../Permissions/index.js');
var index$2 = require('../Policies/index.js');
var init = require('./init.js');
var reducer = require('./reducer.js');
const UsersPermissions = /*#__PURE__*/ React.forwardRef(({ permissions, routes }, ref)=>{
const { formatMessage } = reactIntl.useIntl();
const [state, dispatch] = React.useReducer(reducer.default, reducer.initialState, (state)=>init(state, permissions, routes));
React.useImperativeHandle(ref, ()=>({
getPermissions () {
return {
permissions: state.modifiedData
};
},
resetForm () {
dispatch({
type: 'ON_RESET'
});
},
setFormAfterSubmit () {
dispatch({
type: 'ON_SUBMIT_SUCCEEDED'
});
}
}));
const handleChange = ({ target: { name, value } })=>dispatch({
type: 'ON_CHANGE',
keys: name.split('.'),
value: value === 'empty__string_value' ? '' : value
});
const handleChangeSelectAll = ({ target: { name, value } })=>dispatch({
type: 'ON_CHANGE_SELECT_ALL',
keys: name.split('.'),
value
});
const handleSelectedAction = (actionToSelect)=>dispatch({
type: 'SELECT_ACTION',
actionToSelect
});
const providerValue = {
...state,
onChange: handleChange,
onChangeSelectAll: handleChangeSelectAll,
onSelectedAction: handleSelectedAction
};
return /*#__PURE__*/ jsxRuntime.jsx(index.UsersPermissionsProvider, {
value: providerValue,
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Grid.Root, {
gap: 0,
shadow: "filterShadow",
hasRadius: true,
background: "neutral0",
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: 7,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 6,
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: getTrad('Plugins.header.title'),
defaultMessage: 'Permissions'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
tag: "p",
textColor: "neutral600",
children: formatMessage({
id: getTrad('Plugins.header.description'),
defaultMessage: 'Only actions bound by a route are listed below.'
})
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(index$1, {})
]
})
}),
/*#__PURE__*/ jsxRuntime.jsx(index$2, {})
]
})
});
});
UsersPermissions.propTypes = {
permissions: PropTypes.object.isRequired,
routes: PropTypes.object.isRequired
};
var UsersPermissions$1 = /*#__PURE__*/ React.memo(UsersPermissions);
module.exports = UsersPermissions$1;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import { forwardRef, useReducer, useImperativeHandle, memo } from 'react';
import { Grid, Flex, Typography } from '@strapi/design-system';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { UsersPermissionsProvider } from '../../contexts/UsersPermissionsContext/index.mjs';
import getTrad from '../../utils/getTrad.mjs';
import Permissions from '../Permissions/index.mjs';
import Policies from '../Policies/index.mjs';
import init from './init.mjs';
import reducer, { initialState } from './reducer.mjs';
const UsersPermissions = /*#__PURE__*/ forwardRef(({ permissions, routes }, ref)=>{
const { formatMessage } = useIntl();
const [state, dispatch] = useReducer(reducer, initialState, (state)=>init(state, permissions, routes));
useImperativeHandle(ref, ()=>({
getPermissions () {
return {
permissions: state.modifiedData
};
},
resetForm () {
dispatch({
type: 'ON_RESET'
});
},
setFormAfterSubmit () {
dispatch({
type: 'ON_SUBMIT_SUCCEEDED'
});
}
}));
const handleChange = ({ target: { name, value } })=>dispatch({
type: 'ON_CHANGE',
keys: name.split('.'),
value: value === 'empty__string_value' ? '' : value
});
const handleChangeSelectAll = ({ target: { name, value } })=>dispatch({
type: 'ON_CHANGE_SELECT_ALL',
keys: name.split('.'),
value
});
const handleSelectedAction = (actionToSelect)=>dispatch({
type: 'SELECT_ACTION',
actionToSelect
});
const providerValue = {
...state,
onChange: handleChange,
onChangeSelectAll: handleChangeSelectAll,
onSelectedAction: handleSelectedAction
};
return /*#__PURE__*/ jsx(UsersPermissionsProvider, {
value: providerValue,
children: /*#__PURE__*/ jsxs(Grid.Root, {
gap: 0,
shadow: "filterShadow",
hasRadius: true,
background: "neutral0",
children: [
/*#__PURE__*/ jsx(Grid.Item, {
col: 7,
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
gap: 6,
children: [
/*#__PURE__*/ jsxs(Flex, {
direction: "column",
alignItems: "stretch",
gap: 2,
children: [
/*#__PURE__*/ jsx(Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: getTrad('Plugins.header.title'),
defaultMessage: 'Permissions'
})
}),
/*#__PURE__*/ jsx(Typography, {
tag: "p",
textColor: "neutral600",
children: formatMessage({
id: getTrad('Plugins.header.description'),
defaultMessage: 'Only actions bound by a route are listed below.'
})
})
]
}),
/*#__PURE__*/ jsx(Permissions, {})
]
})
}),
/*#__PURE__*/ jsx(Policies, {})
]
})
});
});
UsersPermissions.propTypes = {
permissions: PropTypes.object.isRequired,
routes: PropTypes.object.isRequired
};
var UsersPermissions$1 = /*#__PURE__*/ memo(UsersPermissions);
export { UsersPermissions$1 as default };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
'use strict';
const init = (state, permissions, routes)=>{
return {
...state,
initialData: permissions,
modifiedData: permissions,
routes
};
};
module.exports = init;
//# sourceMappingURL=init.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"init.js","sources":["../../../../admin/src/components/UsersPermissions/init.js"],"sourcesContent":["const init = (state, permissions, routes) => {\n return {\n ...state,\n initialData: permissions,\n modifiedData: permissions,\n routes,\n };\n};\n\nexport default init;\n"],"names":["init","state","permissions","routes","initialData","modifiedData"],"mappings":";;AAAMA,MAAAA,IAAAA,GAAO,CAACC,KAAAA,EAAOC,WAAaC,EAAAA,MAAAA,GAAAA;IAChC,OAAO;AACL,QAAA,GAAGF,KAAK;QACRG,WAAaF,EAAAA,WAAAA;QACbG,YAAcH,EAAAA,WAAAA;AACdC,QAAAA;AACF,KAAA;AACF;;;;"}

View File

@@ -0,0 +1,11 @@
const init = (state, permissions, routes)=>{
return {
...state,
initialData: permissions,
modifiedData: permissions,
routes
};
};
export { init as default };
//# sourceMappingURL=init.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"init.mjs","sources":["../../../../admin/src/components/UsersPermissions/init.js"],"sourcesContent":["const init = (state, permissions, routes) => {\n return {\n ...state,\n initialData: permissions,\n modifiedData: permissions,\n routes,\n };\n};\n\nexport default init;\n"],"names":["init","state","permissions","routes","initialData","modifiedData"],"mappings":"AAAMA,MAAAA,IAAAA,GAAO,CAACC,KAAAA,EAAOC,WAAaC,EAAAA,MAAAA,GAAAA;IAChC,OAAO;AACL,QAAA,GAAGF,KAAK;QACRG,WAAaF,EAAAA,WAAAA;QACbG,YAAcH,EAAAA,WAAAA;AACdC,QAAAA;AACF,KAAA;AACF;;;;"}

View File

@@ -0,0 +1,73 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var immer = require('immer');
var get = require('lodash/get');
var set = require('lodash/set');
var take = require('lodash/take');
const initialState = {
initialData: {},
modifiedData: {},
routes: {},
selectedAction: '',
policies: []
};
const reducer = (state, action)=>immer.produce(state, (draftState)=>{
switch(action.type){
case 'ON_CHANGE':
{
const keysLength = action.keys.length;
const isChangingCheckbox = action.keys[keysLength - 1] === 'enabled';
if (action.value && isChangingCheckbox) {
const selectedAction = take(action.keys, keysLength - 1).join('.');
draftState.selectedAction = selectedAction;
}
set(draftState, [
'modifiedData',
...action.keys
], action.value);
break;
}
case 'ON_CHANGE_SELECT_ALL':
{
const pathToValue = [
'modifiedData',
...action.keys
];
const oldValues = get(state, pathToValue, {});
const updatedValues = Object.keys(oldValues).reduce((acc, current)=>{
acc[current] = {
...oldValues[current],
enabled: action.value
};
return acc;
}, {});
set(draftState, pathToValue, updatedValues);
break;
}
case 'ON_RESET':
{
draftState.modifiedData = state.initialData;
break;
}
case 'ON_SUBMIT_SUCCEEDED':
{
draftState.initialData = state.modifiedData;
break;
}
case 'SELECT_ACTION':
{
const { actionToSelect } = action;
draftState.selectedAction = actionToSelect === state.selectedAction ? '' : actionToSelect;
break;
}
default:
return draftState;
}
});
exports.default = reducer;
exports.initialState = initialState;
//# sourceMappingURL=reducer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reducer.js","sources":["../../../../admin/src/components/UsersPermissions/reducer.js"],"sourcesContent":["/* eslint-disable consistent-return */\nimport { produce } from 'immer';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\nimport take from 'lodash/take';\n\nexport const initialState = {\n initialData: {},\n modifiedData: {},\n routes: {},\n selectedAction: '',\n policies: [],\n};\n\nconst reducer = (state, action) =>\n produce(state, (draftState) => {\n switch (action.type) {\n case 'ON_CHANGE': {\n const keysLength = action.keys.length;\n const isChangingCheckbox = action.keys[keysLength - 1] === 'enabled';\n\n if (action.value && isChangingCheckbox) {\n const selectedAction = take(action.keys, keysLength - 1).join('.');\n draftState.selectedAction = selectedAction;\n }\n\n set(draftState, ['modifiedData', ...action.keys], action.value);\n break;\n }\n case 'ON_CHANGE_SELECT_ALL': {\n const pathToValue = ['modifiedData', ...action.keys];\n const oldValues = get(state, pathToValue, {});\n const updatedValues = Object.keys(oldValues).reduce((acc, current) => {\n acc[current] = { ...oldValues[current], enabled: action.value };\n\n return acc;\n }, {});\n\n set(draftState, pathToValue, updatedValues);\n\n break;\n }\n case 'ON_RESET': {\n draftState.modifiedData = state.initialData;\n break;\n }\n case 'ON_SUBMIT_SUCCEEDED': {\n draftState.initialData = state.modifiedData;\n break;\n }\n\n case 'SELECT_ACTION': {\n const { actionToSelect } = action;\n draftState.selectedAction = actionToSelect === state.selectedAction ? '' : actionToSelect;\n break;\n }\n default:\n return draftState;\n }\n });\n\nexport default reducer;\n"],"names":["initialState","initialData","modifiedData","routes","selectedAction","policies","reducer","state","action","produce","draftState","type","keysLength","keys","length","isChangingCheckbox","value","take","join","set","pathToValue","oldValues","get","updatedValues","Object","reduce","acc","current","enabled","actionToSelect"],"mappings":";;;;;;;;;MAMaA,YAAe,GAAA;AAC1BC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,YAAAA,EAAc,EAAC;AACfC,IAAAA,MAAAA,EAAQ,EAAC;IACTC,cAAgB,EAAA,EAAA;AAChBC,IAAAA,QAAAA,EAAU;AACZ;AAEA,MAAMC,UAAU,CAACC,KAAAA,EAAOC,MACtBC,GAAAA,aAAAA,CAAQF,OAAO,CAACG,UAAAA,GAAAA;AACd,QAAA,OAAQF,OAAOG,IAAI;YACjB,KAAK,WAAA;AAAa,gBAAA;AAChB,oBAAA,MAAMC,UAAaJ,GAAAA,MAA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A;AAAuB,gBAAA;oBAC1BS,UAAWT,CAAAA,WAAW,GAAGM,KAAAA,CAAML,YAAY;AAC3C,oBAAA;AACF;YAEA,KAAK,eAAA;AAAiB,gBAAA;oBACpB,MAAM,EAAE2B,cAAc,EAAE,GAAGrB,MAAAA;AAC3BE,oBAAAA,UAAAA,CAAWN,cAAc,GAAGyB,cAAAA,KAAmBtB,KAAMH,CAAAA,cAAc,GAAG,EAAKyB,GAAAA,cAAAA;AAC3E,oBAAA;AACF;AACA,YAAA;gBACE,OAAOnB,UAAAA;AACX;AACF,KAAA;;;;;"}

View File

@@ -0,0 +1,68 @@
import { produce } from 'immer';
import get from 'lodash/get';
import set from 'lodash/set';
import take from 'lodash/take';
const initialState = {
initialData: {},
modifiedData: {},
routes: {},
selectedAction: '',
policies: []
};
const reducer = (state, action)=>produce(state, (draftState)=>{
switch(action.type){
case 'ON_CHANGE':
{
const keysLength = action.keys.length;
const isChangingCheckbox = action.keys[keysLength - 1] === 'enabled';
if (action.value && isChangingCheckbox) {
const selectedAction = take(action.keys, keysLength - 1).join('.');
draftState.selectedAction = selectedAction;
}
set(draftState, [
'modifiedData',
...action.keys
], action.value);
break;
}
case 'ON_CHANGE_SELECT_ALL':
{
const pathToValue = [
'modifiedData',
...action.keys
];
const oldValues = get(state, pathToValue, {});
const updatedValues = Object.keys(oldValues).reduce((acc, current)=>{
acc[current] = {
...oldValues[current],
enabled: action.value
};
return acc;
}, {});
set(draftState, pathToValue, updatedValues);
break;
}
case 'ON_RESET':
{
draftState.modifiedData = state.initialData;
break;
}
case 'ON_SUBMIT_SUCCEEDED':
{
draftState.initialData = state.modifiedData;
break;
}
case 'SELECT_ACTION':
{
const { actionToSelect } = action;
draftState.selectedAction = actionToSelect === state.selectedAction ? '' : actionToSelect;
break;
}
default:
return draftState;
}
});
export { reducer as default, initialState };
//# sourceMappingURL=reducer.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"reducer.mjs","sources":["../../../../admin/src/components/UsersPermissions/reducer.js"],"sourcesContent":["/* eslint-disable consistent-return */\nimport { produce } from 'immer';\nimport get from 'lodash/get';\nimport set from 'lodash/set';\nimport take from 'lodash/take';\n\nexport const initialState = {\n initialData: {},\n modifiedData: {},\n routes: {},\n selectedAction: '',\n policies: [],\n};\n\nconst reducer = (state, action) =>\n produce(state, (draftState) => {\n switch (action.type) {\n case 'ON_CHANGE': {\n const keysLength = action.keys.length;\n const isChangingCheckbox = action.keys[keysLength - 1] === 'enabled';\n\n if (action.value && isChangingCheckbox) {\n const selectedAction = take(action.keys, keysLength - 1).join('.');\n draftState.selectedAction = selectedAction;\n }\n\n set(draftState, ['modifiedData', ...action.keys], action.value);\n break;\n }\n case 'ON_CHANGE_SELECT_ALL': {\n const pathToValue = ['modifiedData', ...action.keys];\n const oldValues = get(state, pathToValue, {});\n const updatedValues = Object.keys(oldValues).reduce((acc, current) => {\n acc[current] = { ...oldValues[current], enabled: action.value };\n\n return acc;\n }, {});\n\n set(draftState, pathToValue, updatedValues);\n\n break;\n }\n case 'ON_RESET': {\n draftState.modifiedData = state.initialData;\n break;\n }\n case 'ON_SUBMIT_SUCCEEDED': {\n draftState.initialData = state.modifiedData;\n break;\n }\n\n case 'SELECT_ACTION': {\n const { actionToSelect } = action;\n draftState.selectedAction = actionToSelect === state.selectedAction ? '' : actionToSelect;\n break;\n }\n default:\n return draftState;\n }\n });\n\nexport default reducer;\n"],"names":["initialState","initialData","modifiedData","routes","selectedAction","policies","reducer","state","action","produce","draftState","type","keysLength","keys","length","isChangingCheckbox","value","take","join","set","pathToValue","oldValues","get","updatedValues","Object","reduce","acc","current","enabled","actionToSelect"],"mappings":";;;;;MAMaA,YAAe,GAAA;AAC1BC,IAAAA,WAAAA,EAAa,EAAC;AACdC,IAAAA,YAAAA,EAAc,EAAC;AACfC,IAAAA,MAAAA,EAAQ,EAAC;IACTC,cAAgB,EAAA,EAAA;AAChBC,IAAAA,QAAAA,EAAU;AACZ;AAEA,MAAMC,UAAU,CAACC,KAAAA,E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