Skip to content

Commit

Permalink
update description and show post link instead of slug
Browse files Browse the repository at this point in the history
  • Loading branch information
tharsheblows committed Jun 13, 2024
1 parent eda3f8e commit 2feaaf5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
12 changes: 4 additions & 8 deletions packages/editor/src/components/post-url/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ExternalLink,
Button,
__experimentalInputControl as InputControl,
__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,
__experimentalVStack as VStack,
} from '@wordpress/components';
import { store as noticesStore } from '@wordpress/notices';
Expand Down Expand Up @@ -83,7 +82,9 @@ export default function PostURL( { onClose } ) {
<VStack spacing={ 3 }>
{ isEditable && (
<div>
{ __( 'Customize the last part of the URL. ' ) }
{ __(
'Customize the post name in the URL (in bold below). '
) }
<ExternalLink
href={ __(
'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'
Expand All @@ -97,16 +98,11 @@ export default function PostURL( { onClose } ) {
{ isEditable && (
<InputControl
__next40pxDefaultSize
prefix={
<InputControlPrefixWrapper>
/
</InputControlPrefixWrapper>
}
suffix={
<Button
icon={ copySmall }
ref={ copyButtonRef }
label={ __( 'Copy' ) }
label={ __( 'Copy Link' ) }
/>
}
label={ __( 'Link' ) }
Expand Down
17 changes: 10 additions & 7 deletions packages/editor/src/components/post-url/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useMemo, useState } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { Dropdown, Button } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { safeDecodeURIComponent } from '@wordpress/url';
import { safeDecodeURI } from '@wordpress/url';
import { store as coreStore } from '@wordpress/core-data';

/**
Expand Down Expand Up @@ -59,29 +59,32 @@ export default function PostURLPanel() {
}

function PostURLToggle( { isOpen, onClick } ) {
const { slug, isFrontPage, postLink } = useSelect( ( select ) => {
const { getCurrentPostId, getCurrentPost } = select( editorStore );
const { isFrontPage, postLink, permalink } = useSelect( ( select ) => {
const { getCurrentPostId, getCurrentPost, getPermalink } =
select( editorStore );
const { getEditedEntityRecord } = select( coreStore );
const siteSettings = getEditedEntityRecord( 'root', 'site' );
const _id = getCurrentPostId();

return {
slug: select( editorStore ).getEditedPostSlug(),
isFrontPage: siteSettings?.page_on_front === _id,
postLink: getCurrentPost()?.link,
permalink: getPermalink(),
};
}, [] );
const decodedSlug = safeDecodeURIComponent( slug );

const decodedLink = safeDecodeURI( permalink );
return (
<Button
size="compact"
className="editor-post-url__panel-toggle"
variant="tertiary"
aria-expanded={ isOpen }
// translators: %s: Current post link.
aria-label={ sprintf( __( 'Change link: %s' ), decodedSlug ) }
aria-label={ sprintf( __( 'Change link: %s' ), decodedLink ) }
onClick={ onClick }
>
{ isFrontPage ? postLink : <>/{ decodedSlug }</> }
{ isFrontPage ? postLink : <>{ decodedLink }</> }
</Button>
);
}
6 changes: 0 additions & 6 deletions packages/editor/src/components/post-url/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,3 @@
.editor-post-url__link-slug {
font-weight: 600;
}

// TODO: This might indicate a need to update the InputControl itself, as
// there is no way currently to control the padding when adding prefix/suffix.
.editor-post-url__input input.components-input-control__input {
padding-inline-start: 0 !important;
}

0 comments on commit 2feaaf5

Please sign in to comment.