Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/fields/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
### Bug Fixes

- `PageTitleView`: Keep the page-type badge on a single line, so a list row with the `Privacy Policy Page` badge no longer grows and jumps when hovering reveals the primary action. ([#84368](https://github.com/WordPress/gutenberg/pull/84368))
- Status and slug fields: When the post's `_links` lack the `wp:action-publish` relation, disable the status field and show only the permalink in the slug control, so a user who can't publish gets what the classic sidebar shows. ([#84371](https://github.com/WordPress/gutenberg/pull/84371))
- `SlugEdit`: Keep the external link icon on the same line as the permalink when the slug can't be edited. ([#84371](https://github.com/WordPress/gutenberg/pull/84371))

## 0.49.0 (2026-10-07)

Expand Down
8 changes: 6 additions & 2 deletions packages/fields/src/fields/slug/slug-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { safeDecodeURIComponent } from '@wordpress/url';
import type { DataFormControlProps } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';
import type { BasePost } from '../../types';
import { hasActionLink } from '../utils';
import { getSlug } from './utils';

const SlugEdit = ( {
Expand All @@ -32,7 +33,10 @@ const SlugEdit = ( {
);
const permalinkPrefix = prefix;
const permalinkSuffix = suffix;
const isEditable = PERMALINK_POSTNAME_REGEX.test( permalinkTemplate );
// A user who can't publish only gets the permalink.
const isEditable =
PERMALINK_POSTNAME_REGEX.test( permalinkTemplate ) &&
hasActionLink( data, 'wp:action-publish' );
const originalSlugRef = useRef( slug );
const slugToDisplay = slug || originalSlugRef.current;
const permalink = isEditable
Expand Down Expand Up @@ -135,7 +139,7 @@ const SlugEdit = ( {
) }
{ ! isEditable && (
<ExternalLink
className="fields-controls__slug-help"
className="fields-controls__slug-help-link"
href={ permalink }
>
{ permalink }
Expand Down
3 changes: 3 additions & 0 deletions packages/fields/src/fields/status/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Field } from '@wordpress/dataviews';
import { __ } from '@wordpress/i18n';
import type { BasePost } from '../../types';
import { hasActionLink } from '../utils';
import StatusView from './status-view';
import STATUSES from './status-elements';

Expand All @@ -17,6 +18,8 @@ const statusField: Field< BasePost > = {
item.status === 'auto-draft' ? 'draft' : item.status,
render: StatusView,
Edit: 'radio',
// A user who can't publish can't change the status either.
isDisabled: ( { item } ) => ! hasActionLink( item, 'wp:action-publish' ),
enableSorting: false,
filterBy: {
operators: [ OPERATOR_IS_ANY ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ test.describe( 'Post Summary', () => {
await requestUtils.deleteAllUsers();
} );

test( 'hides the date, author and password fields for a contributor', async ( {
test( 'locks the status and slug and hides the date and author fields for a contributor', async ( {
browser,
requestUtils,
} ) => {
Expand Down Expand Up @@ -461,23 +461,26 @@ test.describe( 'Post Summary', () => {
page,
} );
await expect(
summary.getByRole( 'button', { name: 'Edit Status' } )
summary.getByText( 'Draft', { exact: true } )
).toBeVisible();
await expect(
summary.getByRole( 'button', { name: 'Edit Status' } )
).toBeHidden();
await expect(
summary.getByRole( 'button', { name: 'Edit Date' } )
).toBeHidden();
await expect(
summary.getByRole( 'button', { name: 'Edit Author' } )
).toBeHidden();

await summary
.getByRole( 'button', { name: 'Edit Status' } )
.click();
await expect(
page.getByRole( 'radio', { name: 'Draft' } )
summary.getByText( 'contributor-draft', { exact: true } )
).toBeVisible();
await summary.getByRole( 'button', { name: 'Edit Slug' } ).click();
await expect(
page.getByRole( 'checkbox', { name: 'Password protected' } )
page.getByRole( 'link', { name: /\?p=\d+/ } )
).toBeVisible();
await expect(
page.getByRole( 'textbox', { name: 'Link' } )
).toBeHidden();

await context.close();
Expand Down
Loading