mirror of
https://github.com/strapi/strapi.git
synced 2025-09-03 13:50:38 +00:00
Fix: bulk publish modal and related issues (#20386)
* fix: added bulk actions * chore: migrate bulk publish & unpublish to v5 * chore: change findLocales type to accept arrays * chore: fix lint error * chore: migrate bulkDelete to v5 (#20161) * chore: migrate bulkDelete to v5 * chore: change findLocales type to accept strings array * fix: docs prettier styles * chore: remove console.log * enhancement: migrate countManyDraftRelations to v5 * feat: bulk delete with locale selection option * fix: bulk unpublish working without locale support * test: e2e tests updated * fix: documents api change, deleteMany tags updated, test skipped * chore: renaming * test: reverting e2e tests for delete action changes * feat: publish action changes * fix: reverting publish action changes * fix: hide add to release as its not ready to be migrated * fix: error message updated * fix: tests updated for useDocumentAction * fix: updated request params * fix: publish action added * fix: publish action changes with documentId * fix: reverting wrong commit message Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> * fix: comments updated * chore: renaming * chore: add type to bulk action actions (#20256) * chore: actionType renamed to just type * fix: added missing import * test: fixed * fix(content-manager): edit entry button on bulk publish modal * fix: validationError message type is not as expected * fix: ts error * only fetch entries when modal is opened * fix(content-releases): use status to show the published instead of publishedAt * fix: alignment fix, update selectedEntries to reflect count, reset selectedEntries on locale change * fix: fixed type error --------- Co-authored-by: Fernando Chavez <fernando.chavez@strapi.io> Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com>
This commit is contained in:
parent
7b7a51fc89
commit
adfa9612c9
@ -13,6 +13,7 @@ import {
|
||||
useQueryParams,
|
||||
useRBAC,
|
||||
Layouts,
|
||||
useTable,
|
||||
} from '@strapi/admin/strapi-admin';
|
||||
import { Button, Flex, Typography, ButtonProps } from '@strapi/design-system';
|
||||
import { Plus } from '@strapi/icons';
|
||||
@ -239,9 +240,7 @@ const ListViewPage = () => {
|
||||
<Layouts.Content>
|
||||
<Flex gap={4} direction="column" alignItems="stretch">
|
||||
<Table.Root rows={results} headers={tableHeaders} isLoading={isLoading}>
|
||||
<Table.ActionBar>
|
||||
<BulkActionsRenderer />
|
||||
</Table.ActionBar>
|
||||
<TableActionsBar />
|
||||
<Table.Content>
|
||||
<Table.Head>
|
||||
<Table.HeaderCheckboxCell />
|
||||
@ -330,6 +329,30 @@ const ActionsCell = styled(Table.Cell)`
|
||||
justify-content: flex-end;
|
||||
`;
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------
|
||||
* TableActionsBar
|
||||
* -----------------------------------------------------------------------------------------------*/
|
||||
|
||||
const TableActionsBar = () => {
|
||||
const selectRow = useTable('TableActionsBar', (state) => state.selectRow);
|
||||
const [{ query }] = useQueryParams<{ plugins: { i18n: { locale: string } } }>();
|
||||
const locale = query?.plugins?.i18n?.locale;
|
||||
const prevLocale = usePrev(locale);
|
||||
|
||||
// TODO: find a better way to reset the selected rows when the locale changes across all the app
|
||||
React.useEffect(() => {
|
||||
if (prevLocale !== locale) {
|
||||
selectRow([]);
|
||||
}
|
||||
}, [selectRow, prevLocale, locale]);
|
||||
|
||||
return (
|
||||
<Table.ActionBar>
|
||||
<BulkActionsRenderer />
|
||||
</Table.ActionBar>
|
||||
);
|
||||
};
|
||||
|
||||
/* -------------------------------------------------------------------------------------------------
|
||||
* CreateButton
|
||||
* -----------------------------------------------------------------------------------------------*/
|
||||
|
@ -155,7 +155,7 @@ const ConfirmDialogPublishAll = ({
|
||||
{schema?.pluginOptions &&
|
||||
'i18n' in schema.pluginOptions &&
|
||||
schema?.pluginOptions.i18n && (
|
||||
<Typography textColor="danger500">
|
||||
<Typography textColor="danger500" textAlign="center">
|
||||
{formatMessage(
|
||||
{
|
||||
id: getTranslation('Settings.list.actions.publishAdditionalInfos'),
|
||||
|
@ -333,15 +333,16 @@ const SelectedEntriesModalContent = ({
|
||||
const { publishMany: bulkPublishAction } = useDocumentActions();
|
||||
const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
|
||||
|
||||
const selectedEntries = useTable('publishAction', (state) => state.selectedRows);
|
||||
const selectedRows = useTable('publishAction', (state) => state.selectedRows);
|
||||
|
||||
const entriesToPublish = selectedEntries.reduce((acc, entry) => {
|
||||
if (!validationErrors[entry.documentId]) {
|
||||
acc.push(entry.documentId);
|
||||
}
|
||||
// Filter selected entries from the updated modal table rows
|
||||
const selectedEntries = rows.filter((entry) =>
|
||||
selectedRows.some((selectedEntry) => selectedEntry.documentId === entry.documentId)
|
||||
);
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
const entriesToPublish = selectedEntries
|
||||
.filter((entry) => !validationErrors[entry.documentId])
|
||||
.map((entry) => entry.documentId);
|
||||
|
||||
const selectedEntriesWithErrorsCount = selectedEntries.filter(
|
||||
({ documentId }) => validationErrors[documentId]
|
||||
@ -433,6 +434,7 @@ const SelectedEntriesModalContent = ({
|
||||
disabled={
|
||||
selectedEntries.length === 0 ||
|
||||
selectedEntries.length === selectedEntriesWithErrorsCount ||
|
||||
selectedEntriesPublished === selectedEntries.length ||
|
||||
isLoading
|
||||
}
|
||||
loading={isSubmittingForm}
|
||||
|
Loading…
x
Reference in New Issue
Block a user