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

ENG-2360 Execute action for an account with label "primary" if no account is mentioned #853

Merged
merged 4 commits into from
Nov 14, 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
1 change: 1 addition & 0 deletions js/src/sdk/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ export type ActionExecutionResDto = {

export type ConnectionParams = {
integrationId: string;
labels?: Array<(string)>;
connectionParams?: {
[key: string]: unknown;
};
Expand Down
16 changes: 14 additions & 2 deletions js/src/sdk/models/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { BackendClient } from "./backendClient";
import { Triggers } from "./triggers";
import { CEG } from "../utils/error";

const LABELS = {
PRIMARY: "primary"
}


export class Entity {
id: string;
Expand Down Expand Up @@ -68,8 +72,16 @@ export class Entity {
throw new Error('No connected account found');
}

// @ts-ignore
connectedAccount = connectedAccounts.items![0];
for (const account of connectedAccounts.items!) {
if (account?.labels && account?.labels.includes(LABELS.PRIMARY)) {
connectedAccount = account;
break;
}
}

if (!connectedAccount) {
connectedAccount = connectedAccounts.items![0];
}
}
return this.actionsModel.execute({
actionName: actionName,
Expand Down
Loading