mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 14:59:07 +00:00
Add telemetry back
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
6ea3093221
commit
9626c72268
@ -1,4 +1,3 @@
|
||||
// import styled from 'styled-components';
|
||||
import { Text } from '@buffetjs/core';
|
||||
import Chevron from '../../Chevron';
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
import React, { forwardRef, memo, useCallback, useImperativeHandle, useReducer } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { difference } from 'strapi-helper-plugin';
|
||||
import { has, isEmpty } from 'lodash';
|
||||
import Tabs from '../Tabs';
|
||||
import PermissionsDataManagerProvider from '../PermissionsDataManagerProvider';
|
||||
import ContentTypes from '../ContentTypes';
|
||||
@ -11,14 +13,34 @@ import init from './init';
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
||||
const Permissions = forwardRef(({ layout, isFormDisabled, permissions }, ref) => {
|
||||
const [{ layouts, modifiedData }, dispatch] = useReducer(reducer, initialState, () =>
|
||||
const [{ initialData, layouts, modifiedData }, dispatch] = useReducer(reducer, initialState, () =>
|
||||
init(layout, permissions)
|
||||
);
|
||||
|
||||
useImperativeHandle(ref, () => {
|
||||
return {
|
||||
getPermissions: () => {
|
||||
return formatPermissionsToAPI(modifiedData);
|
||||
const collectionTypesDiff = difference(
|
||||
initialData.collectionTypes,
|
||||
modifiedData.collectionTypes
|
||||
);
|
||||
const singleTypesDiff = difference(initialData.singleTypes, modifiedData.singleTypes);
|
||||
|
||||
const contentTypesDiff = { ...collectionTypesDiff, ...singleTypesDiff };
|
||||
|
||||
let didUpdateConditions;
|
||||
|
||||
if (isEmpty(contentTypesDiff)) {
|
||||
didUpdateConditions = false;
|
||||
} else {
|
||||
didUpdateConditions = Object.values(contentTypesDiff).some(permission => {
|
||||
return Object.values(permission).some(permissionValue =>
|
||||
has(permissionValue, 'conditions')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return { permissionsToSend: formatPermissionsToAPI(modifiedData), didUpdateConditions };
|
||||
},
|
||||
resetForm: () => {
|
||||
dispatch({ type: 'RESET_FORM' });
|
||||
|
@ -10,5 +10,4 @@
|
||||
export const LOGIN_LOGO = null;
|
||||
export const SHOW_TUTORIALS = true;
|
||||
export const SETTINGS_BASE_URL = '/settings';
|
||||
// TODO
|
||||
export const STRAPI_UPDATE_NOTIF = true;
|
||||
|
@ -14,11 +14,7 @@ import schema from './utils/schema';
|
||||
|
||||
const EditPage = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const {
|
||||
// TODO
|
||||
// emitEvent,
|
||||
settingsBaseURL,
|
||||
} = useGlobalContext();
|
||||
const { emitEvent, settingsBaseURL } = useGlobalContext();
|
||||
const {
|
||||
params: { id },
|
||||
} = useRouteMatch(`${settingsBaseURL}/roles/:id`);
|
||||
@ -74,23 +70,7 @@ const EditPage = () => {
|
||||
strapi.lockAppWithOverlay();
|
||||
setIsSubmiting(true);
|
||||
|
||||
const permissionsToSend = permissionsRef.current.getPermissions();
|
||||
|
||||
// TODO
|
||||
// const checkConditionsDiff = () => {
|
||||
// const diff = difference(
|
||||
// get(permissionsToSend, 'contentTypesPermissions', {}),
|
||||
// get(rolePermissions, 'contentTypesPermissions', {})
|
||||
// );
|
||||
|
||||
// if (isEmpty(diff)) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// return Object.keys(diff).some(key => {
|
||||
// return has(diff, [key, 'conditions']);
|
||||
// });
|
||||
// };
|
||||
const { permissionsToSend, didUpdateConditions } = permissionsRef.current.getPermissions();
|
||||
|
||||
await request(`/admin/roles/${id}`, {
|
||||
method: 'PUT',
|
||||
@ -105,10 +85,9 @@ const EditPage = () => {
|
||||
},
|
||||
});
|
||||
|
||||
// TODO
|
||||
// if (checkConditionsDiff()) {
|
||||
// emitEvent('didUpdateConditions');
|
||||
// }
|
||||
if (didUpdateConditions) {
|
||||
emitEvent('didUpdateConditions');
|
||||
}
|
||||
}
|
||||
|
||||
permissionsRef.current.setFormAfterSubmit();
|
||||
|
@ -1,83 +1,83 @@
|
||||
// import ar from './ar.json';
|
||||
// import cs from './cs.json';
|
||||
// import de from './de.json';
|
||||
// import dk from './dk.json';
|
||||
import ar from './ar.json';
|
||||
import cs from './cs.json';
|
||||
import de from './de.json';
|
||||
import dk from './dk.json';
|
||||
import en from './en.json';
|
||||
// import es from './es.json';
|
||||
import es from './es.json';
|
||||
import fr from './fr.json';
|
||||
// import he from './he.json';
|
||||
// import id from './id.json';
|
||||
// import it from './it.json';
|
||||
// import ja from './ja.json';
|
||||
// import ko from './ko.json';
|
||||
// import ms from './ms.json';
|
||||
// import nl from './nl.json';
|
||||
// import pl from './pl.json';
|
||||
// import ptBR from './pt-BR.json';
|
||||
// import pt from './pt.json';
|
||||
// import ru from './ru.json';
|
||||
// import th from './th.json';
|
||||
// import tr from './tr.json';
|
||||
// import vi from './vi.json';
|
||||
// import zhHans from './zh-Hans.json';
|
||||
// import zh from './zh.json';
|
||||
// import sk from './sk.json';
|
||||
// import uk from './uk.json';
|
||||
import he from './he.json';
|
||||
import id from './id.json';
|
||||
import it from './it.json';
|
||||
import ja from './ja.json';
|
||||
import ko from './ko.json';
|
||||
import ms from './ms.json';
|
||||
import nl from './nl.json';
|
||||
import pl from './pl.json';
|
||||
import ptBR from './pt-BR.json';
|
||||
import pt from './pt.json';
|
||||
import ru from './ru.json';
|
||||
import th from './th.json';
|
||||
import tr from './tr.json';
|
||||
import vi from './vi.json';
|
||||
import zhHans from './zh-Hans.json';
|
||||
import zh from './zh.json';
|
||||
import sk from './sk.json';
|
||||
import uk from './uk.json';
|
||||
|
||||
const trads = {
|
||||
// ar,
|
||||
// cs,
|
||||
// de,
|
||||
// dk,
|
||||
ar,
|
||||
cs,
|
||||
de,
|
||||
dk,
|
||||
en,
|
||||
// es,
|
||||
es,
|
||||
fr,
|
||||
// he,
|
||||
// id,
|
||||
// it,
|
||||
// ja,
|
||||
// ko,
|
||||
// ms,
|
||||
// nl,
|
||||
// pl,
|
||||
// 'pt-BR': ptBR,
|
||||
// pt,
|
||||
// ru,
|
||||
// sk,
|
||||
// th,
|
||||
// tr,
|
||||
// uk,
|
||||
// vi,
|
||||
// 'zh-Hans': zhHans,
|
||||
// zh,
|
||||
he,
|
||||
id,
|
||||
it,
|
||||
ja,
|
||||
ko,
|
||||
ms,
|
||||
nl,
|
||||
pl,
|
||||
'pt-BR': ptBR,
|
||||
pt,
|
||||
ru,
|
||||
sk,
|
||||
th,
|
||||
tr,
|
||||
uk,
|
||||
vi,
|
||||
'zh-Hans': zhHans,
|
||||
zh,
|
||||
};
|
||||
|
||||
export const languageNativeNames = {
|
||||
// ar: 'العربية',
|
||||
// cs: 'Čeština',
|
||||
// de: 'Deutsch',
|
||||
// dk: 'Dansk',
|
||||
ar: 'العربية',
|
||||
cs: 'Čeština',
|
||||
de: 'Deutsch',
|
||||
dk: 'Dansk',
|
||||
en: 'English',
|
||||
// es: 'Español',
|
||||
es: 'Español',
|
||||
fr: 'Français',
|
||||
// he: 'עברית',
|
||||
// id: 'Indonesian',
|
||||
// it: 'Italiano',
|
||||
// ja: '日本語',
|
||||
// ko: '한국어',
|
||||
// ms: 'Melayu',
|
||||
// nl: 'Nederlands',
|
||||
// pl: 'Polski',
|
||||
// 'pt-BR': 'Português (Brasil)',
|
||||
// pt: 'Português (Portugal)',
|
||||
// ru: 'Русский',
|
||||
// sk: 'Slovenčina',
|
||||
// th: 'ไทย',
|
||||
// tr: 'Türkçe',
|
||||
// uk: 'Українська',
|
||||
// vi: 'Tiếng Việt',
|
||||
// 'zh-Hans': '中文 (简体)',
|
||||
// zh: '中文 (繁體)',
|
||||
he: 'עברית',
|
||||
id: 'Indonesian',
|
||||
it: 'Italiano',
|
||||
ja: '日本語',
|
||||
ko: '한국어',
|
||||
ms: 'Melayu',
|
||||
nl: 'Nederlands',
|
||||
pl: 'Polski',
|
||||
'pt-BR': 'Português (Brasil)',
|
||||
pt: 'Português (Portugal)',
|
||||
ru: 'Русский',
|
||||
sk: 'Slovenčina',
|
||||
th: 'ไทย',
|
||||
tr: 'Türkçe',
|
||||
uk: 'Українська',
|
||||
vi: 'Tiếng Việt',
|
||||
'zh-Hans': '中文 (简体)',
|
||||
zh: '中文 (繁體)',
|
||||
};
|
||||
|
||||
export default trads;
|
||||
|
@ -33,13 +33,10 @@ const CreatePage = () => {
|
||||
const id = get(params, 'params.id', null);
|
||||
const {
|
||||
isLoading: isLayoutLoading,
|
||||
// TODO
|
||||
// data: permissionsLayout
|
||||
} = useFetchPermissionsLayout();
|
||||
const {
|
||||
// role, permissions: rolePermissions,
|
||||
isLoading: isRoleLoading,
|
||||
} = useFetchRole(id);
|
||||
// console.log({ role, rolePermissions });
|
||||
const { permissions: rolePermissions, isLoading: isRoleLoading } = useFetchRole(id);
|
||||
|
||||
const headerActions = (handleSubmit, handleReset) => [
|
||||
{
|
||||
@ -83,7 +80,7 @@ const CreatePage = () => {
|
||||
})
|
||||
)
|
||||
.then(async res => {
|
||||
const permissionsToSend = permissionsRef.current.getPermissions();
|
||||
const { permissionsToSend } = permissionsRef.current.getPermissions();
|
||||
|
||||
if (id) {
|
||||
emitEvent('didDuplicateRole');
|
||||
@ -197,7 +194,11 @@ const CreatePage = () => {
|
||||
</FormCard>
|
||||
{!isLayoutLoading && !isRoleLoading && (
|
||||
<Padded top bottom size="md">
|
||||
<Permissions isFormDisabled={false} ref={permissionsRef} />
|
||||
<Permissions
|
||||
isFormDisabled={false}
|
||||
ref={permissionsRef}
|
||||
permissions={rolePermissions}
|
||||
/>
|
||||
</Padded>
|
||||
)}
|
||||
</ContainerFluid>
|
||||
|
Loading…
x
Reference in New Issue
Block a user