-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: add actions to list layout #60805
Changes from all commits
40d1331
6b5fb73
673cdec
e0959b8
c61f7a0
5d15c4b
08f3029
6fad6f1
6dbd0f8
89a6c9d
12d3426
9378b7b
dd4d605
f3d4416
94b02b3
ca8bc80
ef3feeb
9c6421c
16e8c84
d211167
c7db4b7
817aebb
4dc0555
dcf7306
132f6b9
270c2a6
9f92508
6afa652
7052fd2
249d86e
adf56e2
7d76a8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,32 @@ function DropdownMenuItemTrigger( { action, onClick } ) { | |
); | ||
} | ||
|
||
export function ActionModal( { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The list view cannot use the ItemActions component, so this PR exports the two things it can actually use. |
||
action, | ||
items, | ||
closeModal, | ||
onActionStart, | ||
onActionPerformed, | ||
} ) { | ||
return ( | ||
<Modal | ||
title={ action.modalHeader || action.label } | ||
__experimentalHideHeader={ !! action.hideModalHeader } | ||
onRequestClose={ closeModal } | ||
overlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase( | ||
action.id | ||
) }` } | ||
> | ||
<action.RenderModal | ||
items={ items } | ||
closeModal={ closeModal } | ||
onActionStart={ onActionStart } | ||
onActionPerformed={ onActionPerformed } | ||
/> | ||
</Modal> | ||
); | ||
} | ||
|
||
export function ActionWithModal( { | ||
action, | ||
items, | ||
|
@@ -64,34 +90,23 @@ export function ActionWithModal( { | |
items, | ||
isBusy, | ||
}; | ||
const { RenderModal, hideModalHeader } = action; | ||
return ( | ||
<> | ||
<ActionTrigger { ...actionTriggerProps } /> | ||
{ isModalOpen && ( | ||
<Modal | ||
title={ action.modalHeader || action.label } | ||
__experimentalHideHeader={ !! hideModalHeader } | ||
onRequestClose={ () => { | ||
setIsModalOpen( false ); | ||
} } | ||
overlayClassName={ `dataviews-action-modal dataviews-action-modal__${ kebabCase( | ||
action.id | ||
) }` } | ||
> | ||
<RenderModal | ||
items={ items } | ||
closeModal={ () => setIsModalOpen( false ) } | ||
onActionStart={ onActionStart } | ||
onActionPerformed={ onActionPerformed } | ||
/> | ||
</Modal> | ||
<ActionModal | ||
action={ action } | ||
items={ items } | ||
closeModal={ () => setIsModalOpen( false ) } | ||
onActionStart={ onActionStart } | ||
onActionPerformed={ onActionPerformed } | ||
/> | ||
) } | ||
</> | ||
); | ||
} | ||
|
||
function ActionsDropdownMenuGroup( { actions, item } ) { | ||
export function ActionsDropdownMenuGroup( { actions, item } ) { | ||
return ( | ||
<DropdownMenuGroup> | ||
{ actions.map( ( action ) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,7 @@ | |
li { | ||
margin: 0; | ||
cursor: pointer; | ||
border-top: 1px solid $gray-100; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move the border to the topmost HTML element. The |
||
|
||
.dataviews-view-list__item-wrapper { | ||
position: relative; | ||
|
@@ -411,6 +412,18 @@ | |
} | ||
} | ||
|
||
.dataviews-view-list__item-actions .components-button { | ||
opacity: 0; | ||
} | ||
|
||
&.is-selected, | ||
&.is-hovered, | ||
&:focus-within { | ||
.dataviews-view-list__item-actions .components-button { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&:not(.is-selected) { | ||
.dataviews-view-list__primary-field { | ||
color: $gray-900; | ||
|
@@ -426,6 +439,7 @@ | |
} | ||
} | ||
} | ||
|
||
} | ||
|
||
li.is-selected, | ||
|
@@ -443,10 +457,9 @@ | |
} | ||
|
||
.dataviews-view-list__item { | ||
padding: $grid-unit-20 $grid-unit-40; | ||
padding: $grid-unit-20 0 $grid-unit-20 $grid-unit-40; | ||
width: 100%; | ||
scroll-margin: $grid-unit-10 0; | ||
border-top: 1px solid $gray-100; | ||
|
||
&:focus-visible { | ||
&::before { | ||
|
@@ -514,6 +527,11 @@ | |
} | ||
} | ||
|
||
.dataviews-view-list__item-actions { | ||
padding-top: $grid-unit-20; | ||
padding-right: $grid-unit-40; | ||
} | ||
|
||
& + .dataviews-pagination { | ||
justify-content: space-between; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,14 +175,14 @@ function GridItem( { | |
} | ||
|
||
export default function ViewGrid( { | ||
actions, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just sorting the prop alphabetically. |
||
data, | ||
fields, | ||
view, | ||
actions, | ||
isLoading, | ||
getItemId, | ||
selection, | ||
isLoading, | ||
onSelectionChange, | ||
selection, | ||
view, | ||
} ) { | ||
const mediaField = fields.find( | ||
( field ) => field.id === view.layout.mediaField | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorts the props alphabetically.