Skip to content

Commit

Permalink
Remove onActionPerformed & onActionStart from the modal API (#61659)
Browse files Browse the repository at this point in the history
Co-authored-by: oandregal <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: mcsf <[email protected]>
  • Loading branch information
4 people authored May 15, 2024
1 parent 37be122 commit 73150a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
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 @@ -210,6 +210,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;

/**
* 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

0 comments on commit 73150a4

Please sign in to comment.