update strapi to 4.11.3
This commit is contained in:
parent
16e8335727
commit
879a6dddfc
|
@ -1,3 +1,5 @@
|
|||
tunnel.conf
|
||||
|
||||
############################
|
||||
# OS X
|
||||
############################
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"latest": "4.11.1",
|
||||
"lastUpdateCheck": 1686791571051,
|
||||
"lastNotification": 1686696427587
|
||||
"latest": "4.11.3",
|
||||
"lastUpdateCheck": 1687984126998,
|
||||
"lastNotification": 1687550765177
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
yarnPath: .yarn/releases/yarn-1.22.19.cjs
|
|
@ -59,4 +59,17 @@ module.exports = ({
|
|||
},
|
||||
},
|
||||
},
|
||||
"users-permissions": {
|
||||
config: {
|
||||
register: {
|
||||
allowedFields: [
|
||||
"isNamePublic",
|
||||
"isLinkPublic",
|
||||
"avatar",
|
||||
"vanityLink",
|
||||
"patreonBenefits"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
. .env
|
||||
|
||||
#docker run -it --name strapi-postgres-14.7_b -p 5432:5432 -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD postgres:14.7
|
||||
docker start strapi-postgres-14.7
|
||||
docker run -it --name strapi-postgres-14.7_b -p 5432:5432 -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD postgres:14.7
|
||||
#docker start strapi-postgres-14.7
|
||||
|
|
69
package.json
69
package.json
|
@ -13,17 +13,59 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@11ty/eleventy-fetch": "^4.0.0",
|
||||
"@aws-sdk/client-s3": "^3.360.0",
|
||||
"@esm2cjs/execa": "6.1.1-cjs.1",
|
||||
"@mux/mux-node": "^7.3.0",
|
||||
"@strapi/plugin-graphql": "4.9.0",
|
||||
"@strapi/plugin-i18n": "4.9.0",
|
||||
"@strapi/plugin-users-permissions": "4.9.0",
|
||||
"@strapi/provider-email-sendgrid": "^4.9.1",
|
||||
"@strapi/provider-upload-cloudinary": "^4.9.0",
|
||||
"@strapi/strapi": "4.9.0",
|
||||
"@strapi/utils": "^4.9.0",
|
||||
"@radix-ui/react-use-callback-ref": "^1.0.1",
|
||||
"@strapi/plugin-i18n": "4.11.3",
|
||||
"@strapi/plugin-users-permissions": "4.11.3",
|
||||
"@strapi/provider-email-sendgrid": "4.11.3",
|
||||
"@strapi/provider-upload-cloudinary": "4.11.3",
|
||||
"@strapi/strapi": "4.11.3",
|
||||
"@strapi/utils": "4.11.3",
|
||||
"@testing-library/dom": "8.19.0",
|
||||
"@testing-library/react": "12.1.4",
|
||||
"@testing-library/react-hooks": "8.0.1",
|
||||
"@testing-library/user-event": "14.4.3",
|
||||
"bcryptjs": "2.4.3",
|
||||
"better-sqlite3": "8.0.1",
|
||||
"pg": "^8.10.0",
|
||||
"strapi-plugin-fuzzy-search": "^1.11.0-beta.1"
|
||||
"codemirror": "^6.0.1",
|
||||
"css-loader": "^6.8.1",
|
||||
"cuid": "^3.0.0",
|
||||
"formik": "2.2.9",
|
||||
"grant-koa": "5.4.8",
|
||||
"history": "^4.10.1",
|
||||
"immer": "9.0.19",
|
||||
"jsonwebtoken": "9.0.0",
|
||||
"jwk-to-pem": "2.0.5",
|
||||
"koa": "^2.14.2",
|
||||
"koa2-ratelimit": "^1.1.3",
|
||||
"lodash": "4.17.21",
|
||||
"match-sorter": "^4.2.1",
|
||||
"msw": "1.0.1",
|
||||
"node-abort-controller": "^3.1.1",
|
||||
"object-assign": "^4.1.1",
|
||||
"pg": "^8.11.1",
|
||||
"prop-types": "^15.8.1",
|
||||
"purest": "4.0.2",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-intl": "6.3.2",
|
||||
"react-query": "3.24.3",
|
||||
"react-redux": "8.0.5",
|
||||
"react-router-dom": "5.3.4",
|
||||
"react-test-renderer": "^17.0.2",
|
||||
"semver": "^7.5.3",
|
||||
"sharp": "^0.32.1",
|
||||
"strapi-plugin-fuzzy-search": "^1.11.0",
|
||||
"styled-components": "5.3.3",
|
||||
"typescript": "^5.1.3",
|
||||
"url-join": "4.0.1",
|
||||
"yallist": "^4.0.0",
|
||||
"yup": "^0.32.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"concurrently": "^8.2.0"
|
||||
},
|
||||
"author": {
|
||||
"name": "CJ_Clippy"
|
||||
|
@ -36,12 +78,5 @@
|
|||
"npm": ">=6.0.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"packageManager": "yarn@1.22.19",
|
||||
"devDependencies": {
|
||||
"@aws-sdk/client-s3": "^3.329.0",
|
||||
"@esm2cjs/execa": "6.1.1-cjs.1",
|
||||
"concurrently": "^8.0.1",
|
||||
"cuid": "^3.0.0",
|
||||
"node-abort-controller": "^3.1.1"
|
||||
}
|
||||
"packageManager": "yarn@1.22.19"
|
||||
}
|
||||
|
|
12157
pnpm-lock.yaml
12157
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +1,12 @@
|
|||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Flex, Box, Typography } from '@strapi/design-system';
|
||||
|
||||
import { Box, Flex, Typography } from '@strapi/design-system';
|
||||
import map from 'lodash/map';
|
||||
import tail from 'lodash/tail';
|
||||
import { useIntl } from 'react-intl';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import getMethodColor from './getMethodColor';
|
||||
|
||||
const MethodBox = styled(Box)`
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { ToggleInput, TextInput } from '@strapi/design-system';
|
||||
|
||||
import { TextInput, ToggleInput } from '@strapi/design-system';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
const Input = ({
|
||||
description,
|
||||
|
@ -23,7 +24,9 @@ const Input = ({
|
|||
}) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const inputValue =
|
||||
name === 'noName' ? `${strapi.backendURL}/api/connect/${providerToEditName}/callback` : value;
|
||||
name === 'noName'
|
||||
? `${window.strapi.backendURL}/api/connect/${providerToEditName}/callback`
|
||||
: value;
|
||||
|
||||
const label = formatMessage(
|
||||
{ id: intlLabel.id, defaultMessage: intlLabel.defaultMessage },
|
||||
|
|
|
@ -5,22 +5,23 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Flex,
|
||||
Breadcrumbs,
|
||||
Crumb,
|
||||
Grid,
|
||||
GridItem,
|
||||
ModalLayout,
|
||||
ModalHeader,
|
||||
ModalFooter,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalLayout,
|
||||
} from '@strapi/design-system';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Formik } from 'formik';
|
||||
import { Breadcrumbs, Crumb } from '@strapi/design-system/v2';
|
||||
import { Form } from '@strapi/helper-plugin';
|
||||
import { Formik } from 'formik';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import Input from './Input';
|
||||
|
||||
const FormModal = ({
|
||||
|
@ -43,8 +44,10 @@ const FormModal = ({
|
|||
<ModalLayout onClose={onToggle} labelledBy="title">
|
||||
<ModalHeader>
|
||||
<Breadcrumbs label={headerBreadcrumbs.join(', ')}>
|
||||
{headerBreadcrumbs.map((crumb) => (
|
||||
<Crumb key={crumb}>{crumb}</Crumb>
|
||||
{headerBreadcrumbs.map((crumb, index, arr) => (
|
||||
<Crumb isCurrent={index === arr.length - 1} key={crumb}>
|
||||
{crumb}
|
||||
</Crumb>
|
||||
))}
|
||||
</Breadcrumbs>
|
||||
</ModalHeader>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import styled, { css } from 'styled-components';
|
||||
import { Box } from '@strapi/design-system';
|
||||
import styled, { css } from 'styled-components';
|
||||
|
||||
const activeCheckboxWrapperStyles = css`
|
||||
background: ${(props) => props.theme.colors.primary100};
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
import React, { useCallback, useMemo } from 'react';
|
||||
import get from 'lodash/get';
|
||||
import styled from 'styled-components';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Box, Checkbox, Flex, Typography, Grid, GridItem } from '@strapi/design-system';
|
||||
|
||||
import {
|
||||
Box,
|
||||
Checkbox,
|
||||
Flex,
|
||||
Typography,
|
||||
Grid,
|
||||
GridItem,
|
||||
VisuallyHidden,
|
||||
} from '@strapi/design-system';
|
||||
import { Cog as CogIcon } from '@strapi/icons';
|
||||
import get from 'lodash/get';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
import CheckboxWrapper from './CheckboxWrapper';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { useUsersPermissions } from '../../../contexts/UsersPermissionsContext';
|
||||
|
||||
import CheckboxWrapper from './CheckboxWrapper';
|
||||
|
||||
const Border = styled.div`
|
||||
flex: 1;
|
||||
align-self: center;
|
||||
|
@ -87,10 +98,20 @@ const SubCategory = ({ subCategory }) => {
|
|||
</Checkbox>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="action-cog"
|
||||
onClick={() => onSelectedAction(action.name)}
|
||||
style={{ display: 'inline-flex', alignItems: 'center' }}
|
||||
>
|
||||
<VisuallyHidden as="span">
|
||||
{formatMessage(
|
||||
{
|
||||
id: 'app.utils.show-bound-route',
|
||||
defaultMessage: 'Show bound route for {route}',
|
||||
},
|
||||
{
|
||||
route: action.name,
|
||||
}
|
||||
)}
|
||||
</VisuallyHidden>
|
||||
<CogIcon />
|
||||
</button>
|
||||
</CheckboxWrapper>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
|
||||
import { Box } from '@strapi/design-system';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import SubCategory from './SubCategory';
|
||||
|
||||
const PermissionRow = ({ name, permissions }) => {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import React, { useReducer } from 'react';
|
||||
import { Accordion, AccordionToggle, AccordionContent, Box, Flex } from '@strapi/design-system';
|
||||
|
||||
import { Accordion, AccordionContent, AccordionToggle, Box, Flex } from '@strapi/design-system';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
||||
import formatPluginName from '../../utils/formatPluginName';
|
||||
import PermissionRow from './PermissionRow';
|
||||
|
||||
import init from './init';
|
||||
import PermissionRow from './PermissionRow';
|
||||
import { initialState, reducer } from './reducer';
|
||||
|
||||
const Permissions = () => {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import React from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { Typography, Flex, GridItem } from '@strapi/design-system';
|
||||
|
||||
import { Flex, GridItem, 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';
|
||||
import BoundRoute from '../BoundRoute';
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import React, { memo, useReducer, forwardRef, useImperativeHandle } from 'react';
|
||||
import React, { forwardRef, memo, useImperativeHandle, useReducer } from 'react';
|
||||
|
||||
import { Flex, Grid, GridItem, Typography } from '@strapi/design-system';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Typography, Flex, Grid, GridItem } from '@strapi/design-system';
|
||||
import { useIntl } from 'react-intl';
|
||||
import getTrad from '../../utils/getTrad';
|
||||
import Policies from '../Policies';
|
||||
import Permissions from '../Permissions';
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
import { UsersPermissionsProvider } from '../../contexts/UsersPermissionsContext';
|
||||
import getTrad from '../../utils/getTrad';
|
||||
import Permissions from '../Permissions';
|
||||
import Policies from '../Policies';
|
||||
|
||||
import init from './init';
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React, { createContext, useContext } from 'react';
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
const UsersPermissions = createContext({});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// eslint-disable-next-line import/prefer-default-export
|
||||
export { default as useForm } from './useForm';
|
||||
export { default as useRolesList } from './useRolesList';
|
||||
export { default as usePlugins } from './usePlugins';
|
||||
export * from './usePlugins';
|
||||
export { default as useFetchRole } from './useFetchRole';
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { useCallback, useReducer, useEffect, useRef } from 'react';
|
||||
import { useNotification, useFetchClient } from '@strapi/helper-plugin';
|
||||
import reducer, { initialState } from './reducer';
|
||||
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
||||
|
||||
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
|
||||
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
const useFetchRole = (id) => {
|
||||
const [state, dispatch] = useReducer(reducer, initialState);
|
||||
const toggleNotification = useNotification();
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
||||
import { useRBAC, request, useNotification } from '@strapi/helper-plugin';
|
||||
|
||||
import { useFetchClient, useNotification, useRBAC } from '@strapi/helper-plugin';
|
||||
|
||||
import { getRequestURL } from '../../utils';
|
||||
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
const useUserForm = (endPoint, permissions) => {
|
||||
|
@ -9,8 +12,7 @@ const useUserForm = (endPoint, permissions) => {
|
|||
const toggleNotification = useNotification();
|
||||
const isMounted = useRef(true);
|
||||
|
||||
const abortController = new AbortController();
|
||||
const { signal } = abortController;
|
||||
const { get } = useFetchClient();
|
||||
|
||||
useEffect(() => {
|
||||
const getData = async () => {
|
||||
|
@ -19,7 +21,7 @@ const useUserForm = (endPoint, permissions) => {
|
|||
type: 'GET_DATA',
|
||||
});
|
||||
|
||||
const data = await request(getRequestURL(endPoint), { method: 'GET', signal });
|
||||
const { data } = await get(getRequestURL(endPoint));
|
||||
|
||||
dispatch({
|
||||
type: 'GET_DATA_SUCCEEDED',
|
||||
|
@ -45,11 +47,9 @@ const useUserForm = (endPoint, permissions) => {
|
|||
}
|
||||
|
||||
return () => {
|
||||
abortController.abort();
|
||||
isMounted.current = false;
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isLoadingForPermissions, endPoint]);
|
||||
}, [isLoadingForPermissions, endPoint, get, toggleNotification]);
|
||||
|
||||
const dispatchSubmitSucceeded = useCallback((data) => {
|
||||
dispatch({
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
import { useNotification, useFetchClient, useAPIErrorHandler } from '@strapi/helper-plugin';
|
||||
import { useQueries } from 'react-query';
|
||||
|
||||
import pluginId from '../pluginId';
|
||||
import { cleanPermissions, getTrad } from '../utils';
|
||||
|
||||
export 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: [pluginId, 'permissions'],
|
||||
async queryFn() {
|
||||
const res = await get(`/${pluginId}/permissions`);
|
||||
|
||||
return res.data.permissions;
|
||||
},
|
||||
},
|
||||
{
|
||||
queryKey: [pluginId, 'routes'],
|
||||
async queryFn() {
|
||||
const res = await get(`/${pluginId}/routes`);
|
||||
|
||||
return res.data.routes;
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const refetchQueries = async () => {
|
||||
await Promise.all([refetchPermissions(), refetchRoutes()]);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (permissionsError) {
|
||||
toggleNotification({
|
||||
type: 'warning',
|
||||
message: formatAPIError(permissionsError),
|
||||
});
|
||||
}
|
||||
}, [toggleNotification, permissionsError, formatAPIError]);
|
||||
|
||||
useEffect(() => {
|
||||
if (routesError) {
|
||||
toggleNotification({
|
||||
type: 'warning',
|
||||
message: formatAPIError(routesError),
|
||||
});
|
||||
}
|
||||
}, [toggleNotification, routesError, formatAPIError]);
|
||||
|
||||
const isLoading = isLoadingPermissions || isLoadingRoutes;
|
||||
|
||||
return {
|
||||
permissions: permissions ? cleanPermissions(permissions) : {},
|
||||
routes: routes ?? {},
|
||||
getData: refetchQueries,
|
||||
isLoading,
|
||||
};
|
||||
};
|
|
@ -1,67 +0,0 @@
|
|||
import { useCallback, useEffect, useReducer } from 'react';
|
||||
import { useNotification, useFetchClient } from '@strapi/helper-plugin';
|
||||
import get from 'lodash/get';
|
||||
import init from './init';
|
||||
import pluginId from '../../pluginId';
|
||||
import { cleanPermissions } from '../../utils';
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
const usePlugins = (shouldFetchData = true) => {
|
||||
const toggleNotification = useNotification();
|
||||
const [{ permissions, routes, isLoading }, dispatch] = useReducer(reducer, initialState, () =>
|
||||
init(initialState, shouldFetchData)
|
||||
);
|
||||
const fetchClient = useFetchClient();
|
||||
|
||||
const fetchPlugins = useCallback(async () => {
|
||||
try {
|
||||
dispatch({
|
||||
type: 'GET_DATA',
|
||||
});
|
||||
|
||||
const [{ permissions }, { routes }] = await Promise.all(
|
||||
[`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
|
||||
const res = await fetchClient.get(endpoint);
|
||||
|
||||
return res.data;
|
||||
})
|
||||
);
|
||||
|
||||
dispatch({
|
||||
type: 'GET_DATA_SUCCEEDED',
|
||||
permissions: cleanPermissions(permissions),
|
||||
routes,
|
||||
});
|
||||
} catch (err) {
|
||||
const message = get(err, ['response', 'payload', 'message'], 'An error occured');
|
||||
|
||||
dispatch({
|
||||
type: 'GET_DATA_ERROR',
|
||||
});
|
||||
|
||||
if (message !== 'Forbidden') {
|
||||
toggleNotification({
|
||||
type: 'warning',
|
||||
message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [toggleNotification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldFetchData) {
|
||||
fetchPlugins();
|
||||
}
|
||||
}, [fetchPlugins, shouldFetchData]);
|
||||
|
||||
return {
|
||||
permissions,
|
||||
routes,
|
||||
getData: fetchPlugins,
|
||||
isLoading,
|
||||
};
|
||||
};
|
||||
|
||||
export default usePlugins;
|
|
@ -1,5 +0,0 @@
|
|||
const init = (initialState, shouldFetchData) => {
|
||||
return { ...initialState, isLoading: shouldFetchData };
|
||||
};
|
||||
|
||||
export default init;
|
|
@ -1,34 +0,0 @@
|
|||
/* eslint-disable consistent-return */
|
||||
import produce from 'immer';
|
||||
|
||||
export const initialState = {
|
||||
permissions: {},
|
||||
routes: {},
|
||||
isLoading: true,
|
||||
};
|
||||
|
||||
const reducer = (state, action) =>
|
||||
produce(state, (draftState) => {
|
||||
switch (action.type) {
|
||||
case 'GET_DATA': {
|
||||
draftState.isLoading = true;
|
||||
draftState.permissions = {};
|
||||
draftState.routes = {};
|
||||
break;
|
||||
}
|
||||
case 'GET_DATA_SUCCEEDED': {
|
||||
draftState.permissions = action.permissions;
|
||||
draftState.routes = action.routes;
|
||||
draftState.isLoading = false;
|
||||
break;
|
||||
}
|
||||
case 'GET_DATA_ERROR': {
|
||||
draftState.isLoading = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return draftState;
|
||||
}
|
||||
});
|
||||
|
||||
export default reducer;
|
|
@ -1,8 +1,11 @@
|
|||
import { useEffect, useReducer, useRef } from 'react';
|
||||
import { request, useNotification } from '@strapi/helper-plugin';
|
||||
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
||||
|
||||
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
|
||||
import get from 'lodash/get';
|
||||
import init from './init';
|
||||
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
import init from './init';
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
const useRolesList = (shouldFetchData = true) => {
|
||||
|
@ -12,28 +15,17 @@ const useRolesList = (shouldFetchData = true) => {
|
|||
const toggleNotification = useNotification();
|
||||
|
||||
const isMounted = useRef(true);
|
||||
const abortController = new AbortController();
|
||||
const { signal } = abortController;
|
||||
const fetchClient = useFetchClient();
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldFetchData) {
|
||||
fetchRolesList();
|
||||
}
|
||||
|
||||
return () => {
|
||||
abortController.abort();
|
||||
isMounted.current = false;
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [shouldFetchData]);
|
||||
|
||||
const fetchRolesList = async () => {
|
||||
const fetchRolesList = useCallback(async () => {
|
||||
try {
|
||||
dispatch({
|
||||
type: 'GET_DATA',
|
||||
});
|
||||
|
||||
const { roles } = await request(`/${pluginId}/roles`, { method: 'GET', signal });
|
||||
const {
|
||||
data: { roles },
|
||||
} = await fetchClient.get(`/${pluginId}/roles`);
|
||||
|
||||
dispatch({
|
||||
type: 'GET_DATA_SUCCEEDED',
|
||||
|
@ -55,7 +47,17 @@ const useRolesList = (shouldFetchData = true) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}, [fetchClient, toggleNotification]);
|
||||
|
||||
useEffect(() => {
|
||||
if (shouldFetchData) {
|
||||
fetchRolesList();
|
||||
}
|
||||
|
||||
return () => {
|
||||
isMounted.current = false;
|
||||
};
|
||||
}, [shouldFetchData, fetchRolesList]);
|
||||
|
||||
return { roles, isLoading, getData: fetchRolesList };
|
||||
};
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
|
||||
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
|
||||
import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
||||
|
||||
import pluginPkg from '../../package.json';
|
||||
|
||||
import pluginPermissions from './permissions';
|
||||
import pluginId from './pluginId';
|
||||
import getTrad from './utils/getTrad';
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
import React, { useMemo } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { Formik } from 'formik';
|
||||
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
ContentLayout,
|
||||
Flex,
|
||||
Grid,
|
||||
GridItem,
|
||||
HeaderLayout,
|
||||
Main,
|
||||
Option,
|
||||
Select,
|
||||
Typography,
|
||||
useNotifyAT,
|
||||
} from '@strapi/design-system';
|
||||
import {
|
||||
CheckPagePermissions,
|
||||
Form,
|
||||
|
@ -13,26 +25,17 @@ import {
|
|||
useOverlayBlocker,
|
||||
useRBAC,
|
||||
} from '@strapi/helper-plugin';
|
||||
import {
|
||||
useNotifyAT,
|
||||
Main,
|
||||
HeaderLayout,
|
||||
ContentLayout,
|
||||
Button,
|
||||
Box,
|
||||
Flex,
|
||||
Select,
|
||||
Option,
|
||||
Typography,
|
||||
Grid,
|
||||
GridItem,
|
||||
} from '@strapi/design-system';
|
||||
import { Check } from '@strapi/icons';
|
||||
import { Formik } from 'formik';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
|
||||
import pluginPermissions from '../../permissions';
|
||||
import { getTrad } from '../../utils';
|
||||
|
||||
import { fetchData, putAdvancedSettings } from './utils/api';
|
||||
import layout from './utils/layout';
|
||||
import schema from './utils/schema';
|
||||
import { fetchData, putAdvancedSettings } from './utils/api';
|
||||
|
||||
const ProtectedAdvancedSettingsPage = () => (
|
||||
<CheckPagePermissions permissions={pluginPermissions.readAdvancedSettings}>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { getFetchClient } from '@strapi/helper-plugin';
|
||||
|
||||
import { getRequestURL } from '../../../utils';
|
||||
|
||||
const fetchData = async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
import * as yup from 'yup';
|
||||
|
||||
// eslint-disable-next-line prefer-regex-literals
|
||||
const URL_REGEX = new RegExp('(^$)|((.+:\\/\\/.*)(d*)\\/?(.*))');
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { Form, GenericInput } from '@strapi/helper-plugin';
|
||||
import { Formik } from 'formik';
|
||||
|
||||
import {
|
||||
ModalLayout,
|
||||
ModalHeader,
|
||||
ModalFooter,
|
||||
ModalBody,
|
||||
Button,
|
||||
Grid,
|
||||
GridItem,
|
||||
Button,
|
||||
Breadcrumbs,
|
||||
Crumb,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
ModalHeader,
|
||||
ModalLayout,
|
||||
Textarea,
|
||||
} from '@strapi/design-system';
|
||||
import { Breadcrumbs, Crumb } from '@strapi/design-system/v2';
|
||||
import { Form, GenericInput } from '@strapi/helper-plugin';
|
||||
import { Formik } from 'formik';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import { getTrad } from '../../../utils';
|
||||
import schema from '../utils/schema';
|
||||
|
||||
|
@ -45,7 +46,7 @@ const EmailForm = ({ template, onToggle, onSubmit }) => {
|
|||
defaultMessage: 'Edit email template',
|
||||
})}
|
||||
</Crumb>
|
||||
<Crumb>
|
||||
<Crumb isCurrent>
|
||||
{formatMessage({ id: getTrad(template.display), defaultMessage: template.display })}
|
||||
</Crumb>
|
||||
</Breadcrumbs>
|
||||
|
@ -120,7 +121,7 @@ const EmailForm = ({ template, onToggle, onSubmit }) => {
|
|||
id: getTrad('PopUpForm.Email.options.message.label'),
|
||||
defaultMessage: 'Message',
|
||||
})}
|
||||
name="options.message"
|
||||
id="options.message"
|
||||
onChange={handleChange}
|
||||
value={values.options.message}
|
||||
error={
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import {
|
||||
Icon,
|
||||
IconButton,
|
||||
Table,
|
||||
Thead,
|
||||
Tbody,
|
||||
Tr,
|
||||
Td,
|
||||
Th,
|
||||
Thead,
|
||||
Tr,
|
||||
Typography,
|
||||
IconButton,
|
||||
Icon,
|
||||
VisuallyHidden,
|
||||
} from '@strapi/design-system';
|
||||
import { Pencil, Refresh, Check } from '@strapi/icons';
|
||||
import { onRowClick, stopPropagation } from '@strapi/helper-plugin';
|
||||
import { Check, Pencil, Refresh } from '@strapi/icons';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import { getTrad } from '../../../utils';
|
||||
|
||||
const EmailTable = ({ canUpdate, onEditClick }) => {
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
import React, { useMemo, useRef, useState } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import { ContentLayout, HeaderLayout, Main, useNotifyAT } from '@strapi/design-system';
|
||||
import {
|
||||
CheckPagePermissions,
|
||||
LoadingIndicatorPage,
|
||||
SettingsPageTitle,
|
||||
useTracking,
|
||||
useFocusWhenNavigate,
|
||||
useNotification,
|
||||
useOverlayBlocker,
|
||||
CheckPagePermissions,
|
||||
useRBAC,
|
||||
useFocusWhenNavigate,
|
||||
LoadingIndicatorPage,
|
||||
useTracking,
|
||||
} from '@strapi/helper-plugin';
|
||||
import { useNotifyAT, Main, ContentLayout, HeaderLayout } from '@strapi/design-system';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
|
||||
import pluginPermissions from '../../permissions';
|
||||
import { getTrad } from '../../utils';
|
||||
import { fetchData, putEmailTemplate } from './utils/api';
|
||||
import EmailTable from './components/EmailTable';
|
||||
|
||||
import EmailForm from './components/EmailForm';
|
||||
import EmailTable from './components/EmailTable';
|
||||
import { fetchData, putEmailTemplate } from './utils/api';
|
||||
|
||||
const ProtectedEmailTemplatesPage = () => (
|
||||
<CheckPagePermissions permissions={pluginPermissions.readEmailTemplates}>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { getFetchClient } from '@strapi/helper-plugin';
|
||||
|
||||
import { getRequestURL } from '../../../utils';
|
||||
|
||||
const fetchData = async () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
import * as yup from 'yup';
|
||||
|
||||
const schema = yup.object().shape({
|
||||
options: yup
|
||||
|
|
|
@ -1,43 +1,46 @@
|
|||
import React, { useMemo, useRef, useState } from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
|
||||
import {
|
||||
SettingsPageTitle,
|
||||
LoadingIndicatorPage,
|
||||
useTracking,
|
||||
useNotification,
|
||||
useOverlayBlocker,
|
||||
CheckPagePermissions,
|
||||
useRBAC,
|
||||
useFocusWhenNavigate,
|
||||
onRowClick,
|
||||
stopPropagation,
|
||||
} from '@strapi/helper-plugin';
|
||||
import has from 'lodash/has';
|
||||
import upperFirst from 'lodash/upperFirst';
|
||||
import {
|
||||
HeaderLayout,
|
||||
Layout,
|
||||
ContentLayout,
|
||||
HeaderLayout,
|
||||
IconButton,
|
||||
Layout,
|
||||
Main,
|
||||
useNotifyAT,
|
||||
Table,
|
||||
Thead,
|
||||
Tr,
|
||||
Th,
|
||||
Tbody,
|
||||
Td,
|
||||
Th,
|
||||
Thead,
|
||||
Tr,
|
||||
Typography,
|
||||
IconButton,
|
||||
useNotifyAT,
|
||||
VisuallyHidden,
|
||||
} from '@strapi/design-system';
|
||||
import {
|
||||
CheckPagePermissions,
|
||||
LoadingIndicatorPage,
|
||||
onRowClick,
|
||||
SettingsPageTitle,
|
||||
stopPropagation,
|
||||
useFocusWhenNavigate,
|
||||
useNotification,
|
||||
useOverlayBlocker,
|
||||
useRBAC,
|
||||
useTracking,
|
||||
} from '@strapi/helper-plugin';
|
||||
import { Pencil } from '@strapi/icons';
|
||||
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
||||
import forms from './utils/forms';
|
||||
import has from 'lodash/has';
|
||||
import upperFirst from 'lodash/upperFirst';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
|
||||
import FormModal from '../../components/FormModal';
|
||||
import pluginPermissions from '../../permissions';
|
||||
import { getTrad } from '../../utils';
|
||||
|
||||
import { fetchData, putProvider } from './utils/api';
|
||||
import createProvidersArray from './utils/createProvidersArray';
|
||||
import { getTrad } from '../../utils';
|
||||
import pluginPermissions from '../../permissions';
|
||||
import FormModal from '../../components/FormModal';
|
||||
import forms from './utils/forms';
|
||||
|
||||
export const ProvidersPage = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { getFetchClient } from '@strapi/helper-plugin';
|
||||
|
||||
import { getRequestURL } from '../../../utils';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
import * as yup from 'yup';
|
||||
|
||||
import { getTrad } from '../../../utils';
|
||||
|
||||
|
@ -33,10 +33,6 @@ const secretLabel = {
|
|||
id: getTrad('PopUpForm.Providers.secret.label'),
|
||||
defaultMessage: 'Client Secret',
|
||||
};
|
||||
const benefitLabel = {
|
||||
id: getTrad('PopUpForm.Providers.enabled.benefit'),
|
||||
defaultMessage: 'Patreon Benefit ID',
|
||||
};
|
||||
|
||||
const forms = {
|
||||
email: {
|
||||
|
@ -119,17 +115,6 @@ const forms = {
|
|||
disabled: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
intlLabel: benefitLabel,
|
||||
placeholder: textPlaceholder,
|
||||
name: 'benefit',
|
||||
type: 'text',
|
||||
validations: {
|
||||
required: true,
|
||||
}
|
||||
}
|
||||
],
|
||||
],
|
||||
schema: yup.object().shape({
|
||||
enabled: yup.bool().required(translatedErrors.required),
|
||||
|
@ -148,11 +133,6 @@ const forms = {
|
|||
then: yup.string().required(translatedErrors.required),
|
||||
otherwise: yup.string(),
|
||||
}),
|
||||
benefit: yup.string().when('enabled', {
|
||||
is: true,
|
||||
then: yup.string().required(translatedErrors.required),
|
||||
otherwise: yup.string(),
|
||||
})
|
||||
}),
|
||||
},
|
||||
providersWithSubdomain: {
|
||||
|
@ -249,17 +229,6 @@ const forms = {
|
|||
disabled: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
intlLabel: benefitLabel,
|
||||
placeholder: textPlaceholder,
|
||||
name: 'benefit',
|
||||
type: 'text',
|
||||
validations: {
|
||||
required: true,
|
||||
}
|
||||
}
|
||||
],
|
||||
],
|
||||
schema: yup.object().shape({
|
||||
enabled: yup.bool().required(translatedErrors.required),
|
||||
|
@ -283,11 +252,6 @@ const forms = {
|
|||
then: yup.string().required(translatedErrors.required),
|
||||
otherwise: yup.string(),
|
||||
}),
|
||||
benefit: yup.string().when('enabled', {
|
||||
is: true,
|
||||
then: yup.string().required(translatedErrors.required),
|
||||
otherwise: yup.string(),
|
||||
}),
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,36 +1,39 @@
|
|||
import React, { useState, useRef } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import React, { useRef, useState } from 'react';
|
||||
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
ContentLayout,
|
||||
Flex,
|
||||
Grid,
|
||||
GridItem,
|
||||
HeaderLayout,
|
||||
Main,
|
||||
Button,
|
||||
Flex,
|
||||
Box,
|
||||
TextInput,
|
||||
Textarea,
|
||||
TextInput,
|
||||
Typography,
|
||||
GridItem,
|
||||
Grid,
|
||||
} from '@strapi/design-system';
|
||||
import {
|
||||
Form,
|
||||
SettingsPageTitle,
|
||||
useFetchClient,
|
||||
useNotification,
|
||||
useOverlayBlocker,
|
||||
useTracking,
|
||||
} from '@strapi/helper-plugin';
|
||||
import { Check } from '@strapi/icons';
|
||||
import { Formik } from 'formik';
|
||||
import { useIntl } from 'react-intl';
|
||||
import {
|
||||
useOverlayBlocker,
|
||||
SettingsPageTitle,
|
||||
useFetchClient,
|
||||
useTracking,
|
||||
Form,
|
||||
useNotification,
|
||||
} from '@strapi/helper-plugin';
|
||||
import UsersPermissions from '../../../components/UsersPermissions';
|
||||
import getTrad from '../../../utils/getTrad';
|
||||
import pluginId from '../../../pluginId';
|
||||
import { usePlugins } from '../../../hooks';
|
||||
import schema from './utils/schema';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
const EditPage = () => {
|
||||
import UsersPermissions from '../../components/UsersPermissions';
|
||||
import { usePlugins } from '../../hooks';
|
||||
import pluginId from '../../pluginId';
|
||||
import getTrad from '../../utils/getTrad';
|
||||
|
||||
import { createRoleSchema } from './constants';
|
||||
|
||||
const CreatePage = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const toggleNotification = useNotification();
|
||||
|
@ -82,7 +85,7 @@ const EditPage = () => {
|
|||
enableReinitialize
|
||||
initialValues={{ name: '', description: '' }}
|
||||
onSubmit={handleCreateRoleSubmit}
|
||||
validationSchema={schema}
|
||||
validationSchema={createRoleSchema}
|
||||
>
|
||||
{({ handleSubmit, values, handleChange, errors }) => (
|
||||
<Form noValidate onSubmit={handleSubmit}>
|
||||
|
@ -143,7 +146,7 @@ const EditPage = () => {
|
|||
</GridItem>
|
||||
<GridItem col={6}>
|
||||
<Textarea
|
||||
name="description"
|
||||
id="description"
|
||||
value={values.description || ''}
|
||||
onChange={handleChange}
|
||||
label={formatMessage({
|
||||
|
@ -179,4 +182,4 @@ const EditPage = () => {
|
|||
);
|
||||
};
|
||||
|
||||
export default EditPage;
|
||||
export default CreatePage;
|
|
@ -1,16 +1,5 @@
|
|||
import React, { useState, useRef } from 'react';
|
||||
import { Formik } from 'formik';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useRouteMatch } from 'react-router-dom';
|
||||
import {
|
||||
useFetchClient,
|
||||
useOverlayBlocker,
|
||||
SettingsPageTitle,
|
||||
LoadingIndicatorPage,
|
||||
Form,
|
||||
useNotification,
|
||||
Link,
|
||||
} from '@strapi/helper-plugin';
|
||||
import React, { useRef, useState } from 'react';
|
||||
|
||||
import {
|
||||
ContentLayout,
|
||||
HeaderLayout,
|
||||
|
@ -24,12 +13,26 @@ import {
|
|||
GridItem,
|
||||
Grid,
|
||||
} from '@strapi/design-system';
|
||||
import {
|
||||
useFetchClient,
|
||||
useOverlayBlocker,
|
||||
SettingsPageTitle,
|
||||
LoadingIndicatorPage,
|
||||
Form,
|
||||
useNotification,
|
||||
Link,
|
||||
} from '@strapi/helper-plugin';
|
||||
import { ArrowLeft, Check } from '@strapi/icons';
|
||||
import UsersPermissions from '../../../components/UsersPermissions';
|
||||
import getTrad from '../../../utils/getTrad';
|
||||
import pluginId from '../../../pluginId';
|
||||
import { usePlugins, useFetchRole } from '../../../hooks';
|
||||
import schema from './utils/schema';
|
||||
import { Formik } from 'formik';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useRouteMatch } from 'react-router-dom';
|
||||
|
||||
import UsersPermissions from '../../components/UsersPermissions';
|
||||
import { usePlugins, useFetchRole } from '../../hooks';
|
||||
import pluginId from '../../pluginId';
|
||||
import getTrad from '../../utils/getTrad';
|
||||
|
||||
import { createRoleSchema } from './constants';
|
||||
|
||||
const EditPage = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
@ -87,7 +90,7 @@ const EditPage = () => {
|
|||
enableReinitialize
|
||||
initialValues={{ name: role.name, description: role.description }}
|
||||
onSubmit={handleEditRoleSubmit}
|
||||
validationSchema={schema}
|
||||
validationSchema={createRoleSchema}
|
||||
>
|
||||
{({ handleSubmit, values, handleChange, errors }) => (
|
||||
<Form noValidate onSubmit={handleSubmit}>
|
||||
|
@ -155,7 +158,7 @@ const EditPage = () => {
|
|||
</GridItem>
|
||||
<GridItem col={6}>
|
||||
<Textarea
|
||||
name="description"
|
||||
id="description"
|
||||
value={values.description || ''}
|
||||
onChange={handleChange}
|
||||
label={formatMessage({
|
|
@ -1,9 +0,0 @@
|
|||
import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
|
||||
const schema = yup.object().shape({
|
||||
name: yup.string().required(translatedErrors.required),
|
||||
description: yup.string().required(translatedErrors.required),
|
||||
});
|
||||
|
||||
export default schema;
|
|
@ -1,8 +1,9 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { IconButton, Typography, Flex, Tbody, Tr, Td } from '@strapi/design-system';
|
||||
import { Pencil, Trash } from '@strapi/icons';
|
||||
|
||||
import { Flex, IconButton, Tbody, Td, Tr, Typography } from '@strapi/design-system';
|
||||
import { CheckPermissions, onRowClick, stopPropagation } from '@strapi/helper-plugin';
|
||||
import { Pencil, Trash } from '@strapi/icons';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
|
|
|
@ -1,48 +1,51 @@
|
|||
import React, { useMemo, useState } from 'react';
|
||||
|
||||
import {
|
||||
ActionLayout,
|
||||
Button,
|
||||
ContentLayout,
|
||||
HeaderLayout,
|
||||
Layout,
|
||||
ContentLayout,
|
||||
ActionLayout,
|
||||
Main,
|
||||
Table,
|
||||
Tr,
|
||||
Thead,
|
||||
Th,
|
||||
Thead,
|
||||
Tr,
|
||||
Typography,
|
||||
useNotifyAT,
|
||||
VisuallyHidden,
|
||||
} from '@strapi/design-system';
|
||||
import { Plus } from '@strapi/icons';
|
||||
import {
|
||||
useTracking,
|
||||
SettingsPageTitle,
|
||||
CheckPermissions,
|
||||
useNotification,
|
||||
useRBAC,
|
||||
NoPermissions,
|
||||
LoadingIndicatorPage,
|
||||
SearchURLQuery,
|
||||
useFocusWhenNavigate,
|
||||
useQueryParams,
|
||||
EmptyStateLayout,
|
||||
ConfirmDialog,
|
||||
EmptyStateLayout,
|
||||
LoadingIndicatorPage,
|
||||
NoPermissions,
|
||||
SearchURLQuery,
|
||||
SettingsPageTitle,
|
||||
useCollator,
|
||||
useFilter,
|
||||
useFocusWhenNavigate,
|
||||
useNotification,
|
||||
useQueryParams,
|
||||
useRBAC,
|
||||
useTracking,
|
||||
} from '@strapi/helper-plugin';
|
||||
import { Plus } from '@strapi/icons';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
||||
import matchSorter from 'match-sorter';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { fetchData, deleteData } from './utils/api';
|
||||
import { getTrad } from '../../../utils';
|
||||
import pluginId from '../../../pluginId';
|
||||
import permissions from '../../../permissions';
|
||||
import pluginId from '../../../pluginId';
|
||||
import { getTrad } from '../../../utils';
|
||||
|
||||
import TableBody from './components/TableBody';
|
||||
import { deleteData, fetchData } from './utils/api';
|
||||
|
||||
const RoleListPage = () => {
|
||||
const { trackUsage } = useTracking();
|
||||
const { formatMessage } = useIntl();
|
||||
const { formatMessage, locale } = useIntl();
|
||||
const { push } = useHistory();
|
||||
const toggleNotification = useNotification();
|
||||
const { notifyStatus } = useNotifyAT();
|
||||
|
@ -78,6 +81,17 @@ const RoleListPage = () => {
|
|||
enabled: canRead,
|
||||
});
|
||||
|
||||
const { includes } = useFilter(locale, {
|
||||
sensitivity: 'base',
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {Intl.Collator}
|
||||
*/
|
||||
const formatter = useCollator(locale, {
|
||||
sensitivity: 'base',
|
||||
});
|
||||
|
||||
const isLoading = isLoadingForData || isFetching;
|
||||
|
||||
const handleNewRoleClick = () => {
|
||||
|
@ -118,7 +132,12 @@ const RoleListPage = () => {
|
|||
setIsConfirmButtonLoading(false);
|
||||
};
|
||||
|
||||
const sortedRoles = matchSorter(roles || [], _q, { keys: ['name', 'description'] });
|
||||
const sortedRoles = (roles || [])
|
||||
.filter((role) => includes(role.name, _q) || includes(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;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { getFetchClient } from '@strapi/helper-plugin';
|
||||
|
||||
import { getRequestURL } from '../../../../utils';
|
||||
|
||||
export const fetchData = async (toggleNotification, notifyStatus) => {
|
||||
|
@ -14,7 +15,7 @@ export const fetchData = async (toggleNotification, notifyStatus) => {
|
|||
message: { id: 'notification.error' },
|
||||
});
|
||||
|
||||
throw new Error('error');
|
||||
throw new Error(err);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import React from 'react';
|
||||
|
||||
import { CheckPagePermissions } from '@strapi/helper-plugin';
|
||||
import pluginPermissions from '../../../permissions';
|
||||
import RolesCreatePage from '../CreatePage';
|
||||
|
||||
import pluginPermissions from '../../permissions';
|
||||
|
||||
import RolesCreatePage from './CreatePage';
|
||||
|
||||
const ProtectedRolesCreatePage = () => (
|
||||
<CheckPagePermissions permissions={pluginPermissions.createRole}>
|
|
@ -1,7 +1,10 @@
|
|||
import React from 'react';
|
||||
|
||||
import { CheckPagePermissions } from '@strapi/helper-plugin';
|
||||
import pluginPermissions from '../../../permissions';
|
||||
import RolesEditPage from '../EditPage';
|
||||
|
||||
import pluginPermissions from '../../permissions';
|
||||
|
||||
import RolesEditPage from './EditPage';
|
||||
|
||||
const ProtectedRolesEditPage = () => (
|
||||
<CheckPagePermissions permissions={pluginPermissions.updateRole}>
|
|
@ -1,8 +1,10 @@
|
|||
import React from 'react';
|
||||
import { CheckPagePermissions } from '@strapi/helper-plugin';
|
||||
import pluginPermissions from '../../../permissions';
|
||||
|
||||
import RolesListPage from '../ListPage';
|
||||
import { CheckPagePermissions } from '@strapi/helper-plugin';
|
||||
|
||||
import pluginPermissions from '../../permissions';
|
||||
|
||||
import RolesListPage from './ListPage';
|
||||
|
||||
const ProtectedRolesListPage = () => {
|
||||
return (
|
|
@ -1,9 +1,7 @@
|
|||
import * as yup from 'yup';
|
||||
import { translatedErrors } from '@strapi/helper-plugin';
|
||||
import * as yup from 'yup';
|
||||
|
||||
const schema = yup.object().shape({
|
||||
export const createRoleSchema = yup.object().shape({
|
||||
name: yup.string().required(translatedErrors.required),
|
||||
description: yup.string().required(translatedErrors.required),
|
||||
});
|
||||
|
||||
export default schema;
|
|
@ -1,11 +1,14 @@
|
|||
import React from 'react';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
import { CheckPagePermissions, NotFound } from '@strapi/helper-plugin';
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
import { AnErrorOccurred, CheckPagePermissions } from '@strapi/helper-plugin';
|
||||
import { Route, Switch } from 'react-router-dom';
|
||||
|
||||
import pluginPermissions from '../../permissions';
|
||||
import ProtectedRolesListPage from './ProtectedListPage';
|
||||
import ProtectedRolesEditPage from './ProtectedEditPage';
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
import ProtectedRolesCreatePage from './ProtectedCreatePage';
|
||||
import ProtectedRolesEditPage from './ProtectedEditPage';
|
||||
import ProtectedRolesListPage from './ProtectedListPage';
|
||||
|
||||
const Roles = () => {
|
||||
return (
|
||||
|
@ -18,7 +21,7 @@ const Roles = () => {
|
|||
/>
|
||||
<Route path={`/settings/${pluginId}/roles/:id`} component={ProtectedRolesEditPage} exact />
|
||||
<Route path={`/settings/${pluginId}/roles`} component={ProtectedRolesListPage} exact />
|
||||
<Route path="" component={NotFound} />
|
||||
<Route path="" component={AnErrorOccurred} />
|
||||
</Switch>
|
||||
</CheckPagePermissions>
|
||||
);
|
||||
|
|
|
@ -2,55 +2,79 @@
|
|||
"BoundRoute.title": "Связать путь с",
|
||||
"EditForm.inputSelect.description.role": "При регистрации пользователи будут иметь выбранную роль.",
|
||||
"EditForm.inputSelect.label.role": "Роль по умолчанию для новых пользователей",
|
||||
"EditForm.inputToggle.description.email": "Запретить пользователю создавать несколько учетных записей, используя один и тот же адрес электронной почты с различными провайдерами аутентификации.",
|
||||
"EditForm.inputToggle.description.email": "Запретить пользователю создавать несколько учётных записей, используя один и тот же адрес электронной почты, у разных поставщиков аутентификации.",
|
||||
"EditForm.inputToggle.description.email-confirmation": "Если включено (ON), при регистрации пользователи будут получать письмо для подтверждения адреса электронной почты.",
|
||||
"EditForm.inputToggle.description.email-confirmation-redirection": "Укажите URL-адрес для перенаправления после подтверждения адреса электронной почты.",
|
||||
"EditForm.inputToggle.description.email-reset-password": "URL-адрес страницы сброса пароля вашего приложения",
|
||||
"EditForm.inputToggle.description.sign-up": "Когда выключенно (OFF) процесс регистрации запрещен. Никто не может зарегистрироваться, независимо от провайдера.",
|
||||
"EditForm.inputToggle.label.email": "Одна учетная запись на адрес электронной почты",
|
||||
"EditForm.inputToggle.description.email-confirmation-redirection": "Укажите URL-адрес для перенаправления пользователей после подтверждения адреса электронной почты.",
|
||||
"EditForm.inputToggle.description.email-reset-password": "URL-адрес страницы для сброса пароля учётной записи пользователя",
|
||||
"EditForm.inputToggle.description.sign-up": "Если выключено (OFF), процесс регистрации пользователей запрещен. Никто не может зарегистрироваться, независимо от провайдера.",
|
||||
"EditForm.inputToggle.label.email": "Одна учётная запись на один адрес электронной почты",
|
||||
"EditForm.inputToggle.label.email-confirmation": "Включить подтверждение по электронной почте",
|
||||
"EditForm.inputToggle.label.email-confirmation-redirection": "URL-адрес для перенаправления",
|
||||
"EditForm.inputToggle.label.email-reset-password": "Страница сброса пароля",
|
||||
"EditForm.inputToggle.label.sign-up": "Включить регистрацию",
|
||||
"Email.template.email_confirmation": "Подтверждение адреса электронной почты",
|
||||
"EditForm.inputToggle.label.sign-up": "Включить регистрации",
|
||||
"EditForm.inputToggle.placeholder.email-confirmation-redirection": "например: https://yourfrontend.com/email-confirmation-redirection",
|
||||
"EditForm.inputToggle.placeholder.email-reset-password": "например: https://yourfrontend.com/reset-password",
|
||||
"EditPage.form.roles": "Сведения о роли",
|
||||
"Email.template.data.loaded": "Шаблоны автоматических писем для электронной почты были загружены",
|
||||
"Email.template.email_confirmation": "Адреса электронной почты с письмом о подтверждении",
|
||||
"Email.template.form.edit.label": "Редактировать шаблон",
|
||||
"Email.template.table.action.label": "действие",
|
||||
"Email.template.table.icon.label": "иконка",
|
||||
"Email.template.table.name.label": "название",
|
||||
"Form.advancedSettings.data.loaded": "Данные расширенных настроек были загружены",
|
||||
"HeaderNav.link.advancedSettings": "Расширенные настройки",
|
||||
"HeaderNav.link.emailTemplates": "Шаблоны писем",
|
||||
"HeaderNav.link.providers": "Провайдеры",
|
||||
"Plugin.permissions.plugins.description": "Определить действия доступные для плагина {name}.",
|
||||
"Plugins.header.description": "В списке выводятся только действия, связанные с маршрутом.",
|
||||
"Plugins.header.title": "Доступы",
|
||||
"Policies.header.hint": "Выберите действия приложения или плагина и щелкните значок шестеренки, чтобы отобразить связанный маршрут",
|
||||
"Plugin.permissions.plugins.description": "Определите все разрешенные действия для плагина {name}.",
|
||||
"Plugins.header.description": "Ниже перечислены только действия, связанные с путём.",
|
||||
"Plugins.header.title": "Разрешения",
|
||||
"Policies.header.hint": "Выберите действия приложения или плагина и нажмите на значок шестерёнки, чтобы отобразить связанный путь",
|
||||
"Policies.header.title": "Расширенные настройки",
|
||||
"PopUpForm.Email.email_templates.inputDescription": "Если вы не уверены как использовать переменные, {link}",
|
||||
"PopUpForm.Email.email_templates.inputDescription": "Если вы не уверены, как использовать переменные — {link}",
|
||||
"PopUpForm.Email.link.documentation": "ознакомьтесь с нашей документацией.",
|
||||
"PopUpForm.Email.options.from.email.label": "Адрес отправителя",
|
||||
"PopUpForm.Email.options.from.email.label": "Электронная почта отправителя",
|
||||
"PopUpForm.Email.options.from.email.placeholder": "kai@doe.com",
|
||||
"PopUpForm.Email.options.from.name.label": "Имя отправителя",
|
||||
"PopUpForm.Email.options.from.name.placeholder": "Kai Doe",
|
||||
"PopUpForm.Email.options.message.label": "Сообщение",
|
||||
"PopUpForm.Email.options.object.label": "Тема",
|
||||
"PopUpForm.Email.options.object.placeholder": "Пожалуйста, подтвердите свой адрес электронной почты для %APP_NAME%",
|
||||
"PopUpForm.Email.options.response_email.label": "Адрес для ответа",
|
||||
"PopUpForm.Email.options.response_email.placeholder": "kai@doe.com",
|
||||
"PopUpForm.Providers.enabled.description": "Если отключено, пользователи не смогут использовать этот провайдер.",
|
||||
"PopUpForm.Providers.enabled.label": "Включить",
|
||||
"PopUpForm.Providers.key.label": "Client ID",
|
||||
"PopUpForm.Email.options.response_email.label": "Электронная почта для ответов",
|
||||
"PopUpForm.Email.options.response_email.placeholder": "paul@example.com",
|
||||
"PopUpForm.Providers.enabled.description": "Если этот параметр отключен, пользователи не смогут использовать этого поставщика.",
|
||||
"PopUpForm.Providers.enabled.label": "Включено",
|
||||
"PopUpForm.Providers.key.label": "ID клиента",
|
||||
"PopUpForm.Providers.key.placeholder": "TEXT",
|
||||
"PopUpForm.Providers.redirectURL.front-end.label": "URL-адрес перенаправления для вашего приложения",
|
||||
"PopUpForm.Providers.redirectURL.label": "URL перенаправления, который нужно добавить в {provider} конфигурации приложения",
|
||||
"PopUpForm.Providers.redirectURL.front-end.label": "URL-адрес перенаправления на ваше приложение",
|
||||
"PopUpForm.Providers.redirectURL.label": "URL-адрес перенаправления, который нужно добавить в {provider} конфигурации приложения",
|
||||
"PopUpForm.Providers.secret.label": "Client Secret",
|
||||
"PopUpForm.Providers.secret.placeholder": "TEXT",
|
||||
"PopUpForm.Providers.subdomain.label": "Host URI (Subdomain)",
|
||||
"PopUpForm.Providers.subdomain.label": "Хост URI (Поддомен)",
|
||||
"PopUpForm.Providers.subdomain.placeholder": "my.subdomain.com",
|
||||
"PopUpForm.header.edit.email-templates": "Редактировать шаблон письма",
|
||||
"PopUpForm.header.edit.providers": "Редактировать провайдера",
|
||||
"Providers.data.loaded": "Провайдеры были загружены",
|
||||
"Providers.status": "Статус",
|
||||
"Roles.empty": "У вас пока нет никаких ролей.",
|
||||
"Roles.empty.search": "Ни одна роль не соответствует поисковому запросу.",
|
||||
"Settings.roles.deleted": "Роль удалена",
|
||||
"Settings.roles.edited": "Роль отредактирована",
|
||||
"Settings.section-label": "Плагин Пользователи и разрешения",
|
||||
"notification.success.submit": "Настройки обновлены",
|
||||
"plugin.description.long": "Защитите ваш API с помощью процесса полной аутентификации, основанном на JWT. Этот плагин также включает в себя возможности ACL (Access Control List), которые позволят вам настраивать доступы для групп пользователей.",
|
||||
"plugin.description.short": "Защитите ваш API с помощью процесса полной аутентификации, основанном на JWT",
|
||||
"plugin.name": "Роли и доступы",
|
||||
"Settings.section-label": "Плагин «Пользователи и Разрешения»",
|
||||
"components.Input.error.validation.email": "Неверный адрес электронной почты",
|
||||
"components.Input.error.validation.json": "Это не соответствует формату JSON",
|
||||
"components.Input.error.validation.max": "Значение слишком велико.",
|
||||
"components.Input.error.validation.maxLength": "Значение слишком длинное.",
|
||||
"components.Input.error.validation.min": "Значение слишком мало.",
|
||||
"components.Input.error.validation.minLength": "Значение слишком короткое.",
|
||||
"components.Input.error.validation.minSupMax": "Не может быть выше",
|
||||
"components.Input.error.validation.regex": "Значение не соответствует регулярному выражению.",
|
||||
"components.Input.error.validation.required": "Это значение является обязательным.",
|
||||
"components.Input.error.validation.unique": "Это значение уже используется.",
|
||||
"notification.success.submit": "Настройки были обновлены",
|
||||
"page.title": "Настройки — Роли",
|
||||
"plugin.description.long": "Защитите свой API с помощью полноценного процесса аутентификации, основанного на JWT. Этот плагин также имеет настройки стратегии ACL, которые позволяют вам управлять разрешениями между группами пользователей.",
|
||||
"plugin.description.short": "Защитите свой API с помощью полноценного процесса аутентификации, основанного на JWT.",
|
||||
"plugin.name": "Пользователи и Разрешения",
|
||||
"popUpWarning.button.cancel": "Отменить",
|
||||
"popUpWarning.button.confirm": "Подтвердить",
|
||||
"popUpWarning.title": "Пожалуйста подтвердите",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export { default as cleanPermissions } from './cleanPermissions';
|
||||
export { default as formatPolicies } from './formatPolicies';
|
||||
export { default as getRequestURL } from './getRequestURL';
|
||||
export { default as getTrad } from './getTrad';
|
||||
export { default as formatPolicies } from './formatPolicies';
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
"displayName": "User"
|
||||
},
|
||||
"options": {
|
||||
"draftAndPublish": false,
|
||||
"timestamps": true
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"attributes": {
|
||||
"username": {
|
||||
|
|
|
@ -12,8 +12,16 @@ tags:
|
|||
url: 'https://docs.strapi.io/developer-docs/latest/plugins/users-permissions.html'
|
||||
|
||||
paths:
|
||||
'/connect/(.*)':
|
||||
/connect/{provider}:
|
||||
get:
|
||||
parameters:
|
||||
- name: provider
|
||||
in: path
|
||||
required: true
|
||||
description: Provider name
|
||||
schema:
|
||||
type: string
|
||||
pattern: '.*'
|
||||
tags:
|
||||
- Users-Permissions - Auth
|
||||
summary: Login with a provider
|
||||
|
@ -148,7 +156,7 @@ paths:
|
|||
type: object
|
||||
properties:
|
||||
ok:
|
||||
type: enum
|
||||
type: string
|
||||
enum: [true]
|
||||
default:
|
||||
description: Error
|
||||
|
@ -273,7 +281,7 @@ paths:
|
|||
email:
|
||||
type: string
|
||||
sent:
|
||||
type: enum
|
||||
type: string
|
||||
enum: [true]
|
||||
default:
|
||||
description: Error
|
||||
|
@ -381,7 +389,7 @@ paths:
|
|||
type: object
|
||||
properties:
|
||||
ok:
|
||||
type: enum
|
||||
type: string
|
||||
enum: [true]
|
||||
default:
|
||||
description: Error
|
||||
|
@ -456,7 +464,7 @@ paths:
|
|||
type: object
|
||||
properties:
|
||||
ok:
|
||||
type: enum
|
||||
type: string
|
||||
enum: [true]
|
||||
default:
|
||||
description: Error
|
||||
|
@ -485,7 +493,7 @@ paths:
|
|||
type: object
|
||||
properties:
|
||||
ok:
|
||||
type: enum
|
||||
type: string
|
||||
enum: [true]
|
||||
default:
|
||||
description: Error
|
||||
|
@ -779,9 +787,11 @@ components:
|
|||
type:
|
||||
type: string
|
||||
createdAt:
|
||||
type: datetime
|
||||
type: string
|
||||
format: date-time
|
||||
updatedAt:
|
||||
type: datetime
|
||||
type: string
|
||||
format: date-time
|
||||
|
||||
Users-Permissions-User:
|
||||
type: object
|
||||
|
@ -805,10 +815,12 @@ components:
|
|||
type: boolean
|
||||
example: false
|
||||
createdAt:
|
||||
type: datetime
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2022-06-02T08:32:06.258Z'
|
||||
updatedAt:
|
||||
type: datetime
|
||||
type: string
|
||||
format: date-time
|
||||
example: '2022-06-02T08:32:06.267Z'
|
||||
|
||||
Users-Permissions-UserRegistration:
|
||||
|
@ -839,10 +851,6 @@ components:
|
|||
type: boolean
|
||||
policy:
|
||||
type: string
|
||||
|
||||
parameters:
|
||||
responses:
|
||||
examples:
|
||||
requestBodies:
|
||||
Users-Permissions-RoleRequest:
|
||||
required: true
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
module.exports = {
|
||||
preset: '../../../jest-preset.front.js',
|
||||
displayName: 'Users & Permissions plugin',
|
||||
setupFilesAfterEnv: ['./tests/setup.js'],
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@strapi/plugin-users-permissions",
|
||||
"version": "4.9.0",
|
||||
"version": "4.11.2",
|
||||
"description": "Protect your API with a full-authentication process based on JWT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -20,21 +20,21 @@
|
|||
}
|
||||
],
|
||||
"scripts": {
|
||||
"test:unit": "jest",
|
||||
"test:unit:watch": "jest --watch",
|
||||
"test:front": "cross-env IS_EE=true jest --config ./jest.config.front.js",
|
||||
"test:front:watch": "cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
|
||||
"test:front:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js",
|
||||
"test:front:watch:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
|
||||
"lint": "eslint ."
|
||||
"test:unit": "run -T jest",
|
||||
"test:unit:watch": "run -T jest --watch",
|
||||
"test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
|
||||
"test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
|
||||
"test:front:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js",
|
||||
"test:front:watch:ce": "run -T cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll",
|
||||
"lint": "run -T eslint ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@strapi/design-system": "1.6.6",
|
||||
"@strapi/helper-plugin": "4.9.0",
|
||||
"@strapi/icons": "1.6.6",
|
||||
"@strapi/utils": "4.9.0",
|
||||
"@strapi/design-system": "1.8.0",
|
||||
"@strapi/helper-plugin": "4.11.2",
|
||||
"@strapi/icons": "1.8.0",
|
||||
"@strapi/utils": "4.11.2",
|
||||
"bcryptjs": "2.4.3",
|
||||
"formik": "2.2.9",
|
||||
"formik": "2.4.0",
|
||||
"grant-koa": "5.4.8",
|
||||
"immer": "9.0.19",
|
||||
"jsonwebtoken": "9.0.0",
|
||||
|
@ -42,31 +42,27 @@
|
|||
"koa": "^2.13.4",
|
||||
"koa2-ratelimit": "^1.1.2",
|
||||
"lodash": "4.17.21",
|
||||
"match-sorter": "^4.0.2",
|
||||
"prop-types": "^15.7.2",
|
||||
"prop-types": "^15.8.1",
|
||||
"purest": "4.0.2",
|
||||
"react-intl": "6.3.2",
|
||||
"react-query": "3.24.3",
|
||||
"react-intl": "6.4.1",
|
||||
"react-query": "3.39.3",
|
||||
"react-redux": "8.0.5",
|
||||
"url-join": "4.0.1",
|
||||
"yup": "^0.32.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/dom": "8.19.0",
|
||||
"@testing-library/react": "12.1.4",
|
||||
"@testing-library/react-hooks": "8.0.1",
|
||||
"@testing-library/dom": "9.2.0",
|
||||
"@testing-library/react": "14.0.0",
|
||||
"@testing-library/user-event": "14.4.3",
|
||||
"history": "^4.9.0",
|
||||
"msw": "1.0.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"msw": "1.2.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "5.3.4",
|
||||
"react-test-renderer": "^17.0.2",
|
||||
"styled-components": "5.3.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react": "^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^17.0.0 || ^18.0.0",
|
||||
"react-router-dom": "5.3.4",
|
||||
"styled-components": "5.3.3"
|
||||
},
|
||||
|
@ -81,5 +77,5 @@
|
|||
"required": true,
|
||||
"kind": "plugin"
|
||||
},
|
||||
"gitHead": "ffe3f4621ccc968ce56fda9a8317ec30d4bad205"
|
||||
"gitHead": "6f7c815c2bbe41dda7d77136eb8df736c028ff67"
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ module.exports = (baseURL) => ({
|
|||
subdomain: 'my.subdomain.com/cas',
|
||||
},
|
||||
patreon: {
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
icon: '',
|
||||
key: '',
|
||||
secret: '',
|
||||
|
|
|
@ -280,6 +280,12 @@ module.exports = {
|
|||
'confirmationToken',
|
||||
'resetPasswordToken',
|
||||
'provider',
|
||||
'id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'createdBy',
|
||||
'updatedBy',
|
||||
'role',
|
||||
]),
|
||||
provider: 'local',
|
||||
};
|
||||
|
|
|
@ -138,8 +138,6 @@ module.exports = {
|
|||
ctx.send(sanitizedData);
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve user records.
|
||||
* @return {Object|Array}
|
||||
|
|
|
@ -9,17 +9,13 @@ const routes = require('./routes');
|
|||
const controllers = require('./controllers');
|
||||
const config = require('./config');
|
||||
|
||||
module.exports = (idk) => {
|
||||
console.log(' >> server!!!')
|
||||
console.log(idk)
|
||||
return {
|
||||
register,
|
||||
bootstrap,
|
||||
config,
|
||||
routes,
|
||||
controllers,
|
||||
contentTypes,
|
||||
middlewares,
|
||||
services,
|
||||
};
|
||||
}
|
||||
module.exports = () => ({
|
||||
register,
|
||||
bootstrap,
|
||||
config,
|
||||
routes,
|
||||
controllers,
|
||||
contentTypes,
|
||||
middlewares,
|
||||
services,
|
||||
});
|
||||
|
|
|
@ -18,6 +18,12 @@ module.exports = ({ strapi }) => {
|
|||
const specPath = path.join(__dirname, '../documentation/content-api.yaml');
|
||||
const spec = fs.readFileSync(specPath, 'utf8');
|
||||
|
||||
strapi.plugin('documentation').service('documentation').registerDoc(spec);
|
||||
strapi
|
||||
.plugin('documentation')
|
||||
.service('override')
|
||||
.registerOverride(spec, {
|
||||
pluginOrigin: 'users-permissions',
|
||||
excludeFromGeneration: ['users-permissions'],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -47,7 +47,6 @@ module.exports = [
|
|||
handler: 'user.update',
|
||||
config: {
|
||||
prefix: '',
|
||||
policies: ['global::updateOwnerOnly']
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -176,7 +176,7 @@ const getInitialProviders = ({ purest }) => ({
|
|||
const vk = purest({ provider: 'vk' });
|
||||
|
||||
return vk
|
||||
.get('users.get')
|
||||
.get('users')
|
||||
.auth(accessToken)
|
||||
.qs({ id: query.raw.user_id, v: '5.122' })
|
||||
.request()
|
||||
|
@ -303,7 +303,6 @@ const getInitialProviders = ({ purest }) => ({
|
|||
});
|
||||
},
|
||||
async patreon({ accessToken }) {
|
||||
console.log(' >> overrriden patreon')
|
||||
const patreon = purest({
|
||||
provider: 'patreon',
|
||||
config: {
|
||||
|
@ -363,8 +362,6 @@ module.exports = () => {
|
|||
|
||||
const providersCallbacks = getInitialProviders({ purest });
|
||||
|
||||
const sup = 'yall'
|
||||
|
||||
return {
|
||||
register(providerName, provider) {
|
||||
assert(typeof providerName === 'string', 'Provider name must be a string');
|
||||
|
|
|
@ -44,8 +44,6 @@ module.exports = ({ strapi }) => {
|
|||
*/
|
||||
|
||||
const connect = async (provider, query) => {
|
||||
console.log(`provider connect q_q = ${provider}`)
|
||||
|
||||
const accessToken = query.access_token || query.code || query.oauth_token;
|
||||
|
||||
if (!accessToken) {
|
||||
|
@ -55,13 +53,6 @@ module.exports = ({ strapi }) => {
|
|||
// Get the profile.
|
||||
const profile = await getProfile(provider, query);
|
||||
|
||||
console.log(' >> profile')
|
||||
console.log(profile)
|
||||
|
||||
if (!profile) {
|
||||
throw new Error('No profile')
|
||||
}
|
||||
|
||||
const email = _.toLower(profile.email);
|
||||
|
||||
// We need at least the mail.
|
||||
|
@ -78,17 +69,15 @@ module.exports = ({ strapi }) => {
|
|||
.get();
|
||||
|
||||
const user = _.find(users, { provider });
|
||||
console.log('user is as follows vvv')
|
||||
console.log(user)
|
||||
|
||||
if (_.isEmpty(user)) {
|
||||
console.log('WELCOME, NEW USER!')
|
||||
}
|
||||
|
||||
if (_.isEmpty(user) && !advancedSettings.allow_register) {
|
||||
throw new Error('Register action is actually not available.');
|
||||
}
|
||||
|
||||
if (!_.isEmpty(user)) {
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
// Retrieve default role.
|
||||
const defaultRole = await strapi
|
||||
|
@ -97,22 +86,21 @@ module.exports = ({ strapi }) => {
|
|||
|
||||
const patronRole = await strapi
|
||||
.query('plugin::users-permissions.role')
|
||||
.findOne({ where: { name: 'Patron' }})
|
||||
.findOne({ where: { name: 'Patron' }});
|
||||
|
||||
if (_.isEmpty(patronRole)) throw new Error('Patron role is missing in Strapi. Please create it in users-permissions plugin.');
|
||||
|
||||
// get the user's patron status
|
||||
const patreonModel = await strapi
|
||||
.query('api::patreon.patreon')
|
||||
.findOne({ select: ['id', 'accessToken', 'benefitId'], where: { id: 1 } })
|
||||
.findOne({ select: ['id', 'accessToken', 'benefitId'], where: { id: 1 } });
|
||||
|
||||
console.log(` >> patreon model`)
|
||||
console.log(patreonModel)
|
||||
console.log(` >> patreon:${patreonModel.id}`)
|
||||
console.log(` >> HERE is the user's patreon profile`)
|
||||
console.log(profile)
|
||||
const isPatron = profile.benefits.includes(patreonModel.benefitId)
|
||||
const patreonBenefits = profile.benefits.join(',')
|
||||
|
||||
console.log(`isPatron:${isPatron}`)
|
||||
|
||||
|
||||
|
@ -137,14 +125,13 @@ module.exports = ({ strapi }) => {
|
|||
if (users.length && advancedSettings.unique_email) {
|
||||
throw new Error('Email is already taken.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Create the new user.
|
||||
const newUser = {
|
||||
...profile,
|
||||
email, // overwrite with lowercased email
|
||||
provider,
|
||||
role: selectedRole,
|
||||
role: defaultRole.id,
|
||||
confirmed: true,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
"use strict";
|
||||
'use strict';
|
||||
|
||||
// Yes, this file is custom.
|
||||
module.exports = (plugin) => {
|
||||
// console.log("strapi-server.js", plugin.services.toString());
|
||||
console.log(plugin.services)
|
||||
// console.log(plugin.services["providers-registry"].toString())
|
||||
plugin.bootstrap = require("./server/bootstrap");
|
||||
plugin.services["providers"] = require("./server/services/providers");
|
||||
plugin.services["providers-registry"] = require("./server/services/providers-registry");
|
||||
return plugin;
|
||||
};
|
||||
plugin.bootstrap = require('./server/bootstrap');
|
||||
plugin.services['providers'] = require('./server/services/providers');
|
||||
plugin.services['providers-registry'] = require('./server/services/providers-registry');
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
|
||||
// const purest = require('purest');
|
||||
|
||||
// const patreon = async function patreon({ accessToken }) {
|
||||
|
@ -48,9 +50,8 @@ module.exports = {
|
|||
* This gives you an opportunity to extend code.
|
||||
*/
|
||||
register({ strapi }) {
|
||||
console.log(` >> boostrap!`)
|
||||
|
||||
|
||||
// console.log(strapi.plugin('users-permissions').service('providers-registry'))
|
||||
// strapi.plugin('users-permissions').service('providers-registry').register('taco', patreon)
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue