mirror of
https://github.com/strapi/strapi.git
synced 2025-08-22 15:48:59 +00:00
Reduce and optimize lodash imports
This commit is contained in:
parent
69e34ff84a
commit
a9fb1f3130
@ -1,4 +1,4 @@
|
||||
import { cloneDeep } from 'lodash';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import init from '../init';
|
||||
import { initialState } from '../reducer';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
||||
|
||||
function useSelect(name) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useMemo } from 'react';
|
||||
import { get, take } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import take from 'lodash/take';
|
||||
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
||||
|
||||
import { getFieldName } from '../../../utils';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { toLower } from 'lodash';
|
||||
import toLower from 'lodash/toLower';
|
||||
|
||||
const getInputType = (type = '') => {
|
||||
switch (toLower(type)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
||||
|
||||
function useSelect(keys) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { useCallback } from 'react';
|
||||
import { get } from 'lodash';
|
||||
import { useSelector } from 'react-redux';
|
||||
import selectLayout from '../../pages/EditViewLayoutManager/selectors';
|
||||
|
||||
@ -8,7 +7,7 @@ const useContentTypeLayout = () => {
|
||||
|
||||
const getComponentLayout = useCallback(
|
||||
(componentUid) => {
|
||||
return get(currentLayout, ['components', componentUid], {});
|
||||
return currentLayout?.components?.[componentUid] ?? {};
|
||||
},
|
||||
[currentLayout]
|
||||
);
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { cloneDeep, get, set } from 'lodash';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import get from 'lodash/get';
|
||||
import set from 'lodash/set';
|
||||
|
||||
import { mergeMetasWithSchema } from '../../../utils';
|
||||
|
||||
const getRelationModel = (targetModel, models) => models.find((model) => model.uid === targetModel);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React, { memo, useMemo } from 'react';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import { get } from 'lodash';
|
||||
import PropTypes from 'prop-types';
|
||||
import { LoadingIndicatorPage, CheckPagePermissions } from '@strapi/helper-plugin';
|
||||
import permissions from '../../../permissions';
|
||||
@ -43,7 +42,7 @@ const CollectionTypeRecursivePath = ({
|
||||
return { rawContentTypeLayout, rawComponentsLayouts };
|
||||
}, [layout]);
|
||||
|
||||
const uid = get(layout, ['contentType', 'uid'], null);
|
||||
const uid = layout?.contentType?.uid ?? null;
|
||||
|
||||
// This statement is needed in order to prevent the CollectionTypeFormWrapper effects clean up phase to be run twice.
|
||||
// What can happen is that when navigating from one entry to another the cleanup phase of the fetch data effect is run twice : once when
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { cloneDeep, set } from 'lodash';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import set from 'lodash/set';
|
||||
|
||||
import { createLayout, formatLayout } from './utils/layout';
|
||||
|
||||
const init = (initialState, mainLayout, components) => {
|
||||
|
@ -1,8 +1,6 @@
|
||||
import { get } from 'lodash';
|
||||
|
||||
const createPossibleMainFieldsForModelsAndComponents = (array) => {
|
||||
return array.reduce((acc, current) => {
|
||||
const attributes = get(current, ['attributes'], {});
|
||||
const attributes = current?.attributes ?? {};
|
||||
const possibleMainFields = Object.keys(attributes).filter((attr) => {
|
||||
return ![
|
||||
'boolean',
|
||||
@ -14,7 +12,7 @@ const createPossibleMainFieldsForModelsAndComponents = (array) => {
|
||||
'relation',
|
||||
'text',
|
||||
'richtext',
|
||||
].includes(get(attributes, [attr, 'type'], ''));
|
||||
].includes(attributes?.[attr]?.type ?? '');
|
||||
});
|
||||
|
||||
acc[current.uid] = possibleMainFields;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isEmpty } from 'lodash';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
||||
|
||||
function useSelect() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { get, isEmpty } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
|
||||
const createAttributesLayout = (currentContentTypeLayoutData) => {
|
||||
if (!currentContentTypeLayoutData.layouts) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { uniq, flatMap } from 'lodash';
|
||||
import uniq from 'lodash/uniq';
|
||||
import flatMap from 'lodash/flatMap';
|
||||
import { findMatchingPermissions } from '@strapi/helper-plugin';
|
||||
|
||||
const getFieldsActionMatchingPermissions = (userPermissions, slug) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { toLower } from 'lodash';
|
||||
import toLower from 'lodash/toLower';
|
||||
|
||||
const checkIfAttributeIsDisplayable = (attribute) => {
|
||||
const type = attribute.type;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
|
||||
const createDefaultForm = (attributes, allComponentsSchema) => {
|
||||
return Object.keys(attributes).reduce((acc, current) => {
|
||||
@ -10,7 +10,7 @@ const createDefaultForm = (attributes, allComponentsSchema) => {
|
||||
}
|
||||
|
||||
if (type === 'component') {
|
||||
const currentComponentSchema = get(allComponentsSchema, [component, 'attributes'], {});
|
||||
const currentComponentSchema = allComponentsSchema?.[component]?.attributes ?? {};
|
||||
const currentComponentDefaultForm = createDefaultForm(
|
||||
currentComponentSchema,
|
||||
allComponentsSchema
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { omit, get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import omit from 'lodash/omit';
|
||||
|
||||
const formatLayoutToApi = ({ layouts, metadatas, ...rest }) => {
|
||||
const list = layouts.list.map((obj) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isNaN } from 'lodash';
|
||||
import isNaN from 'lodash/isNaN';
|
||||
|
||||
const getFieldName = (stringName) =>
|
||||
stringName.split('.').filter((string) => isNaN(parseInt(string, 10)));
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { set } from 'lodash';
|
||||
import set from 'lodash/set';
|
||||
|
||||
const mergeMetasWithSchema = (data, schemas, mainSchemaKey) => {
|
||||
const findSchema = (refUid) => schemas.find((obj) => obj.uid === refUid);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* This file is for all helpers related to `paths` in the CM.
|
||||
*/
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
|
||||
/**
|
||||
* This is typically used in circumstances where there are re-orderable pieces e.g. Dynamic Zones
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { getType, getOtherInfos } from '@strapi/helper-plugin';
|
||||
|
||||
const removePasswordFieldsFromData = (data, contentTypeSchema, componentSchema) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { useFetchClient, useNotification } from '@strapi/helper-plugin';
|
||||
|
||||
const useRegenerate = (url, id, onRegenerate) => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useEffect, useReducer } from 'react';
|
||||
import { request, useNotification, useOverlayBlocker } from '@strapi/helper-plugin';
|
||||
import { get, has, omit } from 'lodash';
|
||||
import omit from 'lodash/omit';
|
||||
import { checkFormValidity, formatAPIErrors } from '../../utils';
|
||||
import { initialState, reducer } from './reducer';
|
||||
import init from './init';
|
||||
@ -102,9 +102,9 @@ const useSettingsForm = (endPoint, schema, cbSuccess, fieldsToPick) => {
|
||||
message: { id: 'notification.success.saved' },
|
||||
});
|
||||
} catch (err) {
|
||||
const data = get(err, 'response.payload', { data: {} });
|
||||
const data = err?.response?.payload ?? { data: {} };
|
||||
|
||||
if (has(data, 'data') && typeof data.data === 'string') {
|
||||
if (!!data?.data && typeof data.data === 'string') {
|
||||
toggleNotification({
|
||||
type: 'warning',
|
||||
message: data.data,
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* eslint-disable consistent-return */
|
||||
import produce from 'immer';
|
||||
import { pick, set, unset } from 'lodash';
|
||||
import pick from 'lodash/pick';
|
||||
import set from 'lodash/set';
|
||||
import unset from 'lodash/unset';
|
||||
|
||||
const initialState = {
|
||||
fieldsToPick: [],
|
||||
|
@ -1,5 +1,5 @@
|
||||
import produce from 'immer';
|
||||
import { set } from 'lodash';
|
||||
import set from 'lodash/set';
|
||||
|
||||
const initialState = {
|
||||
menu: [],
|
||||
|
@ -1,5 +1,5 @@
|
||||
import produce from 'immer';
|
||||
import { set } from 'lodash';
|
||||
import set from 'lodash/set';
|
||||
/* eslint-disable consistent-return */
|
||||
|
||||
const initialState = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { capitalize } from 'lodash';
|
||||
import capitalize from 'lodash/capitalize';
|
||||
import { useIntl } from 'react-intl';
|
||||
import {
|
||||
Accordion,
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable consistent-return */
|
||||
import produce from 'immer';
|
||||
import { pull } from 'lodash';
|
||||
import pull from 'lodash/pull';
|
||||
import { transformPermissionsData } from './utils';
|
||||
|
||||
export const initialState = {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { flatten } from 'lodash';
|
||||
|
||||
const transformPermissionsData = (data) => {
|
||||
const layout = {
|
||||
allActionsIds: [],
|
||||
@ -9,11 +7,11 @@ const transformPermissionsData = (data) => {
|
||||
layout.permissions = Object.keys(data).map((apiId) => ({
|
||||
apiId,
|
||||
label: apiId.split('::')[1],
|
||||
controllers: flatten(
|
||||
Object.keys(data[apiId].controllers).map((controller) => ({
|
||||
controllers: Object.keys(data[apiId].controllers)
|
||||
.map((controller) => ({
|
||||
controller,
|
||||
actions: flatten(
|
||||
data[apiId].controllers[controller].map((action) => {
|
||||
actions: data[apiId].controllers[controller]
|
||||
.map((action) => {
|
||||
const actionId = `${apiId}.${controller}.${action}`;
|
||||
|
||||
if (apiId.includes('api::')) {
|
||||
@ -25,9 +23,9 @@ const transformPermissionsData = (data) => {
|
||||
actionId,
|
||||
};
|
||||
})
|
||||
),
|
||||
.flat(),
|
||||
}))
|
||||
),
|
||||
.flat(),
|
||||
}));
|
||||
|
||||
return layout;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
|
||||
const createConditionsForm = (conditions, valueObject) => {
|
||||
return conditions.reduce((acc, current) => {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { get, isEmpty } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import { createArrayOfValues, getCheckboxState } from '../../../utils';
|
||||
|
||||
const generateCheckboxesActions = (availableActions, modifiedData, pathToData) => {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import { getCheckboxState } from '../../../../utils';
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { getCheckboxState, removeConditionKeyFromData } from '../../utils';
|
||||
|
||||
const getActionsIds = (array) => array.map(({ actionId }) => actionId);
|
||||
|
@ -1,5 +1,10 @@
|
||||
import produce from 'immer';
|
||||
import { cloneDeep, has, isObject, get, set } from 'lodash';
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import has from 'lodash/has';
|
||||
import isObject from 'lodash/isObject';
|
||||
import get from 'lodash/get';
|
||||
import set from 'lodash/set';
|
||||
|
||||
import updateConditionsToFalse from './utils/updateConditionsToFalse';
|
||||
import updateValues from './utils/updateValues';
|
||||
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { merge, get, isEmpty, set } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import merge from 'lodash/merge';
|
||||
import set from 'lodash/set';
|
||||
|
||||
import findMatchingPermission from './findMatchingPermissions';
|
||||
/**
|
||||
* Creates the default condition form: { [conditionId]: false }
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { get } from 'lodash';
|
||||
import { createDefaultConditionsForm } from './createDefaultCTFormFromLayout';
|
||||
import findMatchingPermission from './findMatchingPermissions';
|
||||
|
||||
@ -12,7 +11,7 @@ const createSubCategoryForm = (actions, conditions, permissions) => {
|
||||
},
|
||||
conditions: createDefaultConditionsForm(
|
||||
conditions,
|
||||
get(foundMatchingPermission, 'conditions', [])
|
||||
foundMatchingPermission?.conditions ?? []
|
||||
),
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { has, isObject } from 'lodash';
|
||||
import isObject from 'lodash/isObject';
|
||||
import { createArrayOfValues } from '../../utils';
|
||||
import { createConditionsArray } from './formatSettingsPermissionsToAPI';
|
||||
|
||||
@ -77,7 +77,7 @@ const createSubjectPermissions = (subject, actions) => {
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (!has(permissions, 'properties.enabled')) {
|
||||
if (!permissions?.properties?.enabled) {
|
||||
const createdPermissionsArray = createPermissionWithProperties(
|
||||
actionName,
|
||||
subject,
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { isObject, has, omit } from 'lodash';
|
||||
import isObject from 'lodash/isObject';
|
||||
import has from 'lodash/has';
|
||||
import omit from 'lodash/omit';
|
||||
|
||||
import { createArrayOfValues } from '../../utils';
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isObject } from 'lodash';
|
||||
import isObject from 'lodash/isObject';
|
||||
|
||||
/**
|
||||
* Sets all the none object values of an object to the given one
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { createArrayOfValues } from '../../../utils';
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { flattenDeep, isObject } from 'lodash';
|
||||
import flattenDeep from 'lodash/flattenDeep';
|
||||
import isObject from 'lodash/isObject';
|
||||
|
||||
const createArrayOfValues = (obj) => {
|
||||
if (!isObject(obj)) {
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
Typography,
|
||||
VisuallyHidden,
|
||||
} from '@strapi/design-system';
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import matchSorter from 'match-sorter';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { useRBAC, LoadingIndicatorPage, useNotification } from '@strapi/helper-plugin';
|
||||
import { Redirect, useLocation } from 'react-router-dom';
|
||||
import { get } from 'lodash';
|
||||
|
||||
import adminPermissions from '../../../../../permissions';
|
||||
import EditPage from '../EditPage';
|
||||
|
||||
@ -19,7 +19,7 @@ const ProtectedEditPage = () => {
|
||||
allowedActions: { canRead, canUpdate },
|
||||
} = useRBAC(permissions);
|
||||
const { state } = useLocation();
|
||||
const from = get(state, 'from', '/');
|
||||
const from = state?.from ?? '/';
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading) {
|
||||
|
@ -1,11 +1,5 @@
|
||||
import { set } from 'lodash';
|
||||
|
||||
const cleanData = (data) => {
|
||||
const webhooks = { ...data };
|
||||
|
||||
set(webhooks, 'headers', unformatHeaders(data.headers));
|
||||
|
||||
return webhooks;
|
||||
return { ...data, headers: unformatHeaders(data.headers) };
|
||||
};
|
||||
|
||||
const unformatHeaders = (headers) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { merge } from 'lodash';
|
||||
import merge from 'lodash/merge';
|
||||
import customPermissions from 'ee_else_ce/permissions/customPermissions';
|
||||
import defaultPermissions from './defaultPermissions';
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
import { get } from 'lodash';
|
||||
|
||||
const getAttributesToDisplay = (contentType) => {
|
||||
const timestamps = get(contentType, ['options', 'timestamps']);
|
||||
const timestamps = contentType?.options?.timestamps;
|
||||
|
||||
// Sometimes timestamps is false
|
||||
let timestampsArray = Array.isArray(timestamps) ? timestamps : [];
|
||||
const idsAttributes = ['id', '_id']; // For both SQL and mongo
|
||||
const unwritableAttributes = [...idsAttributes, ...timestampsArray, 'publishedAt'];
|
||||
const schemaAttributes = get(contentType, ['attributes'], {});
|
||||
const schemaAttributes = contentType?.attributes ?? {};
|
||||
|
||||
return Object.keys(schemaAttributes).reduce((acc, current) => {
|
||||
if (!unwritableAttributes.includes(current)) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { get } from 'lodash';
|
||||
|
||||
const getExistingActions = (permissions) => {
|
||||
return Array.from(
|
||||
new Set(
|
||||
@ -23,7 +21,7 @@ const getExistingActions = (permissions) => {
|
||||
...acc,
|
||||
...getActionsPermission([
|
||||
...Object.values(current[1].attributes || {}),
|
||||
get(current[1], 'contentTypeActions', {}),
|
||||
current[1]?.contentTypeActions ?? {},
|
||||
]),
|
||||
];
|
||||
}, [])
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { sortBy } from 'lodash';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
|
||||
const sortLinks = (links) => sortBy(links, (object) => object.name);
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
import React, { memo, useEffect, useMemo, useRef } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { get, groupBy, set, size } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import groupBy from 'lodash/groupBy';
|
||||
import set from 'lodash/set';
|
||||
import size from 'lodash/size';
|
||||
import {
|
||||
LoadingIndicatorPage,
|
||||
useTracking,
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { get, isEqual, omit, sortBy, camelCase } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import omit from 'lodash/omit';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import camelCase from 'lodash/camelCase';
|
||||
|
||||
import pluginId from '../../../pluginId';
|
||||
import makeUnique from '../../../utils/makeUnique';
|
||||
|
@ -1,9 +1,8 @@
|
||||
import { get } from 'lodash';
|
||||
import makeUnique from '../../../utils/makeUnique';
|
||||
|
||||
const retrieveNestedComponents = (appComponents) => {
|
||||
const nestedComponents = Object.keys(appComponents).reduce((acc, current) => {
|
||||
const componentAttributes = get(appComponents, [current, 'schema', 'attributes'], []);
|
||||
const componentAttributes = appComponents?.[current]?.schema?.attributes ?? [];
|
||||
const currentComponentNestedCompos = getComponentsFromComponent(componentAttributes);
|
||||
|
||||
return [...acc, ...currentComponentNestedCompos];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import makeUnique from '../../../utils/makeUnique';
|
||||
|
||||
const retrieveSpecificInfoFromComponents = (allComponents, keysToRetrieve) => {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import * as yup from 'yup';
|
||||
import { get, toNumber } from 'lodash';
|
||||
import toNumber from 'lodash/toNumber';
|
||||
import { translatedErrors as errorsTrads } from '@strapi/helper-plugin';
|
||||
|
||||
import getTrad from '../../../../utils/getTrad';
|
||||
|
||||
const NAME_REGEX = /^[A-Za-z][_0-9A-Za-z]*$/;
|
||||
@ -20,7 +21,7 @@ const alreadyUsedAttributeNames = (usedNames) => {
|
||||
};
|
||||
|
||||
const getUsedContentTypeAttributeNames = (ctShema, isEdition, attributeNameToEdit) => {
|
||||
const attributes = get(ctShema, ['schema', 'attributes'], {});
|
||||
const attributes = ctShema?.schema?.attributes ?? {};
|
||||
|
||||
return Object.keys(attributes).filter((attr) => {
|
||||
if (isEdition) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as yup from 'yup';
|
||||
import { toLower } from 'lodash';
|
||||
import { translatedErrors as errorsTrads } from '@strapi/helper-plugin';
|
||||
|
||||
import CATEGORY_NAME_REGEX from './regex';
|
||||
|
||||
const createCategorySchema = (usedCategoryNames) => {
|
||||
@ -16,7 +16,7 @@ const createCategorySchema = (usedCategoryNames) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !usedCategoryNames.includes(toLower(value));
|
||||
return !usedCategoryNames.includes(value?.toLowerCase());
|
||||
},
|
||||
})
|
||||
.required(errorsTrads.required),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as yup from 'yup';
|
||||
import { toLower, trim } from 'lodash';
|
||||
import { translatedErrors as errorsTrads } from '@strapi/helper-plugin';
|
||||
|
||||
import getTrad from '../../../utils/getTrad';
|
||||
import { createComponentUid } from '../utils/createUid';
|
||||
import { CATEGORY_NAME_REGEX } from '../category';
|
||||
@ -30,7 +30,7 @@ const createComponentSchema = (usedComponentNames, reservedNames, category) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !reservedNames.includes(toLower(trim(value)));
|
||||
return !reservedNames.includes(value?.trim()?.toLowerCase());
|
||||
},
|
||||
})
|
||||
.required(errorsTrads.required),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as yup from 'yup';
|
||||
import { toLower, trim } from 'lodash';
|
||||
import { translatedErrors as errorsTrads } from '@strapi/helper-plugin';
|
||||
|
||||
import getTrad from '../../../utils/getTrad';
|
||||
import { createUid } from '../utils/createUid';
|
||||
|
||||
@ -34,7 +34,7 @@ const createContentTypeSchema = ({
|
||||
return false;
|
||||
}
|
||||
|
||||
return !reservedModels.includes(toLower(trim(value)));
|
||||
return !reservedModels.includes(value?.trim()?.toLowerCase());
|
||||
},
|
||||
})
|
||||
.required(errorsTrads.required),
|
||||
@ -70,7 +70,7 @@ const createContentTypeSchema = ({
|
||||
return false;
|
||||
}
|
||||
|
||||
return !reservedModels.includes(toLower(trim(value)));
|
||||
return !reservedModels.includes(value?.trim()?.toLowerCase());
|
||||
},
|
||||
})
|
||||
.required(errorsTrads.required),
|
||||
@ -106,7 +106,7 @@ const createContentTypeSchema = ({
|
||||
return false;
|
||||
}
|
||||
|
||||
return !reservedModels.includes(toLower(trim(value)));
|
||||
return !reservedModels.includes(value?.trim()?.toLowerCase());
|
||||
},
|
||||
})
|
||||
.required(errorsTrads.required),
|
||||
|
@ -27,7 +27,7 @@ import {
|
||||
TabPanel,
|
||||
Flex,
|
||||
} from '@strapi/design-system';
|
||||
import { isEqual } from 'lodash';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import pluginId from '../../pluginId';
|
||||
import useDataManager from '../../hooks/useDataManager';
|
||||
import useFormModalNavigation from '../../hooks/useFormModalNavigation';
|
||||
|
@ -2,7 +2,7 @@ import produce from 'immer';
|
||||
import pluralize from 'pluralize';
|
||||
import set from 'lodash/set';
|
||||
import snakeCase from 'lodash/snakeCase';
|
||||
import _ from 'lodash';
|
||||
|
||||
import getRelationType from '../../utils/getRelationType';
|
||||
import nameToSlug from '../../utils/nameToSlug';
|
||||
import { createComponentUid } from './utils/createUid';
|
||||
@ -312,7 +312,7 @@ const reducer = (state = initialState, action) =>
|
||||
|
||||
if (optionDefaults.length) {
|
||||
optionDefaults.forEach(({ name, defaultValue }) =>
|
||||
_.set(draftState.modifiedData, name, defaultValue)
|
||||
set(draftState.modifiedData, name, defaultValue)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
import { startsWith } from 'lodash';
|
||||
|
||||
const openWithNewTab = (path) => {
|
||||
const url = (() => {
|
||||
if (startsWith(path, '/')) {
|
||||
if (path.startsWith('/')) {
|
||||
return `${strapi.backendURL}${path}`;
|
||||
}
|
||||
if (startsWith(path, 'https') || startsWith(path, 'http')) {
|
||||
|
||||
if (path.startsWith('http')) {
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import { getType, getOtherInfos } from '@strapi/helper-plugin';
|
||||
|
||||
const removePasswordAndRelationsFieldFromData = (data, contentTypeSchema, componentSchema) => {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { has } from 'lodash';
|
||||
|
||||
const extendCTBInitialDataMiddleware = () => {
|
||||
return () => (next) => (action) => {
|
||||
if (
|
||||
@ -20,7 +18,7 @@ const extendCTBInitialDataMiddleware = () => {
|
||||
|
||||
// Override the action if the pluginOption config does not contain i18n
|
||||
// In this case we need to set the proper initialData shape
|
||||
if (!has(action.data.pluginOptions, 'i18n.localized')) {
|
||||
if (!action.data.pluginOptions?.i18n?.localized) {
|
||||
return next({ ...action, data });
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
import { has, get, omit } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import has from 'lodash/has';
|
||||
import omit from 'lodash/omit';
|
||||
|
||||
import LOCALIZED_FIELDS from './localizedFields';
|
||||
|
||||
const localizedPath = ['pluginOptions', 'i18n', 'localized'];
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import { get } from 'lodash';
|
||||
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';
|
||||
|
@ -1,7 +1,10 @@
|
||||
import React from 'react';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { Typography, Flex, GridItem } from '@strapi/design-system';
|
||||
import { get, isEmpty, without } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import without from 'lodash/without';
|
||||
|
||||
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
||||
import BoundRoute from '../BoundRoute';
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* eslint-disable consistent-return */
|
||||
import produce from 'immer';
|
||||
import { set, get, take } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import set from 'lodash/set';
|
||||
import take from 'lodash/take';
|
||||
|
||||
export const initialState = {
|
||||
initialData: {},
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useReducer } from 'react';
|
||||
import { useNotification, useFetchClient } from '@strapi/helper-plugin';
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import init from './init';
|
||||
import pluginId from '../../pluginId';
|
||||
import { cleanPermissions } from '../../utils';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { useEffect, useReducer, useRef } from 'react';
|
||||
import { request, useNotification } from '@strapi/helper-plugin';
|
||||
import { get } from 'lodash';
|
||||
import get from 'lodash/get';
|
||||
import init from './init';
|
||||
import pluginId from '../../pluginId';
|
||||
import reducer, { initialState } from './reducer';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import produce from 'immer';
|
||||
import { set } from 'lodash';
|
||||
import set from 'lodash/set';
|
||||
|
||||
const initialState = {
|
||||
formErrors: {},
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { sortBy } from 'lodash';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
|
||||
const createProvidersArray = (data) => {
|
||||
return sortBy(
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { isEmpty } from 'lodash';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
|
||||
const cleanPermissions = (permissions) =>
|
||||
Object.keys(permissions).reduce((acc, current) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user