[DS] Typography Users&Permissions/Roles (#11569)

* create a role done

* edit a role done

* list page done

* updated tests

* feedback fix

* updated tests
This commit is contained in:
ronronscelestes 2021-11-15 18:27:32 +01:00 committed by GitHub
parent 8367872c74
commit daf2e5010d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 222 additions and 234 deletions

View File

@ -1,13 +1,19 @@
import React from 'react';
import styled from 'styled-components';
import { Stack } from '@strapi/design-system/Stack';
import { Box } from '@strapi/design-system/Box';
import { H3, Text } from '@strapi/design-system/Text';
import { Typography } from '@strapi/design-system/Typography';
import map from 'lodash/map';
import tail from 'lodash/tail';
import { useIntl } from 'react-intl';
import PropTypes from 'prop-types';
import getMethodColor from './getMethodColor';
const MethodBox = styled(Box)`
margin: -1px;
border-radius: ${({ theme }) => theme.spaces[1]} 0 0 ${({ theme }) => theme.spaces[1]};
`;
function BoundRoute({ route }) {
const { formatMessage } = useIntl();
@ -18,41 +24,31 @@ function BoundRoute({ route }) {
return (
<Stack size={2}>
<H3>
<Typography variant="delta" as="h3">
{formatMessage({
id: 'users-permissions.BoundRoute.title',
defaultMessage: 'Bound route to',
})}
&nbsp;
<span>{controller}</span>
<Text style={{ fontSize: 'inherit', fontWeight: 'inherit' }} textColor="primary600">
<Typography variant="delta" textColor="primary600">
.{action}
</Text>
</H3>
<Box hasRadius background="neutral0" borderColor="neutral200">
<Box
color={colors.text}
background={colors.background}
borderColor={colors.border}
padding={2}
hasRadius
style={{
display: 'inline-block',
margin: '-1px',
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
}}
>
<Text bold>{method}</Text>
</Box>
<Box style={{ display: 'inline-block' }} paddingLeft={2} paddingRight={2}>
</Typography>
</Typography>
<Stack horizontal hasRadius background="neutral0" borderColor="neutral200" size={0}>
<MethodBox background={colors.background} borderColor={colors.border} padding={2}>
<Typography fontWeight="bold" textColor={colors.text}>
{method}
</Typography>
</MethodBox>
<Box paddingLeft={2} paddingRight={2}>
{map(formattedRoute, value => (
<Text key={value} textColor={value.includes(':') ? 'neutral600' : 'neutral900'}>
<Typography key={value} textColor={value.includes(':') ? 'neutral600' : 'neutral900'}>
/{value}
</Text>
</Typography>
))}
</Box>
</Box>
</Stack>
</Stack>
);
}

View File

@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { Box } from '@strapi/design-system/Box';
import { Checkbox } from '@strapi/design-system/Checkbox';
import { Flex } from '@strapi/design-system/Flex';
import { TableLabel } from '@strapi/design-system/Text';
import { Typography } from '@strapi/design-system/Typography';
import { Grid, GridItem } from '@strapi/design-system/Grid';
import CogIcon from '@strapi/icons/Cog';
import { useIntl } from 'react-intl';
@ -61,7 +61,9 @@ const SubCategory = ({ subCategory }) => {
<Box>
<Flex justifyContent="space-between" alignItems="center">
<Box paddingRight={4}>
<TableLabel textColor="neutral600">{subCategory.label}</TableLabel>
<Typography variant="sigma" textColor="neutral600">
{subCategory.label}
</Typography>
</Box>
<Border />
<Box paddingLeft={4}>

View File

@ -1,6 +1,6 @@
import React from 'react';
import { useIntl } from 'react-intl';
import { H3, Text } from '@strapi/design-system/Text';
import { Typography } from '@strapi/design-system/Typography';
import { Stack } from '@strapi/design-system/Stack';
import { GridItem } from '@strapi/design-system/Grid';
import { get, isEmpty, takeRight, toLower, without } from 'lodash';
@ -35,19 +35,19 @@ const Policies = () => {
</Stack>
) : (
<Stack size={2}>
<H3>
<Typography variant="delta" as="h3">
{formatMessage({
id: 'users-permissions.Policies.header.title',
defaultMessage: 'Advanced settings',
})}
</H3>
<Text as="p" textColor="neutral600">
</Typography>
<Typography as="p" textColor="neutral600">
{formatMessage({
id: 'users-permissions.Policies.header.hint',
defaultMessage:
"Select the application's actions or the plugin's actions and click on the cog icon to display the bound route",
})}
</Text>
</Typography>
</Stack>
)}
</GridItem>

View File

@ -1,6 +1,6 @@
import React, { memo, useReducer, useCallback, forwardRef, useImperativeHandle } from 'react';
import PropTypes from 'prop-types';
import { H3, Text } from '@strapi/design-system/Text';
import { Typography } from '@strapi/design-system/Typography';
import { Stack } from '@strapi/design-system/Stack';
import { Grid, GridItem } from '@strapi/design-system/Grid';
import { useIntl } from 'react-intl';
@ -67,18 +67,18 @@ const UsersPermissions = forwardRef(({ permissions, routes }, ref) => {
<GridItem col={7} paddingTop={6} paddingBottom={6} paddingLeft={7} paddingRight={7}>
<Stack size={4}>
<Stack size={2}>
<H3 as="h2">
<Typography variant="delta" as="h2">
{formatMessage({
id: getTrad('Plugins.header.title'),
defaultMessage: 'Permissions',
})}
</H3>
<Text as="p" textColor="neutral600">
</Typography>
<Typography as="p" textColor="neutral600">
{formatMessage({
id: getTrad('Plugins.header.description'),
defaultMessage: 'Only actions bound by a route are listed below.',
})}
</Text>
</Typography>
</Stack>
<Permissions />
</Stack>

View File

@ -7,7 +7,7 @@ import { Stack } from '@strapi/design-system/Stack';
import { Box } from '@strapi/design-system/Box';
import { TextInput } from '@strapi/design-system/TextInput';
import { Textarea } from '@strapi/design-system/Textarea';
import { H3 } from '@strapi/design-system/Text';
import { Typography } from '@strapi/design-system/Typography';
import Check from '@strapi/icons/Check';
import { GridItem, Grid } from '@strapi/design-system/Grid';
import { Formik } from 'formik';
@ -113,12 +113,12 @@ const EditPage = () => {
paddingRight={7}
>
<Stack size={4}>
<H3 as="h2">
<Typography variant="delta" as="h2">
{formatMessage({
id: getTrad('EditPage.form.roles'),
defaultMessage: 'Role details',
})}
</H3>
</Typography>
<Grid gap={4}>
<GridItem col={6}>
<TextInput

View File

@ -580,17 +580,16 @@ describe('Admin | containers | RoleCreatePage', () => {
}
.c17 {
color: #32324d;
font-weight: 500;
font-size: 1rem;
line-height: 1.25;
color: #32324d;
}
.c37 {
font-weight: 400;
color: #666687;
font-size: 0.875rem;
line-height: 1.43;
color: #666687;
}
.c32 {
@ -745,7 +744,7 @@ describe('Admin | containers | RoleCreatePage', () => {
border: 1px solid #4945ff;
}
.c39:hover:not([aria-disabled='true']) .sc-joeujd {
.c39:hover:not([aria-disabled='true']) .sc-eiWPNw {
color: #271fe0;
}

View File

@ -6,7 +6,7 @@ import { Stack } from '@strapi/design-system/Stack';
import { Box } from '@strapi/design-system/Box';
import { TextInput } from '@strapi/design-system/TextInput';
import { Textarea } from '@strapi/design-system/Textarea';
import { H3 } from '@strapi/design-system/Text';
import { Typography } from '@strapi/design-system/Typography';
import ArrowLeft from '@strapi/icons/ArrowLeft';
import Check from '@strapi/icons/Check';
import { Link } from '@strapi/design-system/Link';
@ -126,12 +126,12 @@ const EditPage = () => {
paddingRight={7}
>
<Stack size={4}>
<H3 as="h2">
<Typography variant="delta" as="h2">
{formatMessage({
id: getTrad('EditPage.form.roles'),
defaultMessage: 'Role details',
})}
</H3>
</Typography>
<Grid gap={4}>
<GridItem col={6}>
<TextInput

View File

@ -579,17 +579,16 @@ describe('Admin | containers | RoleEditPage', () => {
}
.c22 {
color: #32324d;
font-weight: 500;
font-size: 1rem;
line-height: 1.25;
color: #32324d;
}
.c42 {
font-weight: 400;
color: #666687;
font-size: 0.875rem;
line-height: 1.43;
color: #666687;
}
.c6 {
@ -817,7 +816,7 @@ describe('Admin | containers | RoleEditPage', () => {
border: 1px solid #4945ff;
}
.c44:hover:not([aria-disabled='true']) .sc-iAjLmB {
.c44:hover:not([aria-disabled='true']) .sc-heejUR {
color: #271fe0;
}

View File

@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { IconButton } from '@strapi/design-system/IconButton';
import { Text } from '@strapi/design-system/Text';
import { Typography } from '@strapi/design-system/Typography';
import { Flex } from '@strapi/design-system/Flex';
import { Tbody, Tr, Td } from '@strapi/design-system/Table';
import Pencil from '@strapi/icons/Pencil';
@ -34,18 +34,18 @@ const TableBody = ({ sortedRoles, canDelete, permissions, setRoleToDelete, onDel
{sortedRoles?.map(role => (
<Tr key={role.name} {...onRowClick({ fn: () => handleClickEdit(role.id) })}>
<Td width="20%">
<Text>{role.name}</Text>
<Typography>{role.name}</Typography>
</Td>
<Td width="50%">
<Text>{role.description}</Text>
<Typography>{role.description}</Typography>
</Td>
<Td width="30%">
<Text>
<Typography>
{`${role.nb_users} ${formatMessage({
id: getTrad('Roles.users'),
defaultMessage: 'users',
}).toLowerCase()}`}
</Text>
</Typography>
</Td>
<Td>
<Flex justifyContent="end" {...stopPropagation}>

View File

@ -1,19 +1,11 @@
import React, { useMemo, useState } from 'react';
import {
Button,
HeaderLayout,
Layout,
Main,
Table,
Tr,
Thead,
Th,
TableLabel,
useNotifyAT,
ContentLayout,
ActionLayout,
VisuallyHidden,
} from '@strapi/design-system';
import { Button } from '@strapi/design-system/Button';
import { HeaderLayout, Layout, ContentLayout, ActionLayout } from '@strapi/design-system/Layout';
import { Main } from '@strapi/design-system/Main';
import { Table, Tr, Thead, Th } from '@strapi/design-system/Table';
import { VisuallyHidden } from '@strapi/design-system/VisuallyHidden';
import { Typography } from '@strapi/design-system/Typography';
import { useNotifyAT } from '@strapi/design-system/LiveRegions';
import Plus from '@strapi/icons/Plus';
import {
useTracking,
@ -166,25 +158,25 @@ const RoleListPage = () => {
<Thead>
<Tr>
<Th>
<TableLabel textColor="neutral600">
<Typography variant="sigma" textColor="neutral600">
{formatMessage({ id: getTrad('Roles.name'), defaultMessage: 'Name' })}
</TableLabel>
</Typography>
</Th>
<Th>
<TableLabel textColor="neutral600">
<Typography variant="sigma" textColor="neutral600">
{formatMessage({
id: getTrad('Roles.description'),
defaultMessage: 'Description',
})}
</TableLabel>
</Typography>
</Th>
<Th>
<TableLabel textColor="neutral600">
<Typography variant="sigma" textColor="neutral600">
{formatMessage({
id: getTrad('Roles.users'),
defaultMessage: 'Users',
})}
</TableLabel>
</Typography>
</Th>
<Th>
<VisuallyHidden>

View File

@ -58,13 +58,6 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
} = render(App);
expect(firstChild).toMatchInlineSnapshot(`
.c9 {
color: #32324d;
font-weight: 600;
font-size: 2rem;
line-height: 1.25;
}
.c14 {
font-weight: 600;
color: #32324d;
@ -72,105 +65,11 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
line-height: 1.43;
}
.c15 {
color: #666687;
font-size: 1rem;
line-height: 1.5;
}
.c2 {
padding-bottom: 56px;
}
.c5 {
background: #f6f6f9;
padding-top: 56px;
padding-right: 56px;
padding-bottom: 56px;
padding-left: 56px;
}
.c12 {
.c11 {
padding-right: 8px;
}
.c16 {
padding-right: 56px;
padding-left: 56px;
}
.c17 {
padding-bottom: 16px;
}
.c6 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c7 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c18 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: flex-start;
-webkit-box-align: flex-start;
-ms-flex-align: flex-start;
align-items: flex-start;
}
.c19 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.c10 {
.c8 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
@ -184,21 +83,21 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
outline: none;
}
.c10 svg {
.c8 svg {
height: 12px;
width: 12px;
}
.c10 svg > g,
.c10 svg path {
.c8 svg > g,
.c8 svg path {
fill: #ffffff;
}
.c10[aria-disabled='true'] {
.c8[aria-disabled='true'] {
pointer-events: none;
}
.c10:after {
.c8:after {
-webkit-transition-property: all;
transition-property: all;
-webkit-transition-duration: 0.2s;
@ -213,11 +112,11 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
border: 2px solid transparent;
}
.c10:focus-visible {
.c8:focus-visible {
outline: none;
}
.c10:focus-visible:after {
.c8:focus-visible:after {
border-radius: 8px;
content: '';
position: absolute;
@ -228,11 +127,11 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
border: 2px solid #4945ff;
}
.c13 {
.c12 {
height: 100%;
}
.c11 {
.c9 {
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
@ -244,7 +143,7 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
background: #4945ff;
}
.c11 .c0 {
.c9 .c10 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
@ -255,65 +154,48 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
align-items: center;
}
.c11 .c8 {
.c9 .c13 {
color: #ffffff;
}
.c11[aria-disabled='true'] {
.c9[aria-disabled='true'] {
border: 1px solid #dcdce4;
background: #eaeaef;
}
.c11[aria-disabled='true'] .c8 {
.c9[aria-disabled='true'] .c13 {
color: #666687;
}
.c11[aria-disabled='true'] svg > g,
.c11[aria-disabled='true'] svg path {
.c9[aria-disabled='true'] svg > g,
.c9[aria-disabled='true'] svg path {
fill: #666687;
}
.c11[aria-disabled='true']:active {
.c9[aria-disabled='true']:active {
border: 1px solid #dcdce4;
background: #eaeaef;
}
.c11[aria-disabled='true']:active .c8 {
.c9[aria-disabled='true']:active .c13 {
color: #666687;
}
.c11[aria-disabled='true']:active svg > g,
.c11[aria-disabled='true']:active svg path {
.c9[aria-disabled='true']:active svg > g,
.c9[aria-disabled='true']:active svg path {
fill: #666687;
}
.c11:hover {
.c9:hover {
border: 1px solid #7b79ff;
background: #7b79ff;
}
.c11:active {
.c9:active {
border: 1px solid #4945ff;
background: #4945ff;
}
.c1 {
display: grid;
grid-template-columns: 1fr;
}
.c3 {
overflow-x: hidden;
}
.c20 > * + * {
margin-left: 8px;
}
.c4 {
outline: none;
}
.c32 {
color: #666687;
font-weight: 500;
@ -492,16 +374,134 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
height: 100vh;
}
.c1 {
padding-bottom: 56px;
}
.c4 {
background: #f6f6f9;
padding-top: 56px;
padding-right: 56px;
padding-bottom: 56px;
padding-left: 56px;
}
.c16 {
padding-right: 56px;
padding-left: 56px;
}
.c17 {
padding-bottom: 16px;
}
.c0 {
display: grid;
grid-template-columns: 1fr;
}
.c2 {
overflow-x: hidden;
}
.c5 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c6 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.c18 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-align-items: flex-start;
-webkit-box-align: flex-start;
-ms-flex-align: flex-start;
align-items: flex-start;
}
.c19 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.c20 > * + * {
margin-left: 8px;
}
.c7 {
color: #32324d;
font-weight: 600;
font-size: 2rem;
line-height: 1.25;
}
.c15 {
color: #666687;
font-size: 1rem;
line-height: 1.5;
}
.c3 {
outline: none;
}
<div
class="c0 c1"
class="c0"
>
<div
class="c0 c2 c3"
class="c1 c2"
>
<main
aria-busy="true"
aria-labelledby="main-content-title"
class="c4"
class="c3"
id="main-content"
tabindex="-1"
>
@ -509,29 +509,29 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
style="height: 0px;"
>
<div
class="c0 c5"
class="c4"
data-strapi-header="true"
>
<div
class="c0 c6"
class="c5"
>
<div
class="c0 c7"
class="c6"
>
<h1
class="c8 c9"
class="c7"
>
Roles
</h1>
</div>
<button
aria-disabled="false"
class="c10 c11"
class="c8 c9"
type="button"
>
<div
aria-hidden="true"
class="c0 c12 c13"
class="c10 c11 c12"
>
<svg
fill="none"
@ -547,30 +547,30 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
</svg>
</div>
<span
class="c8 c14"
class="c13 c14"
>
Add new role
</span>
</button>
</div>
<p
class="c8 c15"
class="c15"
>
List of roles
</p>
</div>
</div>
<div
class="c0 c16"
class="c16"
>
<div
class="c0 c17"
class="c17"
>
<div
class="c0 c18"
class="c18"
>
<div
class="c0 c19 c20"
class="c19 c20"
wrap="wrap"
>
<span>
@ -602,7 +602,7 @@ describe('Plugin | Users and Permissions | RoleListPage', () => {
</div>
</div>
<div
class="c0 c16"
class="c16"
>
<div
class="c23 c24"