[MM-52271] Add recommended tag to Work Template integrations (#23016)

This commit is contained in:
Julien Tant 2023-04-24 09:59:01 -07:00 committed by GitHub
parent bf4555a223
commit 94cb2867a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 55 additions and 18 deletions

View File

@ -93,6 +93,7 @@ var wt{{.MD5}} = &WorkTemplate{
Illustration: "{{.Playbook.Illustration}}",
},{{end}}{{if .Integration}}Integration: &Integration{
ID: "{{.Integration.ID}}",
Recommended: {{.Integration.Recommended}},
},{{end}}
},
{{end}}

View File

@ -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

View File

@ -109,6 +109,7 @@ func (wt WorkTemplate) ToModelWorkTemplate(t i18n.TranslateFunc) *model.WorkTemp
mwt.Content = append(mwt.Content, model.WorkTemplateContent{
Integration: &model.WorkTemplateIntegration{
ID: content.Integration.ID,
Recommended: content.Integration.Recommended,
},
})
}
@ -321,6 +322,7 @@ func (p *Playbook) Validate() error {
type Integration struct {
ID string `yaml:"id"`
Recommended bool `yaml:"recommended"`
}
func (i *Integration) Validate() error {

View File

@ -149,11 +149,13 @@ var wt00a1b44a5831c0a3acb14787b3fdd352 = &WorkTemplate{
{
Integration: &Integration{
ID: "jira",
Recommended: true,
},
},
{
Integration: &Integration{
ID: "github",
Recommended: true,
},
},
},
@ -215,6 +217,7 @@ var wt5baa68055bf9ea423273662e01ccc575 = &WorkTemplate{
{
Integration: &Integration{
ID: "zoom",
Recommended: true,
},
},
},
@ -266,6 +269,7 @@ var wtfeb56bc6a8f277c47b503bd1c92d830e = &WorkTemplate{
{
Integration: &Integration{
ID: "jira",
Recommended: true,
},
},
},
@ -318,6 +322,7 @@ var wt8d2ef53deac5517eb349dc5de6150196 = &WorkTemplate{
{
Integration: &Integration{
ID: "zoom",
Recommended: true,
},
},
},
@ -519,6 +524,7 @@ var wtf7b846d35810f8272eeb9a1a562025b5 = &WorkTemplate{
{
Integration: &Integration{
ID: "zoom",
Recommended: true,
},
},
},
@ -571,16 +577,19 @@ var wtb9ab412890c2410c7b49eec8f12e7edc = &WorkTemplate{
{
Integration: &Integration{
ID: "jira",
Recommended: true,
},
},
{
Integration: &Integration{
ID: "github",
Recommended: true,
},
},
{
Integration: &Integration{
ID: "zoom",
Recommended: true,
},
},
},
@ -633,6 +642,7 @@ var wt32ab773bfe021e3d4913931041552559 = &WorkTemplate{
{
Integration: &Integration{
ID: "zoom",
Recommended: true,
},
},
},

View File

@ -70,6 +70,7 @@ type WorkTemplatePlaybook struct {
type WorkTemplateIntegration struct {
ID string `json:"id"`
Recommended bool `json:"recommended"`
}
type WorkTemplateContent struct {

View File

@ -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);
}
});

View File

@ -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,
};

View File

@ -64,6 +64,7 @@ export interface Playbook {
}
export interface Integration {
id: string;
recommended: boolean;
name?: string;
icon?: string;
installed?: boolean;