mirror of
https://github.com/strapi/strapi.git
synced 2025-09-28 18:01:26 +00:00
Fix PR feedback
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
4b528451ba
commit
78fa5374a5
@ -1,4 +1,4 @@
|
|||||||
import React, { memo, useCallback, useMemo, useState } from 'react';
|
import React, { memo, useMemo, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import { Flex, Text } from '@buffetjs/core';
|
import { Flex, Text } from '@buffetjs/core';
|
||||||
@ -34,7 +34,7 @@ const SubActionRow = ({
|
|||||||
} = usePermissionsDataManager();
|
} = usePermissionsDataManager();
|
||||||
const [rowToOpen, setRowToOpen] = useState(null);
|
const [rowToOpen, setRowToOpen] = useState(null);
|
||||||
|
|
||||||
const handleClickToggleSubLevel = useCallback(name => {
|
const handleClickToggleSubLevel = name => {
|
||||||
setRowToOpen(prev => {
|
setRowToOpen(prev => {
|
||||||
if (prev === name) {
|
if (prev === name) {
|
||||||
return null;
|
return null;
|
||||||
@ -42,7 +42,7 @@ const SubActionRow = ({
|
|||||||
|
|
||||||
return name;
|
return name;
|
||||||
});
|
});
|
||||||
}, []);
|
};
|
||||||
|
|
||||||
const displayedRecursiveChildren = useMemo(() => {
|
const displayedRecursiveChildren = useMemo(() => {
|
||||||
if (!rowToOpen) {
|
if (!rowToOpen) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import generateHeadersFromActions from '../generateHeadersFromActions';
|
import generateHeadersFromActions from '../generateHeadersFromActions';
|
||||||
|
|
||||||
describe('ADMIN | COMPONENTS | Permissions | CollapsePropertyMatrix | utils', () => {
|
describe('ADMIN | COMPONENTS | Permissions | CollapsePropertyMatrix | utils', () => {
|
||||||
it('should set isActionRelatedToCurrentProperty key to false if the applyToProperties is not an array', () => {
|
it('should set isActionRelatedToCurrentProperty key to false when the applyToProperties is not an array', () => {
|
||||||
const data = [{ label: 'test' }, { label: 'test1' }];
|
const data = [{ label: 'test' }, { label: 'test1' }];
|
||||||
const expected = [
|
const expected = [
|
||||||
{ label: 'test', isActionRelatedToCurrentProperty: false, actionId: undefined },
|
{ label: 'test', isActionRelatedToCurrentProperty: false, actionId: undefined },
|
||||||
@ -11,7 +11,7 @@ describe('ADMIN | COMPONENTS | Permissions | CollapsePropertyMatrix | utils', ()
|
|||||||
expect(generateHeadersFromActions(data, 'test')).toEqual(expected);
|
expect(generateHeadersFromActions(data, 'test')).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set isActionRelatedToCurrentProperty key to false if the propertyName is not in the applyToProperties array', () => {
|
it('should set isActionRelatedToCurrentProperty key to false when the propertyName is not in the applyToProperties array', () => {
|
||||||
const data = [
|
const data = [
|
||||||
{ label: 'test', applyToProperties: ['foo'], actionId: 'test' },
|
{ label: 'test', applyToProperties: ['foo'], actionId: 'test' },
|
||||||
{ label: 'test1', applyToProperties: ['foo'], actionId: 'test' },
|
{ label: 'test1', applyToProperties: ['foo'], actionId: 'test' },
|
||||||
@ -24,7 +24,7 @@ describe('ADMIN | COMPONENTS | Permissions | CollapsePropertyMatrix | utils', ()
|
|||||||
expect(generateHeadersFromActions(data, 'test')).toEqual(expected);
|
expect(generateHeadersFromActions(data, 'test')).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set isActionRelatedToCurrentProperty key to false if the isDisplayed key is falsy', () => {
|
it('should set isActionRelatedToCurrentProperty key to false when the isDisplayed key is falsy', () => {
|
||||||
const data = [
|
const data = [
|
||||||
{ label: 'test', isDisplayed: false, actionId: 'test' },
|
{ label: 'test', isDisplayed: false, actionId: 'test' },
|
||||||
{ label: 'test1', isDisplayed: false, actionId: 'test' },
|
{ label: 'test1', isDisplayed: false, actionId: 'test' },
|
||||||
@ -37,7 +37,7 @@ describe('ADMIN | COMPONENTS | Permissions | CollapsePropertyMatrix | utils', ()
|
|||||||
expect(generateHeadersFromActions(data, 'test')).toEqual(expected);
|
expect(generateHeadersFromActions(data, 'test')).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the isActionRelatedToCurrentProperty key to true if isDisplayed is truthy and the propertyName is in the applyToProperties array', () => {
|
it('should set the isActionRelatedToCurrentProperty key to true when isDisplayed is truthy and the propertyName is in the applyToProperties array', () => {
|
||||||
const data = [
|
const data = [
|
||||||
{ label: 'test', isDisplayed: true, applyToProperties: ['test'], actionId: 'test' },
|
{ label: 'test', isDisplayed: true, applyToProperties: ['test'], actionId: 'test' },
|
||||||
{ label: 'test1', isDisplayed: false, applyToProperties: ['test'], actionId: 'test' },
|
{ label: 'test1', isDisplayed: false, applyToProperties: ['test'], actionId: 'test' },
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
import React, { memo, useCallback, useState } from 'react';
|
import React, { memo, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ContentTypeCollapse from '../ContentTypeCollapse';
|
import ContentTypeCollapse from '../ContentTypeCollapse';
|
||||||
|
|
||||||
const ContentTypeCollapses = ({ actions, pathToData, subjects }) => {
|
const ContentTypeCollapses = ({ actions, pathToData, subjects }) => {
|
||||||
const [collapseToOpen, setCollapseToOpen] = useState(null);
|
const [collapseToOpen, setCollapseToOpen] = useState(null);
|
||||||
|
|
||||||
const handleClickToggleCollapse = useCallback(
|
const handleClickToggleCollapse = collapseName => {
|
||||||
collapseName => {
|
const nextCollapseToOpen = collapseToOpen === collapseName ? null : collapseName;
|
||||||
const nextCollapseToOpen = collapseToOpen === collapseName ? null : collapseName;
|
|
||||||
|
|
||||||
setCollapseToOpen(nextCollapseToOpen);
|
setCollapseToOpen(nextCollapseToOpen);
|
||||||
},
|
};
|
||||||
[collapseToOpen]
|
|
||||||
);
|
|
||||||
|
|
||||||
return subjects.map(({ uid, label, properties }, index) => {
|
return subjects.map(({ uid, label, properties }, index) => {
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user