Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataViews: scope names of V2 UI components #56503

Merged
merged 1 commit into from
Nov 24, 2023
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
24 changes: 12 additions & 12 deletions packages/edit-site/src/components/dataviews/add-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import { unlock } from '../../lock-unlock';
import { ENUMERATION_TYPE, OPERATOR_IN } from './constants';

const {
DropdownMenuV2,
DropdownSubMenuV2,
DropdownSubMenuTriggerV2,
DropdownMenuItemV2,
DropdownMenuV2: DropdownMenu,
DropdownSubMenuV2: DropdownSubMenu,
DropdownSubMenuTriggerV2: DropdownSubMenuTrigger,
DropdownMenuItemV2: DropdownMenuItem,
} = unlock( componentsPrivateApis );

export default function AddFilter( { fields, view, onChangeView } ) {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default function AddFilter( { fields, view, onChangeView } ) {
}

return (
<DropdownMenuV2
<DropdownMenu
label={ __( 'Add filter' ) }
trigger={
<Button
Expand All @@ -68,18 +68,18 @@ export default function AddFilter( { fields, view, onChangeView } ) {
}

return (
<DropdownSubMenuV2
<DropdownSubMenu
key={ filter.field }
trigger={
<DropdownSubMenuTriggerV2
<DropdownSubMenuTrigger
suffix={ <Icon icon={ chevronRightSmall } /> }
>
{ filter.name }
</DropdownSubMenuTriggerV2>
</DropdownSubMenuTrigger>
}
>
{ filter.elements.map( ( element ) => (
<DropdownMenuItemV2
<DropdownMenuItem
key={ element.value }
onSelect={ () => {
onChangeView( ( currentView ) => ( {
Expand All @@ -98,11 +98,11 @@ export default function AddFilter( { fields, view, onChangeView } ) {
role="menuitemcheckbox"
>
{ element.label }
</DropdownMenuItemV2>
</DropdownMenuItem>
) ) }
</DropdownSubMenuV2>
</DropdownSubMenu>
);
} ) }
</DropdownMenuV2>
</DropdownMenu>
);
}
74 changes: 37 additions & 37 deletions packages/edit-site/src/components/dataviews/view-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { __ } from '@wordpress/i18n';
import { unlock } from '../../lock-unlock';

const {
DropdownMenuV2,
DropdownMenuGroupV2,
DropdownMenuItemV2,
DropdownSubMenuV2,
DropdownSubMenuTriggerV2,
DropdownMenuV2: DropdownMenu,
DropdownMenuGroupV2: DropdownMenuGroup,
DropdownMenuItemV2: DropdownMenuItem,
DropdownSubMenuV2: DropdownSubMenu,
DropdownSubMenuTriggerV2: DropdownSubMenuTrigger,
} = unlock( componentsPrivateApis );

const availableViews = [
Expand Down Expand Up @@ -57,9 +57,9 @@ function ViewTypeMenu( { view, onChangeView, supportedLayouts } ) {
}
const activeView = _availableViews.find( ( v ) => view.type === v.id );
return (
<DropdownSubMenuV2
<DropdownSubMenu
trigger={
<DropdownSubMenuTriggerV2
<DropdownSubMenuTrigger
suffix={
<>
{ activeView.label }
Expand All @@ -68,12 +68,12 @@ function ViewTypeMenu( { view, onChangeView, supportedLayouts } ) {
}
>
{ __( 'Layout' ) }
</DropdownSubMenuTriggerV2>
</DropdownSubMenuTrigger>
}
>
{ _availableViews.map( ( availableView ) => {
return (
<DropdownMenuItemV2
<DropdownMenuItem
key={ availableView.id }
prefix={
availableView.id === view.type && (
Expand All @@ -89,19 +89,19 @@ function ViewTypeMenu( { view, onChangeView, supportedLayouts } ) {
role="menuitemcheckbox"
>
{ availableView.label }
</DropdownMenuItemV2>
</DropdownMenuItem>
);
} ) }
</DropdownSubMenuV2>
</DropdownSubMenu>
);
}

const PAGE_SIZE_VALUES = [ 10, 20, 50, 100 ];
function PageSizeMenu( { view, onChangeView } ) {
return (
<DropdownSubMenuV2
<DropdownSubMenu
trigger={
<DropdownSubMenuTriggerV2
<DropdownSubMenuTrigger
suffix={
<>
{ view.perPage }
Expand All @@ -111,12 +111,12 @@ function PageSizeMenu( { view, onChangeView } ) {
>
{ /* TODO: probably label per view type. */ }
{ __( 'Rows per page' ) }
</DropdownSubMenuTriggerV2>
</DropdownSubMenuTrigger>
}
>
{ PAGE_SIZE_VALUES.map( ( size ) => {
return (
<DropdownMenuItemV2
<DropdownMenuItem
key={ size }
prefix={
view.perPage === size && <Icon icon={ check } />
Expand All @@ -130,10 +130,10 @@ function PageSizeMenu( { view, onChangeView } ) {
role="menuitemcheckbox"
>
{ size }
</DropdownMenuItemV2>
</DropdownMenuItem>
);
} ) }
</DropdownSubMenuV2>
</DropdownSubMenu>
);
}

Expand All @@ -145,18 +145,18 @@ function FieldsVisibilityMenu( { view, onChangeView, fields } ) {
return null;
}
return (
<DropdownSubMenuV2
<DropdownSubMenu
trigger={
<DropdownSubMenuTriggerV2
<DropdownSubMenuTrigger
suffix={ <Icon icon={ chevronRightSmall } /> }
>
{ __( 'Fields' ) }
</DropdownSubMenuTriggerV2>
</DropdownSubMenuTrigger>
}
>
{ hidableFields?.map( ( field ) => {
return (
<DropdownMenuItemV2
<DropdownMenuItem
key={ field.id }
prefix={
! view.hiddenFields?.includes( field.id ) && (
Expand All @@ -179,10 +179,10 @@ function FieldsVisibilityMenu( { view, onChangeView, fields } ) {
role="menuitemcheckbox"
>
{ field.header }
</DropdownMenuItemV2>
</DropdownMenuItem>
);
} ) }
</DropdownSubMenuV2>
</DropdownSubMenu>
);
}

Expand All @@ -202,9 +202,9 @@ function SortMenu( { fields, view, onChangeView } ) {
( field ) => field.id === view.sort?.field
);
return (
<DropdownSubMenuV2
<DropdownSubMenu
trigger={
<DropdownSubMenuTriggerV2
<DropdownSubMenuTrigger
suffix={
<>
{ currentSortedField?.header }
Expand All @@ -213,20 +213,20 @@ function SortMenu( { fields, view, onChangeView } ) {
}
>
{ __( 'Sort by' ) }
</DropdownSubMenuTriggerV2>
</DropdownSubMenuTrigger>
}
>
{ sortableFields?.map( ( field ) => {
const sortedDirection = view.sort?.direction;
return (
<DropdownSubMenuV2
<DropdownSubMenu
key={ field.id }
trigger={
<DropdownSubMenuTriggerV2
<DropdownSubMenuTrigger
suffix={ <Icon icon={ chevronRightSmall } /> }
>
{ field.header }
</DropdownSubMenuTriggerV2>
</DropdownSubMenuTrigger>
}
side="left"
>
Expand All @@ -237,7 +237,7 @@ function SortMenu( { fields, view, onChangeView } ) {
sortedDirection === direction &&
field.id === currentSortedField.id;
return (
<DropdownMenuItemV2
<DropdownMenuItem
key={ direction }
prefix={ <Icon icon={ info.icon } /> }
suffix={
Expand All @@ -264,14 +264,14 @@ function SortMenu( { fields, view, onChangeView } ) {
} }
>
{ info.label }
</DropdownMenuItemV2>
</DropdownMenuItem>
);
}
) }
</DropdownSubMenuV2>
</DropdownSubMenu>
);
} ) }
</DropdownSubMenuV2>
</DropdownSubMenu>
);
}

Expand All @@ -284,7 +284,7 @@ export default function ViewActions( {
supportedLayouts,
} ) {
return (
<DropdownMenuV2
<DropdownMenu
trigger={
<Button
variant="tertiary"
Expand All @@ -296,7 +296,7 @@ export default function ViewActions( {
/>
}
>
<DropdownMenuGroupV2>
<DropdownMenuGroup>
<ViewTypeMenu
view={ view }
onChangeView={ onChangeView }
Expand All @@ -313,7 +313,7 @@ export default function ViewActions( {
onChangeView={ onChangeView }
/>
<PageSizeMenu view={ view } onChangeView={ onChangeView } />
</DropdownMenuGroupV2>
</DropdownMenuV2>
</DropdownMenuGroup>
</DropdownMenu>
);
}
Loading
Loading