From 8536e7c281e74b7df5ecc413f31c795e9983cebe Mon Sep 17 00:00:00 2001 From: skgandikota Date: Wed, 16 Nov 2022 20:26:04 +0530 Subject: [PATCH 1/4] Refactored Report issue template in techdoc addons. Co-authored-by: kcheriyath Co-authored-by: aswathysen Co-authored-by: skgandikota Signed-off-by: skgandikota --- .changeset/tender-parrots-cover.md | 5 +++++ .../src/ReportIssue/hooks.ts | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .changeset/tender-parrots-cover.md diff --git a/.changeset/tender-parrots-cover.md b/.changeset/tender-parrots-cover.md new file mode 100644 index 0000000000..433d030628 --- /dev/null +++ b/.changeset/tender-parrots-cover.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-techdocs-module-addons-contrib': patch +--- + +Refactored Report issue body in the tech-doc addons by getting the app title from `appconfig.yml` using `configApiRef`, In case `appTitle` not mentioned app Tile `new const` will default to `Backstage` diff --git a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts index 22dc359942..302568ce9c 100644 --- a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts +++ b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts @@ -16,7 +16,7 @@ import parseGitUrl from 'git-url-parse'; -import { useApi } from '@backstage/core-plugin-api'; +import { configApiRef, useApi } from '@backstage/core-plugin-api'; import { replaceGithubUrlType, replaceGitLabUrlType, @@ -48,7 +48,11 @@ export const getTitle = (selection: Selection) => { return `Documentation feedback: ${text}${ellipsis}`; }; -export const getBody = (selection: Selection, markdownUrl: string) => { +export const getBody = ( + selection: Selection, + markdownUrl: string, + appTitle: string, +) => { const title = '## Documentation Feedback 📝'; const subheading = '#### The highlighted text:'; const commentHeading = '#### The comment on the text:'; @@ -61,7 +65,7 @@ export const getBody = (selection: Selection, markdownUrl: string) => { .join('\n'); const facts = [ - `Backstage URL: <${window.location.href}> \nMarkdown URL: <${markdownUrl}>`, + `${appTitle} URL: <${window.location.href}> \nMarkdown URL: <${markdownUrl}>`, ]; return `${title}\n\n ${subheading} \n\n ${highlightedTextAsQuote}\n\n ${commentHeading} \n ${commentPlaceholder}\n\n ___\n${facts}`; @@ -73,7 +77,8 @@ export const useGitTemplate = (debounceTime?: number) => { const [editLink] = useShadowRootElements([PAGE_EDIT_LINK_SELECTOR]); const url = (editLink as HTMLAnchorElement)?.href ?? ''; const scmIntegrationsApi = useApi(scmIntegrationsApiRef); - + const configApi = useApi(configApiRef); + const appTitle = configApi.getOptional('app.title') || 'Backstage'; if (!selection || !url) return initialTemplate; const type = scmIntegrationsApi.byUrl(url)?.type; @@ -82,7 +87,7 @@ export const useGitTemplate = (debounceTime?: number) => { return { title: getTitle(selection), - body: getBody(selection, resolveBlobUrl(url, type)), + body: getBody(selection, resolveBlobUrl(url, type), appTitle), }; }; From c03fc0509f5f921ed2e40684c1c6a06bfb86f2e2 Mon Sep 17 00:00:00 2001 From: skgandikota Date: Wed, 16 Nov 2022 20:40:56 +0530 Subject: [PATCH 2/4] Refactored Report issue template in techdoc addons. Co-authored-by: kcheriyath Co-authored-by: aswathysen Signed-off-by: skgandikota --- plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts index 302568ce9c..bfe7331827 100644 --- a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts +++ b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts @@ -78,7 +78,7 @@ export const useGitTemplate = (debounceTime?: number) => { const url = (editLink as HTMLAnchorElement)?.href ?? ''; const scmIntegrationsApi = useApi(scmIntegrationsApiRef); const configApi = useApi(configApiRef); - const appTitle = configApi.getOptional('app.title') || 'Backstage'; + let appTitle: string = configApi.getOptional('app.title') || 'Backstage'; if (!selection || !url) return initialTemplate; const type = scmIntegrationsApi.byUrl(url)?.type; From 27ee635e4d4123a5ab82d73ad9aa47779b4b2c2f Mon Sep 17 00:00:00 2001 From: skgandikota Date: Wed, 16 Nov 2022 20:49:37 +0530 Subject: [PATCH 3/4] fix: lint fix 'appTitle' is never reassigned. Use 'const' instead Co-authored-by: kcheriyath Co-authored-by: aswathysen Signed-off-by: skgandikota --- plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts index bfe7331827..800a422066 100644 --- a/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts +++ b/plugins/techdocs-module-addons-contrib/src/ReportIssue/hooks.ts @@ -78,7 +78,7 @@ export const useGitTemplate = (debounceTime?: number) => { const url = (editLink as HTMLAnchorElement)?.href ?? ''; const scmIntegrationsApi = useApi(scmIntegrationsApiRef); const configApi = useApi(configApiRef); - let appTitle: string = configApi.getOptional('app.title') || 'Backstage'; + const appTitle = configApi.getOptionalString('app.title') || 'Backstage'; if (!selection || !url) return initialTemplate; const type = scmIntegrationsApi.byUrl(url)?.type; From 624162ad3a5efbd47f05e6867c632f606fa2900f Mon Sep 17 00:00:00 2001 From: skgandikota Date: Tue, 22 Nov 2022 16:23:35 +0530 Subject: [PATCH 4/4] rephrased changeset to Use from when creating new Documentation Feedback issue. is the default value. Co-authored-by: kcheriyath Co-authored-by: aswathysen Signed-off-by: skgandikota --- .changeset/tender-parrots-cover.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/tender-parrots-cover.md b/.changeset/tender-parrots-cover.md index 433d030628..5272fcbdce 100644 --- a/.changeset/tender-parrots-cover.md +++ b/.changeset/tender-parrots-cover.md @@ -2,4 +2,4 @@ '@backstage/plugin-techdocs-module-addons-contrib': patch --- -Refactored Report issue body in the tech-doc addons by getting the app title from `appconfig.yml` using `configApiRef`, In case `appTitle` not mentioned app Tile `new const` will default to `Backstage` +Use `app.title` from `app-config.yaml` when creating new Documentation Feedback issue. `Backstage` is the default value.