Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-ast-locale
Browse files Browse the repository at this point in the history
  • Loading branch information
arhubi authored Mar 21, 2023
2 parents c6f94de + 69ce443 commit ec678ce
Show file tree
Hide file tree
Showing 103 changed files with 605 additions and 268 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.front.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ module.exports = {
message:
"'Stack' has been deprecated. Please import 'Flex' from '@strapi/design-system' instead.",
},
{
name: 'lodash',
message: 'Please use import [method] from lodash/[method]',
},
],
patterns: [
{
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/issues_handleLabel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
actions: 'add-assignees'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
assignees: 'derrickmehaffy, kasonde, bolg55'
assignees: 'derrickmehaffy, kasonde, bolg55, Eventyret'
random-to: 1

# v3 Legacy Issues
Expand Down Expand Up @@ -185,21 +185,21 @@ jobs:

# Auto assign issues to projects based on source
- name: assign issues to Content squad project
uses: actions/add-to-project@v0.3.0
uses: actions/add-to-project@v0.4.1
with:
project-url: https://github.com/orgs/strapi/projects/11
github-token: ${{ secrets.PROJECT_TRANSFER_TOKEN }}
labeled: 'source: core:admin, source: core:content-manager, source: core:upload, source: plugin:i18n'
label-operator: OR
- name: assign issues to DevExp squad project
uses: actions/add-to-project@v0.3.0
uses: actions/add-to-project@v0.4.1
with:
project-url: https://github.com/orgs/strapi/projects/13
github-token: ${{ secrets.PROJECT_TRANSFER_TOKEN }}
labeled: 'source: core:content-type-builder, source: core:database, source: core:email, source: core:strapi, source: core:utils, source: plugin:graphql, source: plugin:users-permissions, source: typescript, source: core:data-transfer'
label-operator: OR
- name: assign issues to Expansions squad project
uses: actions/add-to-project@v0.3.0
uses: actions/add-to-project@v0.4.1
with:
project-url: https://github.com/orgs/strapi/projects/4
github-token: ${{ secrets.PROJECT_TRANSFER_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion examples/getstarted/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"passport-google-oauth2": "0.2.0",
"pg": "8.8.0",
"react": "^17.0.2",
"react-intl": "6.2.8",
"react-intl": "6.3.2",
"sqlite3": "5.1.2"
},
"strapi": {
Expand Down
2 changes: 1 addition & 1 deletion examples/kitchensink/src/admin/app.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const config = {
},
},
tutorials: false,
notifications: { release: false },
notifications: { releases: false },
};

const bootstrap = (app) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/kitchensink/src/admin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const config = {
},
},
tutorials: false,
notifications: { release: false },
notifications: { releases: false },
};

const bootstrap = (app) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep } from 'lodash';
import cloneDeep from 'lodash/cloneDeep';
import init from '../init';
import { initialState } from '../reducer';

Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toLower } from 'lodash';
import toLower from 'lodash/toLower';

const getInputType = (type = '') => {
switch (toLower(type)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useCallback } from 'react';
import { get } from 'lodash';
import { useSelector } from 'react-redux';
import selectLayout from '../../pages/EditViewLayoutManager/selectors';

Expand All @@ -8,7 +7,7 @@ const useContentTypeLayout = () => {

const getComponentLayout = useCallback(
(componentUid) => {
return get(currentLayout, ['components', componentUid], {});
return currentLayout?.components?.[componentUid] ?? {};
},
[currentLayout]
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -14,7 +12,7 @@ const createPossibleMainFieldsForModelsAndComponents = (array) => {
'relation',
'text',
'richtext',
].includes(get(attributes, [attr, 'type'], ''));
].includes(attributes?.[attr]?.type ?? '');
});

acc[current.uid] = possibleMainFields;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEmpty } from 'lodash';
import isEmpty from 'lodash/isEmpty';
import { useCMEditViewDataManager } from '@strapi/helper-plugin';

function useSelect() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toLower } from 'lodash';
import toLower from 'lodash/toLower';

const checkIfAttributeIsDisplayable = (attribute) => {
const type = attribute.type;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get } from 'lodash';
import get from 'lodash/get';

const createDefaultForm = (attributes, allComponentsSchema) => {
return Object.keys(attributes).reduce((acc, current) => {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNaN } from 'lodash';
import isNaN from 'lodash/isNaN';

const getFieldName = (stringName) =>
stringName.split('.').filter((string) => isNaN(parseInt(string, 10)));
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/admin/src/hooks/useRegenerate/index.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/admin/admin/src/hooks/useSettingsForm/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import produce from 'immer';
import { set } from 'lodash';
import set from 'lodash/set';

const initialState = {
menu: [],
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/admin/src/pages/AuthPage/reducer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import produce from 'immer';
import { set } from 'lodash';
import set from 'lodash/set';
/* eslint-disable consistent-return */

const initialState = {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { flatten } from 'lodash';

const transformPermissionsData = (data) => {
const layout = {
allActionsIds: [],
Expand All @@ -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::')) {
Expand All @@ -25,9 +23,9 @@ const transformPermissionsData = (data) => {
actionId,
};
})
),
.flat(),
}))
),
.flat(),
}));

return layout;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get } from 'lodash';
import get from 'lodash/get';

const createConditionsForm = (conditions, valueObject) => {
return conditions.reduce((acc, current) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { get } from 'lodash';
import get from 'lodash/get';

import { getCheckboxState } from '../../../../utils';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
Loading

0 comments on commit ec678ce

Please sign in to comment.