mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 19:36:20 +00:00
CM: DynamicTable - Move review workflow column code into ee folder
This commit is contained in:
parent
ae9f809389
commit
573e345e51
@ -0,0 +1,2 @@
|
|||||||
|
// Overwritten in EE
|
||||||
|
export default () => null;
|
||||||
@ -1 +0,0 @@
|
|||||||
export * from './ReviewWorkflowsStage';
|
|
||||||
@ -4,6 +4,7 @@ import { useIntl } from 'react-intl';
|
|||||||
import { DynamicTable as Table, useStrapiApp } from '@strapi/helper-plugin';
|
import { DynamicTable as Table, useStrapiApp } from '@strapi/helper-plugin';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
|
|
||||||
|
import getReviewWorkflowsColumn from 'ee_else_ce/content-manager/components/DynamicTable/CellContent/ReviewWorkflowsStage/getTableColumn';
|
||||||
import { INJECT_COLUMN_IN_TABLE } from '../../../exposedHooks';
|
import { INJECT_COLUMN_IN_TABLE } from '../../../exposedHooks';
|
||||||
import { selectDisplayedHeaders } from '../../pages/ListView/selectors';
|
import { selectDisplayedHeaders } from '../../pages/ListView/selectors';
|
||||||
import { getTrad } from '../../utils';
|
import { getTrad } from '../../utils';
|
||||||
@ -11,7 +12,6 @@ import TableRows from './TableRows';
|
|||||||
import ConfirmDialogDeleteAll from './ConfirmDialogDeleteAll';
|
import ConfirmDialogDeleteAll from './ConfirmDialogDeleteAll';
|
||||||
import ConfirmDialogDelete from './ConfirmDialogDelete';
|
import ConfirmDialogDelete from './ConfirmDialogDelete';
|
||||||
import { PublicationState } from './CellContent/PublicationState/PublicationState';
|
import { PublicationState } from './CellContent/PublicationState/PublicationState';
|
||||||
import { ReviewWorkflowsStage } from './CellContent/ReviewWorkflowsStage';
|
|
||||||
|
|
||||||
const DynamicTable = ({
|
const DynamicTable = ({
|
||||||
canCreate,
|
canCreate,
|
||||||
@ -27,7 +27,6 @@ const DynamicTable = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const { runHookWaterfall } = useStrapiApp();
|
const { runHookWaterfall } = useStrapiApp();
|
||||||
const hasDraftAndPublish = layout.contentType.options?.draftAndPublish ?? false;
|
const hasDraftAndPublish = layout.contentType.options?.draftAndPublish ?? false;
|
||||||
const hasReviewWorkflows = layout.contentType.options?.reviewWorkflows ?? false;
|
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const displayedHeaders = useSelector(selectDisplayedHeaders);
|
const displayedHeaders = useSelector(selectDisplayedHeaders);
|
||||||
|
|
||||||
@ -74,36 +73,19 @@ const DynamicTable = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasReviewWorkflows) {
|
// this should not exist. Ideally we would use registerHook() similar to what has been done
|
||||||
formattedHeaders.push({
|
// in the i18n plugin. In order to do that review-workflows should have been a plugin. In
|
||||||
key: '__strapi_reviewWorkflows_stage_temp_key__',
|
// a future iteration we need to find a better pattern.
|
||||||
name: 'strapi_reviewWorkflows_stage',
|
|
||||||
fieldSchema: {
|
// In CE this will return null - in EE a column definition including the custom formatting component.
|
||||||
type: 'custom',
|
const reviewWorkflowColumn = getReviewWorkflowsColumn(layout);
|
||||||
},
|
|
||||||
metadatas: {
|
if (reviewWorkflowColumn) {
|
||||||
label: formatMessage({
|
formattedHeaders.push(reviewWorkflowColumn);
|
||||||
id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.stage`),
|
|
||||||
defaultMessage: 'Review stage',
|
|
||||||
}),
|
|
||||||
searchable: false,
|
|
||||||
sortable: false,
|
|
||||||
},
|
|
||||||
cellFormatter({ strapi_reviewWorkflows_stage }) {
|
|
||||||
return <ReviewWorkflowsStage name={strapi_reviewWorkflows_stage.name} />;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return formattedHeaders;
|
return formattedHeaders;
|
||||||
}, [
|
}, [runHookWaterfall, displayedHeaders, layout, hasDraftAndPublish, formatMessage]);
|
||||||
runHookWaterfall,
|
|
||||||
displayedHeaders,
|
|
||||||
layout,
|
|
||||||
hasDraftAndPublish,
|
|
||||||
hasReviewWorkflows,
|
|
||||||
formatMessage,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Typography } from '@strapi/design-system';
|
import { Typography } from '@strapi/design-system';
|
||||||
|
|
||||||
export function ReviewWorkflowsStage({ name }) {
|
export function ReviewWorkflowsStageEE({ name }) {
|
||||||
return (
|
return (
|
||||||
<Typography fontWeight="regular" textColor="neutral700">
|
<Typography fontWeight="regular" textColor="neutral700">
|
||||||
{name}
|
{name}
|
||||||
@ -10,6 +10,6 @@ export function ReviewWorkflowsStage({ name }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReviewWorkflowsStage.propTypes = {
|
ReviewWorkflowsStageEE.propTypes = {
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { useIntl } from 'react-intl';
|
||||||
|
|
||||||
|
import ReviewWorkflowsStage from '.';
|
||||||
|
import getTrad from '../../../../../../../admin/src/content-manager/utils/getTrad';
|
||||||
|
|
||||||
|
export default (layout) => {
|
||||||
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
|
// TODO: As soon as the feature was enabled in EE mode, the BE currently does not have a way to send
|
||||||
|
// `false` once a user is in CE mode again. We shouldn't have to perform the window.strapi.isEE check here
|
||||||
|
// and it is meant to be in interim solution until we find a better one.
|
||||||
|
const hasReviewWorkflows =
|
||||||
|
(window.strapi.isEE && layout.contentType.options?.reviewWorkflows) ?? false;
|
||||||
|
|
||||||
|
if (!hasReviewWorkflows) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
key: '__strapi_reviewWorkflows_stage_temp_key__',
|
||||||
|
name: 'strapi_reviewWorkflows_stage',
|
||||||
|
fieldSchema: {
|
||||||
|
type: 'custom',
|
||||||
|
},
|
||||||
|
metadatas: {
|
||||||
|
label: formatMessage({
|
||||||
|
id: getTrad(`containers.ListPage.table-headers.reviewWorkflows.stage`),
|
||||||
|
defaultMessage: 'Review stage',
|
||||||
|
}),
|
||||||
|
searchable: false,
|
||||||
|
sortable: false,
|
||||||
|
},
|
||||||
|
cellFormatter({ strapi_reviewWorkflows_stage }) {
|
||||||
|
return <ReviewWorkflowsStage name={strapi_reviewWorkflows_stage.name} />;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import { ReviewWorkflowsStageEE } from './ReviewWorkflowsStageEE';
|
||||||
|
|
||||||
|
export default ReviewWorkflowsStageEE;
|
||||||
@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
|
|||||||
import { ThemeProvider, lightTheme } from '@strapi/design-system';
|
import { ThemeProvider, lightTheme } from '@strapi/design-system';
|
||||||
import { IntlProvider } from 'react-intl';
|
import { IntlProvider } from 'react-intl';
|
||||||
|
|
||||||
import { ReviewWorkflowsStage } from '..';
|
import ReviewWorkflowsStage from '..';
|
||||||
|
|
||||||
const ComponentFixture = (props) => (
|
const ComponentFixture = (props) => (
|
||||||
<ThemeProvider theme={lightTheme}>
|
<ThemeProvider theme={lightTheme}>
|
||||||
Loading…
x
Reference in New Issue
Block a user