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

Remove onActionPerformed & onActionStart from the ActionModal API #61659

Merged
merged 1 commit into from
May 15, 2024
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
18 changes: 3 additions & 15 deletions packages/dataviews/src/item-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ interface ActionModalProps {
action: ActionModalType;
items: Item[];
closeModal?: () => void;
onActionStart?: ( items: Item[] ) => void;
onActionPerformed?: ( items: Item[] ) => void;
}

interface ActionWithModalProps extends ActionModalProps {
Expand Down Expand Up @@ -97,13 +95,7 @@ function DropdownMenuItemTrigger( {
);
}

export function ActionModal( {
action,
items,
closeModal,
onActionStart,
onActionPerformed,
}: ActionModalProps ) {
export function ActionModal( { action, items, closeModal }: ActionModalProps ) {
return (
<Modal
title={ action.modalHeader || action.label }
Expand All @@ -116,8 +108,8 @@ export function ActionModal( {
<action.RenderModal
items={ items }
closeModal={ closeModal }
onActionStart={ onActionStart }
onActionPerformed={ onActionPerformed }
onActionStart={ action.onActionStart }
onActionPerformed={ action.onActionPerformed }
/>
</Modal>
);
Expand All @@ -127,8 +119,6 @@ export function ActionWithModal( {
action,
items,
ActionTrigger,
onActionStart,
onActionPerformed,
isBusy,
}: ActionWithModalProps ) {
const [ isModalOpen, setIsModalOpen ] = useState( false );
Expand All @@ -148,8 +138,6 @@ export function ActionWithModal( {
action={ action }
items={ items }
closeModal={ () => setIsModalOpen( false ) }
onActionStart={ onActionStart }
onActionPerformed={ onActionPerformed }
/>
) }
</>
Expand Down
10 changes: 10 additions & 0 deletions packages/dataviews/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ interface ActionBase {
}

export interface ActionModal extends ActionBase {
/**
* The callback to execute when the action has finished.
*/
onActionPerformed: ( ( items: Item[] ) => void ) | undefined;

/**
* The callback to execute when the action is triggered.
*/
onActionStart: ( ( items: Item[] ) => void ) | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these properties specific to modal actions or should they be moved to ActionBase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Given the names I think they can be supported in any type of action but since it follows our current implementation, it's fine to keep like that for now.


/**
* Modal to render when the action is triggered.
*/
Expand Down
2 changes: 0 additions & 2 deletions packages/dataviews/src/view-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ function ListItem( {
closeModal={ () =>
setIsModalOpen( false )
}
onActionStart={ () => {} }
onActionPerformed={ () => {} }
/>
) }
</CompositeItem>
Expand Down
Loading