mirror of
https://github.com/strapi/strapi.git
synced 2025-10-13 00:52:54 +00:00
fix: don't show add to release bulk actions when draft and publish di… (#23578)
* fix: don't show add to release bulk actions when draft and publish disabled * fix: force skip guided tour
This commit is contained in:
parent
26ef1c1726
commit
c72b48da73
@ -7,6 +7,7 @@ import {
|
||||
useRBAC,
|
||||
isFetchError,
|
||||
} from '@strapi/admin/strapi-admin';
|
||||
import { unstable_useContentManagerContext as useContentManagerContext } from '@strapi/content-manager/strapi-admin';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
@ -63,6 +64,7 @@ const ReleaseAction: BulkActionComponent = ({ documents, model }) => {
|
||||
const {
|
||||
allowedActions: { canCreate },
|
||||
} = useRBAC(releasePermissions);
|
||||
const { hasDraftAndPublish } = useContentManagerContext();
|
||||
|
||||
// Get all the releases not published
|
||||
const response = useGetReleasesQuery();
|
||||
@ -139,7 +141,7 @@ const ReleaseAction: BulkActionComponent = ({ documents, model }) => {
|
||||
}
|
||||
};
|
||||
|
||||
if (!canCreate || !canPublish) return null;
|
||||
if (!hasDraftAndPublish || !canCreate || !canPublish) return null;
|
||||
|
||||
return {
|
||||
actionType: 'release',
|
||||
|
@ -1,17 +1,25 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { clickAndWait, describeOnCondition } from '../../utils/shared';
|
||||
import { clickAndWait, describeOnCondition, skipCtbTour } from '../../utils/shared';
|
||||
import { resetDatabaseAndImportDataFromPath } from '../../utils/dts-import';
|
||||
import { login } from '../../utils/login';
|
||||
import { waitForRestart } from '../../utils/restart';
|
||||
import { resetFiles } from '../../utils/file-reset';
|
||||
|
||||
const edition = process.env.STRAPI_DISABLE_EE === 'true' ? 'CE' : 'EE';
|
||||
|
||||
describeOnCondition(edition === 'EE')('Releases page', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await resetDatabaseAndImportDataFromPath('with-admin.tar');
|
||||
await resetFiles();
|
||||
await page.goto('/admin');
|
||||
await page.evaluate(() => window.localStorage.setItem('GUIDED_TOUR_SKIPPED', 'true'));
|
||||
await login({ page });
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
await resetFiles();
|
||||
});
|
||||
|
||||
test('A user should be able to create a release without scheduling it and view their pending and done releases', async ({
|
||||
page,
|
||||
}) => {
|
||||
@ -138,4 +146,38 @@ describeOnCondition(edition === 'EE')('Releases page', () => {
|
||||
await expect(page.getByText('The Diamond Dogs')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test('Should not show "add to release" bulk action for content types without draft & publish enabled', async ({
|
||||
page,
|
||||
}) => {
|
||||
// Publish articles, otherwise they'll be deleted when we disable draft & publish
|
||||
await clickAndWait(page, page.getByRole('link', { name: 'Content Manager' }));
|
||||
await clickAndWait(page, page.getByRole('link', { name: 'Article' }));
|
||||
await page.getByRole('checkbox', { name: 'Select all entries' }).check();
|
||||
await clickAndWait(page, page.getByRole('button', { name: 'Publish' }));
|
||||
await page.getByRole('button', { name: 'Publish' }).click();
|
||||
const publishConfirmationDialog = page.getByRole('alertdialog', { name: 'Confirmation' });
|
||||
await expect(publishConfirmationDialog).toBeVisible();
|
||||
await publishConfirmationDialog.getByRole('button', { name: 'Publish' }).click();
|
||||
|
||||
// Disable draft & publish for the Article content type
|
||||
await clickAndWait(page, page.getByRole('link', { name: 'Content-Type Builder' }));
|
||||
await skipCtbTour(page);
|
||||
await clickAndWait(page, page.getByRole('link', { name: 'Article' }));
|
||||
await clickAndWait(page, page.getByRole('button', { name: 'Edit', exact: true }));
|
||||
await clickAndWait(page, page.getByRole('tab', { name: /advanced settings/i }));
|
||||
await page.getByLabel('Draft & publish').click();
|
||||
const ctbConfirmationDialog = page.getByRole('alertdialog', { name: 'Confirmation' });
|
||||
await expect(ctbConfirmationDialog).toBeVisible();
|
||||
await ctbConfirmationDialog.getByRole('button', { name: /disable/i }).click();
|
||||
await clickAndWait(page, page.getByRole('button', { name: 'Finish' }));
|
||||
await waitForRestart(page);
|
||||
|
||||
// Go to the content manager and bulk select articlesto make sure the "add to release" does not show up
|
||||
await clickAndWait(page, page.getByRole('link', { name: 'Content Manager' }));
|
||||
await clickAndWait(page, page.getByRole('link', { name: 'Article' }));
|
||||
await expect(page.getByRole('heading', { name: 'Article' })).toBeVisible();
|
||||
await page.getByRole('checkbox', { name: 'Select all entries' }).check();
|
||||
await expect(page.getByRole('button', { name: /add to release/i })).not.toBeVisible();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user