Skip to content

Commit

Permalink
Use action API identifier instead
Browse files Browse the repository at this point in the history
  • Loading branch information
alanko0511 committed Sep 13, 2024
1 parent 43326e3 commit 6ae2673
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/api-client-core/src/GadgetFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface StubbedActionFunctionMetadata {
functionName: string;
operationName?: string;
errorMessage: string;
actionApiIdentifier: string;
modelApiIdentifier?: string;
variables: VariablesOptions;
reason: StubbedActionReason;
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/useAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const useAction = <
useEffect(() => {
if (action.type === ("stubbedAction" as string)) {
const stubbedAction = action as unknown as StubbedActionFunction<GivenOptions>;
if (!("reason" in stubbedAction) || !("dataPath" in stubbedAction)) {
if (!("reason" in stubbedAction) || !("dataPath" in stubbedAction) || !("actionApiIdentifier" in stubbedAction)) {
// Don't dispatch an event if the generated client has not yet been updated with the updated parameters
return;
}
Expand All @@ -81,7 +81,8 @@ export const useAction = <
detail: {
reason: stubbedAction.reason,
action: {
actionApiIdentifier: stubbedAction.functionName,
functionName: stubbedAction.functionName,
actionApiIdentifier: stubbedAction.actionApiIdentifier,
modelApiIdentifier: stubbedAction.modelApiIdentifier,
dataPath: stubbedAction.dataPath,
},
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/useBulkAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const useBulkAction = <
useEffect(() => {
if (action.type === ("stubbedAction" as string)) {
const stubbedAction = action as unknown as StubbedActionFunction<GivenOptions>;
if (!("reason" in stubbedAction) || !("dataPath" in stubbedAction)) {
if (!("reason" in stubbedAction) || !("dataPath" in stubbedAction) || !("actionApiIdentifier" in stubbedAction)) {
// Don't dispatch an event if the generated client has not yet been updated with the updated parameters
return;
}
Expand All @@ -76,7 +76,8 @@ export const useBulkAction = <
detail: {
reason: stubbedAction.reason,
action: {
actionApiIdentifier: stubbedAction.functionName,
functionName: stubbedAction.functionName,
actionApiIdentifier: stubbedAction.actionApiIdentifier,
modelApiIdentifier: stubbedAction.modelApiIdentifier,
dataPath: stubbedAction.dataPath,
},
Expand Down

0 comments on commit 6ae2673

Please sign in to comment.