Fix PR feedback

Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
soupette 2021-02-15 13:31:46 +01:00
parent 4b528451ba
commit 78fa5374a5
3 changed files with 12 additions and 15 deletions

View File

@ -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 { get } from 'lodash';
import { Flex, Text } from '@buffetjs/core';
@ -34,7 +34,7 @@ const SubActionRow = ({
} = usePermissionsDataManager();
const [rowToOpen, setRowToOpen] = useState(null);
const handleClickToggleSubLevel = useCallback(name => {
const handleClickToggleSubLevel = name => {
setRowToOpen(prev => {
if (prev === name) {
return null;
@ -42,7 +42,7 @@ const SubActionRow = ({
return name;
});
}, []);
};
const displayedRecursiveChildren = useMemo(() => {
if (!rowToOpen) {

View File

@ -1,7 +1,7 @@
import generateHeadersFromActions from '../generateHeadersFromActions';
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 expected = [
{ label: 'test', isActionRelatedToCurrentProperty: false, actionId: undefined },
@ -11,7 +11,7 @@ describe('ADMIN | COMPONENTS | Permissions | CollapsePropertyMatrix | utils', ()
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 = [
{ label: 'test', 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);
});
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 = [
{ label: 'test', 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);
});
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 = [
{ label: 'test', isDisplayed: true, applyToProperties: ['test'], actionId: 'test' },
{ label: 'test1', isDisplayed: false, applyToProperties: ['test'], actionId: 'test' },

View File

@ -1,18 +1,15 @@
import React, { memo, useCallback, useState } from 'react';
import React, { memo, useState } from 'react';
import PropTypes from 'prop-types';
import ContentTypeCollapse from '../ContentTypeCollapse';
const ContentTypeCollapses = ({ actions, pathToData, subjects }) => {
const [collapseToOpen, setCollapseToOpen] = useState(null);
const handleClickToggleCollapse = useCallback(
collapseName => {
const nextCollapseToOpen = collapseToOpen === collapseName ? null : collapseName;
const handleClickToggleCollapse = collapseName => {
const nextCollapseToOpen = collapseToOpen === collapseName ? null : collapseName;
setCollapseToOpen(nextCollapseToOpen);
},
[collapseToOpen]
);
setCollapseToOpen(nextCollapseToOpen);
};
return subjects.map(({ uid, label, properties }, index) => {
return (