From 60813acb090d69a5ad7cd8e1faf1d7edc8ac0fd1 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Wed, 17 Jan 2024 15:26:07 +0200 Subject: [PATCH] fix: make the conflcit email template button conditionally render (#5931) Makes the schedule conflict email button conditional to having the link present. Closes # [1-1950](https://linear.app/unleash/issue/1-1950/modify-the-template-to-make-the-new-button-conditional) Signed-off-by: andreas-unleash --- .../FeatureStrategyConstraints.tsx | 2 +- .../FeatureMetricsHours/FeatureMetricsHours.tsx | 2 -- src/lib/services/email-service.ts | 6 ++++-- .../scheduled-change-conflict.html.mustache | 4 +++- .../scheduled-change-conflict.plain.mustache | 4 +++- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraints.tsx b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraints.tsx index 4ba1791463..80af1adfc6 100644 --- a/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraints.tsx +++ b/frontend/src/component/feature/FeatureStrategy/FeatureStrategyConstraints/FeatureStrategyConstraints.tsx @@ -1,5 +1,5 @@ import { IConstraint, IFeatureStrategy } from 'interfaces/strategy'; -import React, { useEffect, useMemo } from 'react'; +import React, { useEffect } from 'react'; import { UPDATE_FEATURE_STRATEGY, CREATE_FEATURE_STRATEGY, diff --git a/frontend/src/component/feature/FeatureView/FeatureMetrics/FeatureMetricsHours/FeatureMetricsHours.tsx b/frontend/src/component/feature/FeatureView/FeatureMetrics/FeatureMetricsHours/FeatureMetricsHours.tsx index 5e9daa1dbc..b011bde595 100644 --- a/frontend/src/component/feature/FeatureView/FeatureMetrics/FeatureMetricsHours/FeatureMetricsHours.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureMetrics/FeatureMetricsHours/FeatureMetricsHours.tsx @@ -3,8 +3,6 @@ import GeneralSelect, { IGeneralSelectProps, } from 'component/common/GeneralSelect/GeneralSelect'; import { subWeeks, subMonths, differenceInHours } from 'date-fns'; -import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; -import { useUiFlag } from 'hooks/useUiFlag'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; import { useExtendedFeatureMetrics } from '../useExtendedFeatureMetrics'; diff --git a/src/lib/services/email-service.ts b/src/lib/services/email-service.ts index a8a56404c0..3f3f545ef5 100644 --- a/src/lib/services/email-service.ts +++ b/src/lib/services/email-service.ts @@ -146,7 +146,7 @@ export class EmailService { async sendScheduledChangeConflictEmail( recipient: string, conflictScope: 'flag' | 'strategy', - conflictingChangeRequestId: number, + conflictingChangeRequestId: number | undefined, changeRequests: { id: number; scheduledAt: string; @@ -173,7 +173,9 @@ export class EmailService { ? `${this.config.server.unleashUrl}/projects/${project}/archive?sort=archivedAt&search=${flagName}` : false; - const conflictingChangeRequestLink = `${this.config.server.unleashUrl}/projects/${project}/change-requests/${conflictingChangeRequestId}`; + const conflictingChangeRequestLink = conflictingChangeRequestId + ? `${this.config.server.unleashUrl}/projects/${project}/change-requests/${conflictingChangeRequestId}` + : false; const bodyHtml = await this.compileTemplate( 'scheduled-change-conflict', diff --git a/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.html.mustache b/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.html.mustache index d51cd4a941..7dec515e7f 100644 --- a/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.html.mustache +++ b/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.html.mustache @@ -442,7 +442,9 @@
  • #{{id}} {{#title}}- {{.}}{{/title}} (scheduled for {{scheduledAt}})
  • {{/changeRequests}} - Open change request + {{#conflictingChangeRequestLink}} + Open change request + {{/conflictingChangeRequestLink}} diff --git a/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.plain.mustache b/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.plain.mustache index 67f213b5b4..1c458b7a1b 100644 --- a/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.plain.mustache +++ b/src/mailtemplates/scheduled-change-conflict/scheduled-change-conflict.plain.mustache @@ -8,4 +8,6 @@ For you, this concerns change requests: - # {{id}} - {{#title}}- {{.}}{{/title}} (scheduled for {{scheduledAt}}) ({{link}}) {{/changeRequests}} -Open Change request: {{conflictingChangeRequestLink}} +{{#conflictingChangeRequestLink}} + Open Change request: {{conflictingChangeRequestLink}} +{{/conflictingChangeRequestLink}}