Skip to content

Commit

Permalink
Merge pull request #4823 from marek-slavicek/feat/linear-template-id
Browse files Browse the repository at this point in the history
feat(linear): template dropdown option for create issue action
  • Loading branch information
kishanprmr committed May 30, 2024
2 parents 55facc0 + 796afd9 commit dd2373d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/pieces/community/linear/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-linear",
"version": "0.1.0"
"version": "0.1.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const linearCreateIssue = createAction({
labels: props.labels(),
assignee_id: props.assignee_id(),
priority_id: props.priority_id(),
template_id: props.template_id()
},
async run({ auth, propsValue }) {
const issue: LinearDocument.IssueCreateInput = {
Expand All @@ -32,6 +33,7 @@ export const linearCreateIssue = createAction({
stateId: propsValue.state_id,
priority: propsValue.priority_id,
labelIds: propsValue.labels,
templateId: propsValue.template_id
};
const client = makeClient(auth as string);
const result = await client.createIssue(issue);
Expand Down
4 changes: 4 additions & 0 deletions packages/pieces/community/linear/src/lib/common/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export class LinearClientWrapper {
async deleteWebhook(webhookId: string) {
return this.client.deleteWebhook(webhookId);
}
async listTeamsTemplates(teamId: string, variables: Omit<LinearDocument.Team_TemplatesQueryVariables, "id">) {
const team = await this.client.team(teamId);
return team.templates(variables);
}
}

export function makeClient(apiKey: string): LinearClientWrapper {
Expand Down
32 changes: 32 additions & 0 deletions packages/pieces/community/linear/src/lib/common/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,36 @@ export const props = {
};
},
}),
template_id: (required = false) =>
Property.Dropdown({
displayName: 'Template',
required,
description: 'ID of Template',
refreshers: ['auth', 'team_id'],
options: async ({ auth, team_id }) => {
if (!auth || !team_id) {
return {
disabled: true,
placeholder: 'connect your account first and select team',
options: [],
};
}
const client = makeClient(auth as string);
const filter: Omit<LinearDocument.Team_TemplatesQueryVariables, "id"> = {
first: 50,
orderBy: LinearDocument.PaginationOrderBy.UpdatedAt,
};
const templatesConnection = await client.listTeamsTemplates(team_id as string, filter);
const templates = await templatesConnection.nodes;
return {
disabled: false,
options: templates.map((template) => {
return {
label: template.name,
value: template.id,
};
}),
};
},
}),
};

0 comments on commit dd2373d

Please sign in to comment.