Skip to content

Commit

Permalink
feedbacl
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Dec 17, 2024
1 parent 16ed1ca commit 4887285
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 49 deletions.
79 changes: 39 additions & 40 deletions packages/dataviews/src/components/dataviews-view-config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function BaseFieldItem( {
onToggleVisibility,
onMoveUp,
onMoveDown,
additionalActions,
children,
}: {
identifier: string;
label: string;
Expand All @@ -280,7 +280,7 @@ function BaseFieldItem( {
onToggleVisibility?: () => void;
onMoveUp?: () => void;
onMoveDown?: () => void;
additionalActions?: ReactNode;
children?: ReactNode;
} ) {
const focusVisibilityField = () => {
// Focus the visibility button to avoid focus loss.
Expand Down Expand Up @@ -393,7 +393,7 @@ function BaseFieldItem( {
}
/>
) }
{ additionalActions }
{ children }
</HStack>
</HStack>
</Item>
Expand Down Expand Up @@ -539,43 +539,42 @@ function PreviewFieldItem( {
canMove={ false }
canHide
isInteracting={ isChangingPreview }
additionalActions={
isVisible && (
<Menu onOpenChange={ setIsChangingPreview }>
<Menu.TriggerButton
render={
<Button
size="compact"
icon={ moreVertical }
label={ __( 'Preview' ) }
/>
}
/>
<Menu.Popover>
{ previewFields.map( ( field ) => {
return (
<Menu.RadioItem
key={ field.id }
value={ field.id }
checked={ field.id === view.mediaField }
onChange={ () => {
onChangeView( {
...view,
mediaField: field.id,
} );
} }
>
<Menu.ItemLabel>
{ field.label }
</Menu.ItemLabel>
</Menu.RadioItem>
);
} ) }
</Menu.Popover>
</Menu>
)
}
/>
>
{ isVisible && (
<Menu onOpenChange={ setIsChangingPreview }>
<Menu.TriggerButton
render={
<Button
size="compact"
icon={ moreVertical }
label={ __( 'Preview' ) }
/>
}
/>
<Menu.Popover>
{ previewFields.map( ( field ) => {
return (
<Menu.RadioItem
key={ field.id }
value={ field.id }
checked={ field.id === view.mediaField }
onChange={ () => {
onChangeView( {
...view,
mediaField: field.id,
} );
} }
>
<Menu.ItemLabel>
{ field.label }
</Menu.ItemLabel>
</Menu.RadioItem>
);
} ) }
</Menu.Popover>
</Menu>
) }
</BaseFieldItem>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { store as editorStore } from '../../../store';

const { useGlobalStyle } = unlock( blockEditorPrivateApis );

function ContentPreviewContainer( {
function PostPreviewContainer( {
template,
post,
}: {
Expand Down Expand Up @@ -62,7 +62,7 @@ function ContentPreviewContainer( {
);
}

export default function ContentPreviewView( { item }: { item: BasePost } ) {
export default function PostPreviewView( { item }: { item: BasePost } ) {
const { settings, template } = useSelect(
( select ) => {
const { canUser, getPostType, getTemplateId, getEntityRecord } =
Expand Down Expand Up @@ -102,7 +102,7 @@ export default function ContentPreviewView( { item }: { item: BasePost } ) {
settings={ settings }
__unstableTemplate={ template }
>
<ContentPreviewContainer template={ template } post={ item } />
<PostPreviewContainer template={ template } post={ item } />
</EditorProvider>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import ContentPreviewView from './content-preview-view';
import PostPreviewView from './content-preview-view';

const contentPreviewField: Field< BasePost > = {
const postPreviewField: Field< BasePost > = {
type: 'text',
id: 'content-preview',
label: __( 'Content preview' ),
render: ContentPreviewView,
render: PostPreviewView,
enableSorting: false,
isPreviewField: true,
};

export default contentPreviewField;
export default postPreviewField;
6 changes: 4 additions & 2 deletions packages/editor/src/dataviews/store/private-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
* Internal dependencies
*/
import { store as editorStore } from '../../store';
import contentPreviewField from '../fields/content-preview';
import postPreviewField from '../fields/content-preview';
import { unlock } from '../../lock-unlock';

export function registerEntityAction< Item >(
Expand Down Expand Up @@ -176,7 +176,9 @@ export const registerPostTypeSchema =
postTypeConfig.supports?.comments && commentStatusField,
templateField,
passwordField,
contentPreviewField,
postTypeConfig.supports?.editor &&
postTypeConfig.viewable &&
postPreviewField,
].filter( Boolean );
if ( postTypeConfig.supports?.title ) {
let _titleField;
Expand Down
1 change: 1 addition & 0 deletions packages/fields/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export interface PostType {
author?: string;
thumbnail?: string;
comments?: string;
editor?: boolean;
};
}

Expand Down

0 comments on commit 4887285

Please sign in to comment.