From 94cb2867a7ebea1378a87ffb4d2c8574a39d1152 Mon Sep 17 00:00:00 2001 From: Julien Tant <785518+JulienTant@users.noreply.github.com> Date: Mon, 24 Apr 2023 09:59:01 -0700 Subject: [PATCH] [MM-52271] Add recommended tag to Work Template integrations (#23016) --- .../worktemplates/generator/worktemplate.tmpl | 1 + .../channels/app/worktemplates/templates.yaml | 12 ++++++-- server/channels/app/worktemplates/types.go | 6 ++-- .../worktemplates/worktemplate_generated.go | 30 ++++++++++++------- server/model/worktemplate.go | 3 +- .../work_templates/components/preview.tsx | 2 +- .../src/components/work_templates/index.tsx | 18 +++++++++-- webapp/platform/types/src/work_templates.ts | 1 + 8 files changed, 55 insertions(+), 18 deletions(-) diff --git a/server/channels/app/worktemplates/generator/worktemplate.tmpl b/server/channels/app/worktemplates/generator/worktemplate.tmpl index 60f40b5301..52d8d0be5f 100644 --- a/server/channels/app/worktemplates/generator/worktemplate.tmpl +++ b/server/channels/app/worktemplates/generator/worktemplate.tmpl @@ -93,6 +93,7 @@ var wt{{.MD5}} = &WorkTemplate{ Illustration: "{{.Playbook.Illustration}}", },{{end}}{{if .Integration}}Integration: &Integration{ ID: "{{.Integration.ID}}", + Recommended: {{.Integration.Recommended}}, },{{end}} }, {{end}} diff --git a/server/channels/app/worktemplates/templates.yaml b/server/channels/app/worktemplates/templates.yaml index 351e034d15..362b014a71 100644 --- a/server/channels/app/worktemplates/templates.yaml +++ b/server/channels/app/worktemplates/templates.yaml @@ -45,8 +45,10 @@ content: illustration: "/static/worktemplates/playbooks/product_release.png" - integration: id: jira + recommended: true - integration: id: github + recommended: true --- id: 'product_teams/goals_and_okrs:v1' category: product_teams @@ -86,7 +88,7 @@ content: channel: channel-1674845108569 - integration: id: zoom - + recommended: true --- id: 'product_teams/bug_bash:v1' category: product_teams @@ -120,6 +122,7 @@ content: playbook: playbook-1674844017943 - integration: id: jira + recommended: true --- id: 'product_teams/sprint_planning:v1' category: product_teams @@ -153,6 +156,7 @@ content: channel: channel-1674850783500 - integration: id: zoom + recommended: true --- id: 'product_teams/product_roadmap:v1' category: product_teams @@ -282,6 +286,7 @@ content: channel: channel-1674845108569 - integration: id: zoom + recommended: true --- id: 'companywide/create_project:v1' category: companywide @@ -316,10 +321,13 @@ content: channel: channel-1674851940114 - integration: id: jira + recommended: true - integration: id: github + recommended: true - integration: id: zoom + recommended: true --- ###################### # Leadership @@ -356,4 +364,4 @@ content: channel: channel-1674845108569 - integration: id: zoom - + recommended: true diff --git a/server/channels/app/worktemplates/types.go b/server/channels/app/worktemplates/types.go index a75db605aa..83649a4571 100644 --- a/server/channels/app/worktemplates/types.go +++ b/server/channels/app/worktemplates/types.go @@ -108,7 +108,8 @@ func (wt WorkTemplate) ToModelWorkTemplate(t i18n.TranslateFunc) *model.WorkTemp if content.Integration != nil { mwt.Content = append(mwt.Content, model.WorkTemplateContent{ Integration: &model.WorkTemplateIntegration{ - ID: content.Integration.ID, + ID: content.Integration.ID, + Recommended: content.Integration.Recommended, }, }) } @@ -320,7 +321,8 @@ func (p *Playbook) Validate() error { } type Integration struct { - ID string `yaml:"id"` + ID string `yaml:"id"` + Recommended bool `yaml:"recommended"` } func (i *Integration) Validate() error { diff --git a/server/channels/app/worktemplates/worktemplate_generated.go b/server/channels/app/worktemplates/worktemplate_generated.go index a201d7c5c3..f7e3a3e16f 100644 --- a/server/channels/app/worktemplates/worktemplate_generated.go +++ b/server/channels/app/worktemplates/worktemplate_generated.go @@ -148,12 +148,14 @@ var wt00a1b44a5831c0a3acb14787b3fdd352 = &WorkTemplate{ }, { Integration: &Integration{ - ID: "jira", + ID: "jira", + Recommended: true, }, }, { Integration: &Integration{ - ID: "github", + ID: "github", + Recommended: true, }, }, }, @@ -214,7 +216,8 @@ var wt5baa68055bf9ea423273662e01ccc575 = &WorkTemplate{ }, { Integration: &Integration{ - ID: "zoom", + ID: "zoom", + Recommended: true, }, }, }, @@ -265,7 +268,8 @@ var wtfeb56bc6a8f277c47b503bd1c92d830e = &WorkTemplate{ }, { Integration: &Integration{ - ID: "jira", + ID: "jira", + Recommended: true, }, }, }, @@ -317,7 +321,8 @@ var wt8d2ef53deac5517eb349dc5de6150196 = &WorkTemplate{ }, { Integration: &Integration{ - ID: "zoom", + ID: "zoom", + Recommended: true, }, }, }, @@ -518,7 +523,8 @@ var wtf7b846d35810f8272eeb9a1a562025b5 = &WorkTemplate{ }, { Integration: &Integration{ - ID: "zoom", + ID: "zoom", + Recommended: true, }, }, }, @@ -570,17 +576,20 @@ var wtb9ab412890c2410c7b49eec8f12e7edc = &WorkTemplate{ }, { Integration: &Integration{ - ID: "jira", + ID: "jira", + Recommended: true, }, }, { Integration: &Integration{ - ID: "github", + ID: "github", + Recommended: true, }, }, { Integration: &Integration{ - ID: "zoom", + ID: "zoom", + Recommended: true, }, }, }, @@ -632,7 +641,8 @@ var wt32ab773bfe021e3d4913931041552559 = &WorkTemplate{ }, { Integration: &Integration{ - ID: "zoom", + ID: "zoom", + Recommended: true, }, }, }, diff --git a/server/model/worktemplate.go b/server/model/worktemplate.go index b0c4262784..73857524bb 100644 --- a/server/model/worktemplate.go +++ b/server/model/worktemplate.go @@ -69,7 +69,8 @@ type WorkTemplatePlaybook struct { } type WorkTemplateIntegration struct { - ID string `json:"id"` + ID string `json:"id"` + Recommended bool `json:"recommended"` } type WorkTemplateContent struct { diff --git a/webapp/channels/src/components/work_templates/components/preview.tsx b/webapp/channels/src/components/work_templates/components/preview.tsx index 14ea11265d..30667461f6 100644 --- a/webapp/channels/src/components/work_templates/components/preview.tsx +++ b/webapp/channels/src/components/work_templates/components/preview.tsx @@ -117,7 +117,7 @@ const Preview = ({template, className, pluginsEnabled}: PreviewProps) => { if (c.playbook) { playbooks.push(c.playbook); } - if (c.integration) { + if (c.integration && c.integration.recommended) { availableIntegrations.push(c.integration); } }); diff --git a/webapp/channels/src/components/work_templates/index.tsx b/webapp/channels/src/components/work_templates/index.tsx index ed5eb0d6a6..d086c34525 100644 --- a/webapp/channels/src/components/work_templates/index.tsx +++ b/webapp/channels/src/components/work_templates/index.tsx @@ -232,7 +232,12 @@ const WorkTemplateModal = () => { const execute = async (template: WorkTemplate, name = '', visibility: Visibility) => { const pbTemplates = []; - for (const item of template.content) { + for (const ctt in template.content) { + if (!Object.hasOwn(template.content, ctt)) { + continue; + } + + const item = template.content[ctt]; if (item.playbook) { const pbTemplate = playbookTemplates.find((pb) => pb.title === item.playbook.template); if (pbTemplate) { @@ -241,11 +246,20 @@ const WorkTemplateModal = () => { } } + // remove non recommended integrations + const filteredTemplate = {...template}; + filteredTemplate.content = template.content.filter((item) => { + if (!item.integration) { + return true; + } + return item.integration.recommended; + }); + const req: ExecuteWorkTemplateRequest = { team_id: teamId, name, visibility, - work_template: template, + work_template: filteredTemplate, playbook_templates: pbTemplates, }; diff --git a/webapp/platform/types/src/work_templates.ts b/webapp/platform/types/src/work_templates.ts index d9d776e566..8b18abf958 100644 --- a/webapp/platform/types/src/work_templates.ts +++ b/webapp/platform/types/src/work_templates.ts @@ -64,6 +64,7 @@ export interface Playbook { } export interface Integration { id: string; + recommended: boolean; name?: string; icon?: string; installed?: boolean;