-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Chore: Refactor CM list-view review-workflow columns to use useEnterprise #17047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b88b9e8
19d827b
e0c7d79
009f770
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,36 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { BaseCheckbox, IconButton, Tbody, Td, Tr, Flex } from '@strapi/design-system'; | ||
| import { | ||
| BaseCheckbox, | ||
| IconButton, | ||
| Tbody, | ||
| Td, | ||
| Tr, | ||
| Flex, | ||
| lightTheme, | ||
| Status, | ||
| Typography, | ||
| } from '@strapi/design-system'; | ||
| import { useTracking, useFetchClient, useAPIErrorHandler } from '@strapi/helper-plugin'; | ||
| import { Trash, Duplicate, Pencil } from '@strapi/icons'; | ||
| import { AxiosError } from 'axios'; | ||
| import PropTypes from 'prop-types'; | ||
| import { useIntl } from 'react-intl'; | ||
| import { Link, useHistory } from 'react-router-dom'; | ||
|
|
||
| import { useEnterprise } from '../../../../../hooks/useEnterprise'; | ||
| import { getFullName } from '../../../../../utils'; | ||
| import { usePluginsQueryParams } from '../../../../hooks'; | ||
| import { getTrad } from '../../../../utils'; | ||
| import CellContent from '../CellContent'; | ||
|
|
||
| const REVIEW_WORKFLOW_COLUMNS_CE = () => null; | ||
|
|
||
| export const TableRows = ({ | ||
| canCreate, | ||
| canDelete, | ||
| contentType, | ||
| features: { hasDraftAndPublish, hasReviewWorkflows }, | ||
| headers, | ||
| entriesToDelete, | ||
| onClickDelete, | ||
|
|
@@ -33,6 +47,18 @@ export const TableRows = ({ | |
| const { trackUsage } = useTracking(); | ||
| const pluginsQueryParams = usePluginsQueryParams(); | ||
| const { formatAPIError } = useAPIErrorHandler(getTrad); | ||
| const ReviewWorkflowsStage = useEnterprise( | ||
| REVIEW_WORKFLOW_COLUMNS_CE, | ||
| async () => | ||
| ( | ||
| await import( | ||
| '../../../../../../../ee/admin/content-manager/pages/ListView/ReviewWorkflowsColumn' | ||
| ) | ||
| ).ReviewWorkflowsStageEE, | ||
| { | ||
| enabled: hasReviewWorkflows, | ||
| } | ||
| ); | ||
|
|
||
| /** | ||
| * | ||
|
|
@@ -74,6 +100,11 @@ export const TableRows = ({ | |
| } | ||
| }; | ||
|
|
||
| // block rendering until the review stage component is fully loaded in EE | ||
| if (!ReviewWorkflowsStage) { | ||
| return null; | ||
| } | ||
|
|
||
|
Comment on lines
+104
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't block rednering on content-types that don't have review workflows enabled 🤔? Maybe also check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In CE the component will be defined (so this condition won't match), but in EE |
||
| /** | ||
| * Table Cells with actions e.g edit, delete, duplicate have `stopPropagation` | ||
| * to prevent the row from being selected. | ||
|
|
@@ -113,20 +144,59 @@ export const TableRows = ({ | |
| /> | ||
| </Td> | ||
| )} | ||
|
|
||
| {headers.map(({ key, cellFormatter, name, ...rest }) => { | ||
| if (hasDraftAndPublish && name === 'publishedAt') { | ||
| return ( | ||
| <Td key={key}> | ||
| <Status | ||
| width="min-content" | ||
| showBullet={false} | ||
| variant={data.publishedAt ? 'success' : 'secondary'} | ||
| size="S" | ||
| > | ||
| <Typography | ||
| fontWeight="bold" | ||
| textColor={`${data.publishedAt ? 'success' : 'secondary'}700`} | ||
| > | ||
| {formatMessage({ | ||
| id: getTrad( | ||
| `containers.List.${data.publishedAt ? 'published' : 'draft'}` | ||
| ), | ||
| defaultMessage: data.publishedAt ? 'Published' : 'Draft', | ||
| })} | ||
| </Typography> | ||
| </Status> | ||
| </Td> | ||
| ); | ||
| } | ||
|
|
||
| if (hasReviewWorkflows && name === 'strapi_reviewWorkflows_stage') { | ||
| return ( | ||
| <Td key={key}> | ||
| {data.strapi_reviewWorkflows_stage ? ( | ||
| <ReviewWorkflowsStage | ||
| color={ | ||
| data.strapi_reviewWorkflows_stage.color ?? lightTheme.colors.primary600 | ||
gu-stav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| name={data.strapi_reviewWorkflows_stage.name} | ||
| /> | ||
| ) : ( | ||
| <Typography textColor="neutral800">-</Typography> | ||
| )} | ||
| </Td> | ||
| ); | ||
| } | ||
gu-stav marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return ( | ||
| <Td key={key}> | ||
| {typeof cellFormatter === 'function' ? ( | ||
| cellFormatter(data, { key, name, ...rest }) | ||
| ) : ( | ||
| <CellContent | ||
| content={data[name.split('.')[0]]} | ||
| name={name} | ||
| contentType={contentType} | ||
| {...rest} | ||
| rowId={data.id} | ||
| /> | ||
| )} | ||
| <CellContent | ||
| content={data[name.split('.')[0]]} | ||
| name={name} | ||
| contentType={contentType} | ||
| {...rest} | ||
| rowId={data.id} | ||
| /> | ||
| </Td> | ||
| ); | ||
| })} | ||
|
|
@@ -212,6 +282,10 @@ TableRows.propTypes = { | |
| uid: PropTypes.string.isRequired, | ||
| }).isRequired, | ||
| entriesToDelete: PropTypes.array, | ||
| features: PropTypes.shape({ | ||
| hasDraftAndPublish: PropTypes.bool.isRequired, | ||
| hasReviewWorkflows: PropTypes.bool.isRequired, | ||
| }).isRequired, | ||
| headers: PropTypes.array.isRequired, | ||
| onClickDelete: PropTypes.func, | ||
| onSelectRow: PropTypes.func, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would a good example of this be where the EE addition is unique to a feature being enabled as opposed to EE in general?