[TechDocs Addons] Give Feedback Addon (#10733)

* give feedback addon implementation

Co-authored-by: Camila Belo <camilaibs@gmail.com>
Co-authored-by: Anders Näsman <andersn@spotify.com>
Signed-off-by: Emma Indal <emma.indahl@gmail.com>

* export replaceUrlType from @backstage/integration-reacte

Co-authored-by: Camila Belo <camilaibs@gmail.com>
Co-authored-by: Anders Näsman <andersn@spotify.com>
Signed-off-by: Emma Indal <emma.indahl@gmail.com>

* export give feedback addon

Signed-off-by: Emma Indal <emma.indahl@gmail.com>

* add hooks used for give feedback addon

Co-authored-by: Camila Belo <camilaibs@gmail.com>
Co-authored-by: Anders Näsman <andersn@spotify.com>
Signed-off-by: Emma Indal <emma.indahl@gmail.com>

* replaceUrlType -> replaceGitLabUrlType

Signed-off-by: Emma Indal <emma.indahl@gmail.com>

* clarify template + template builder types

Signed-off-by: Emma Indal <emma.indahl@gmail.com>

* feedback fixups

Signed-off-by: Emma Indal <emma.indahl@gmail.com>

Co-authored-by: Camila Belo <camilaibs@gmail.com>
Co-authored-by: Anders Näsman <andersn@spotify.com>
This commit is contained in:
Emma Indal
2022-04-11 08:55:54 +02:00
committed by GitHub
parent 88fd7d1e55
commit d26e1b0146
19 changed files with 670 additions and 11 deletions
+6
View File
@@ -416,6 +416,12 @@ export function replaceGitHubUrlType(
type: 'blob' | 'tree' | 'edit',
): string;
// @public
export function replaceGitLabUrlType(
url: string,
type: 'blob' | 'tree' | 'edit',
): string;
// @public
export interface ScmIntegration {
resolveEditUrl(url: string): string;
@@ -15,7 +15,7 @@
*/
import { ConfigReader } from '@backstage/config';
import { GitLabIntegration, replaceUrlType } from './GitLabIntegration';
import { GitLabIntegration, replaceGitLabUrlType } from './GitLabIntegration';
describe('GitLabIntegration', () => {
it('has a working factory', () => {
@@ -55,28 +55,28 @@ describe('GitLabIntegration', () => {
});
});
describe('replaceUrlType', () => {
describe('replaceGitLabUrlType', () => {
it('should replace with expected type', () => {
expect(
replaceUrlType(
replaceGitLabUrlType(
'https://gitlab.com/my-org/my-project/-/blob/develop/README.md',
'edit',
),
).toBe('https://gitlab.com/my-org/my-project/-/edit/develop/README.md');
expect(
replaceUrlType(
replaceGitLabUrlType(
'https://gitlab.com/webmodules/blob/-/blob/develop/test',
'tree',
),
).toBe('https://gitlab.com/webmodules/blob/-/tree/develop/test');
expect(
replaceUrlType(
replaceGitLabUrlType(
'https://gitlab.com/blob/blob/-/blob/develop/test',
'tree',
),
).toBe('https://gitlab.com/blob/blob/-/tree/develop/test');
expect(
replaceUrlType(
replaceGitLabUrlType(
'https://gitlab.com/blob/blob/-/edit/develop/README.md',
'tree',
),
@@ -60,11 +60,18 @@ export class GitLabIntegration implements ScmIntegration {
}
resolveEditUrl(url: string): string {
return replaceUrlType(url, 'edit');
return replaceGitLabUrlType(url, 'edit');
}
}
export function replaceUrlType(
/**
* Takes a GitLab URL and replaces the type part (blob, tree etc).
*
* @param url - The original URL
* @param type - The desired type, e.g. 'blob', 'tree', 'edit'
* @public
*/
export function replaceGitLabUrlType(
url: string,
type: 'blob' | 'tree' | 'edit',
): string {
+1 -1
View File
@@ -20,4 +20,4 @@ export {
} from './config';
export type { GitLabIntegrationConfig } from './config';
export { getGitLabFileFetchUrl, getGitLabRequestOptions } from './core';
export { GitLabIntegration } from './GitLabIntegration';
export { GitLabIntegration, replaceGitLabUrlType } from './GitLabIntegration';