From ace69f981d755213053bac28532faaa17caadad7 Mon Sep 17 00:00:00 2001 From: Severin Wischmann Date: Wed, 29 Jan 2025 15:12:10 +0100 Subject: [PATCH 1/6] Use Gitlab path rather than project name Signed-off-by: Severin Wischmann --- .../src/autocomplete/autocomplete.test.ts | 8 ++++---- .../src/autocomplete/autocomplete.ts | 2 ++ plugins/scaffolder-react/src/api/types.ts | 2 +- .../components/fields/RepoUrlPicker/GitlabRepoPicker.tsx | 2 +- .../src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx | 2 +- .../src/components/fields/RepoUrlPicker/types.ts | 1 + 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts index 4fa906686c..a60d317077 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts @@ -79,8 +79,8 @@ describe('handleAutocompleteRequest', () => { mockClient.Users.showCurrentUser.mockResolvedValue({ id: 3 }); mockClient.Groups.allProjects.mockResolvedValue([ - { name: 'repo1', id: 1 }, - { name: 'repo2', id: 2 }, + { name: 'Repo 1', path: 'repo-1', id: 1 }, + { name: 'Repo 2', path: 'repo-2', id: 2 }, ]); const result = await handleAutocompleteRequest({ @@ -91,8 +91,8 @@ describe('handleAutocompleteRequest', () => { expect(result).toEqual({ results: [ - { title: 'repo1', id: '1' }, - { title: 'repo2', id: '2' }, + { title: 'Repo 1', path: 'repo-1', id: '1' }, + { title: 'Repo 2', path: 'repo-2', id: '2' }, ], }); }); diff --git a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts index 6e9a7f79c4..d9f2f4351d 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts @@ -32,6 +32,7 @@ export function createHandleAutocompleteRequest(options: { }): Promise<{ results: { title?: string; + path?: string; id: string; }[]; }> { @@ -97,6 +98,7 @@ export function createHandleAutocompleteRequest(options: { return { results: response.map(project => ({ title: project.name.trim(), + path: project.path, id: project.id.toString(), })), }; diff --git a/plugins/scaffolder-react/src/api/types.ts b/plugins/scaffolder-react/src/api/types.ts index 8e4d989a55..293a6a55e7 100644 --- a/plugins/scaffolder-react/src/api/types.ts +++ b/plugins/scaffolder-react/src/api/types.ts @@ -245,5 +245,5 @@ export interface ScaffolderApi { provider: string; resource: string; context?: Record; - }): Promise<{ results: { title?: string; id: string }[] }>; + }): Promise<{ results: { title?: string; path?: string; id: string }[] }>; } diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx index d97c9431ee..abd7071f44 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx @@ -98,7 +98,7 @@ export const GitlabRepoPicker = ( .then(({ results }) => { onChange({ availableRepos: results.map(r => { - return { name: r.title!, id: r.id }; + return { name: r.title!, path: r.path, id: r.id }; }), }); }) diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx index 18da234012..41b00cc642 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx @@ -244,7 +244,7 @@ export const RepoUrlPicker = ( onChange={repo => setState(prevState => ({ ...prevState, - repoName: repo.name, + repoName: repo.path || repo.name, id: repo.id || '', })) } diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts b/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts index d37e764eae..e5c62aed08 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts @@ -15,6 +15,7 @@ */ export interface AvailableRepositories { name: string; + path?: string; id?: string; } From fe4494616fbe9dd5668ebb9fe793b9c09e465e67 Mon Sep 17 00:00:00 2001 From: Severin Wischmann Date: Wed, 29 Jan 2025 15:14:03 +0100 Subject: [PATCH 2/6] Added changeset Signed-off-by: Severin Wischmann --- .changeset/smart-ligers-sniff.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/smart-ligers-sniff.md diff --git a/.changeset/smart-ligers-sniff.md b/.changeset/smart-ligers-sniff.md new file mode 100644 index 0000000000..2a5ec1fd27 --- /dev/null +++ b/.changeset/smart-ligers-sniff.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-scaffolder-backend-module-gitlab': patch +'@backstage/plugin-scaffolder-react': patch +'@backstage/plugin-scaffolder': patch +--- + +Changed field that is used in autocomplete From c68e09060da29ffa6cb370bf22c7d99b1ef4dc08 Mon Sep 17 00:00:00 2001 From: Severin Wischmann Date: Thu, 30 Jan 2025 09:26:13 +0100 Subject: [PATCH 3/6] Added API reports Signed-off-by: Severin Wischmann --- plugins/scaffolder-backend-module-gitlab/report.api.md | 6 +++--- plugins/scaffolder-backend/report.api.md | 2 +- plugins/scaffolder-react/report.api.md | 1 + plugins/scaffolder/report-alpha.api.md | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/scaffolder-backend-module-gitlab/report.api.md b/plugins/scaffolder-backend-module-gitlab/report.api.md index 896c0a5899..238aa4b05e 100644 --- a/plugins/scaffolder-backend-module-gitlab/report.api.md +++ b/plugins/scaffolder-backend-module-gitlab/report.api.md @@ -33,8 +33,8 @@ export const createGitlabIssueAction: (options: { projectId: number; labels?: string | undefined; description?: string | undefined; - weight?: number | undefined; token?: string | undefined; + weight?: number | undefined; assignees?: number[] | undefined; createdAt?: string | undefined; confidential?: boolean | undefined; @@ -198,7 +198,7 @@ export const createPublishGitlabMergeRequestAction: (options: { sourcePath?: string | undefined; targetPath?: string | undefined; token?: string | undefined; - commitAction?: 'auto' | 'update' | 'delete' | 'create' | 'skip' | undefined; + commitAction?: 'auto' | 'update' | 'skip' | 'delete' | 'create' | undefined; projectid?: string | undefined; removeSourceBranch?: boolean | undefined; assignee?: string | undefined; @@ -234,8 +234,8 @@ export const editGitlabIssueAction: (options: { title?: string | undefined; labels?: string | undefined; description?: string | undefined; - weight?: number | undefined; token?: string | undefined; + weight?: number | undefined; assignees?: number[] | undefined; addLabels?: string | undefined; confidential?: boolean | undefined; diff --git a/plugins/scaffolder-backend/report.api.md b/plugins/scaffolder-backend/report.api.md index c2e6c18ad8..863d4a6a9e 100644 --- a/plugins/scaffolder-backend/report.api.md +++ b/plugins/scaffolder-backend/report.api.md @@ -355,7 +355,7 @@ export const createPublishGitlabMergeRequestAction: (options: { sourcePath?: string | undefined; targetPath?: string | undefined; token?: string | undefined; - commitAction?: 'auto' | 'update' | 'delete' | 'create' | 'skip' | undefined; + commitAction?: 'auto' | 'update' | 'skip' | 'delete' | 'create' | undefined; projectid?: string | undefined; removeSourceBranch?: boolean | undefined; assignee?: string | undefined; diff --git a/plugins/scaffolder-react/report.api.md b/plugins/scaffolder-react/report.api.md index 8a6b4739a4..d83d64d834 100644 --- a/plugins/scaffolder-react/report.api.md +++ b/plugins/scaffolder-react/report.api.md @@ -215,6 +215,7 @@ export interface ScaffolderApi { }): Promise<{ results: { title?: string; + path?: string; id: string; }[]; }>; diff --git a/plugins/scaffolder/report-alpha.api.md b/plugins/scaffolder/report-alpha.api.md index e272b57655..d96a266fe0 100644 --- a/plugins/scaffolder/report-alpha.api.md +++ b/plugins/scaffolder/report-alpha.api.md @@ -291,10 +291,10 @@ export const scaffolderTranslationRef: TranslationRef< readonly 'ongoingTask.title': 'Run of'; readonly 'ongoingTask.contextMenu.cancel': 'Cancel'; readonly 'ongoingTask.contextMenu.startOver': 'Start Over'; - readonly 'ongoingTask.contextMenu.retry': 'Retry'; readonly 'ongoingTask.contextMenu.hideLogs': 'Hide Logs'; readonly 'ongoingTask.contextMenu.showLogs': 'Show Logs'; readonly 'ongoingTask.contextMenu.hideButtonBar': 'Hide Button Bar'; + readonly 'ongoingTask.contextMenu.retry': 'Retry'; readonly 'ongoingTask.contextMenu.showButtonBar': 'Show Button Bar'; readonly 'ongoingTask.subtitle': 'Task {{taskId}}'; readonly 'ongoingTask.pageTitle.hasTemplateName': 'Run of {{templateName}}'; @@ -364,8 +364,8 @@ export const scaffolderTranslationRef: TranslationRef< readonly 'templateEditorToolbar.addToCatalogDialogTitle': 'Publish changes'; readonly 'templateEditorToolbar.addToCatalogDialogContent.stepsIntroduction': 'Follow the instructions below to create or update a template:'; readonly 'templateEditorToolbar.addToCatalogDialogContent.stepsListItems': 'Save the template files in a local directory\nCreate a pull request to a new or existing git repository\nIf the template already exists, the changes will be reflected in the software catalog once the pull request gets merged\nBut if you are creating a new template, follow the documentation linked below to register the new template repository in software catalog'; - readonly 'templateEditorToolbar.addToCatalogDialogActions.documentationUrl': 'https://backstage.io/docs/features/software-templates/adding-templates/'; readonly 'templateEditorToolbar.addToCatalogDialogActions.documentationButton': 'Go to the documentation'; + readonly 'templateEditorToolbar.addToCatalogDialogActions.documentationUrl': 'https://backstage.io/docs/features/software-templates/adding-templates/'; readonly 'templateEditorToolbarFileMenu.button': 'File'; readonly 'templateEditorToolbarFileMenu.options.openDirectory': 'Open template directory'; readonly 'templateEditorToolbarFileMenu.options.createDirectory': 'Create template directory'; From 5def47e1da7fdcded9667a01ff080fa5e89743bb Mon Sep 17 00:00:00 2001 From: Severin Wischmann Date: Thu, 30 Jan 2025 09:49:28 +0100 Subject: [PATCH 4/6] Added api-reports Signed-off-by: Severin Wischmann --- plugins/scaffolder-backend-module-gitlab/report.api.md | 6 +++--- plugins/scaffolder-backend/report.api.md | 2 +- plugins/scaffolder/report-alpha.api.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/scaffolder-backend-module-gitlab/report.api.md b/plugins/scaffolder-backend-module-gitlab/report.api.md index 238aa4b05e..896c0a5899 100644 --- a/plugins/scaffolder-backend-module-gitlab/report.api.md +++ b/plugins/scaffolder-backend-module-gitlab/report.api.md @@ -33,8 +33,8 @@ export const createGitlabIssueAction: (options: { projectId: number; labels?: string | undefined; description?: string | undefined; - token?: string | undefined; weight?: number | undefined; + token?: string | undefined; assignees?: number[] | undefined; createdAt?: string | undefined; confidential?: boolean | undefined; @@ -198,7 +198,7 @@ export const createPublishGitlabMergeRequestAction: (options: { sourcePath?: string | undefined; targetPath?: string | undefined; token?: string | undefined; - commitAction?: 'auto' | 'update' | 'skip' | 'delete' | 'create' | undefined; + commitAction?: 'auto' | 'update' | 'delete' | 'create' | 'skip' | undefined; projectid?: string | undefined; removeSourceBranch?: boolean | undefined; assignee?: string | undefined; @@ -234,8 +234,8 @@ export const editGitlabIssueAction: (options: { title?: string | undefined; labels?: string | undefined; description?: string | undefined; - token?: string | undefined; weight?: number | undefined; + token?: string | undefined; assignees?: number[] | undefined; addLabels?: string | undefined; confidential?: boolean | undefined; diff --git a/plugins/scaffolder-backend/report.api.md b/plugins/scaffolder-backend/report.api.md index 863d4a6a9e..c2e6c18ad8 100644 --- a/plugins/scaffolder-backend/report.api.md +++ b/plugins/scaffolder-backend/report.api.md @@ -355,7 +355,7 @@ export const createPublishGitlabMergeRequestAction: (options: { sourcePath?: string | undefined; targetPath?: string | undefined; token?: string | undefined; - commitAction?: 'auto' | 'update' | 'skip' | 'delete' | 'create' | undefined; + commitAction?: 'auto' | 'update' | 'delete' | 'create' | 'skip' | undefined; projectid?: string | undefined; removeSourceBranch?: boolean | undefined; assignee?: string | undefined; diff --git a/plugins/scaffolder/report-alpha.api.md b/plugins/scaffolder/report-alpha.api.md index d96a266fe0..e272b57655 100644 --- a/plugins/scaffolder/report-alpha.api.md +++ b/plugins/scaffolder/report-alpha.api.md @@ -291,10 +291,10 @@ export const scaffolderTranslationRef: TranslationRef< readonly 'ongoingTask.title': 'Run of'; readonly 'ongoingTask.contextMenu.cancel': 'Cancel'; readonly 'ongoingTask.contextMenu.startOver': 'Start Over'; + readonly 'ongoingTask.contextMenu.retry': 'Retry'; readonly 'ongoingTask.contextMenu.hideLogs': 'Hide Logs'; readonly 'ongoingTask.contextMenu.showLogs': 'Show Logs'; readonly 'ongoingTask.contextMenu.hideButtonBar': 'Hide Button Bar'; - readonly 'ongoingTask.contextMenu.retry': 'Retry'; readonly 'ongoingTask.contextMenu.showButtonBar': 'Show Button Bar'; readonly 'ongoingTask.subtitle': 'Task {{taskId}}'; readonly 'ongoingTask.pageTitle.hasTemplateName': 'Run of {{templateName}}'; @@ -364,8 +364,8 @@ export const scaffolderTranslationRef: TranslationRef< readonly 'templateEditorToolbar.addToCatalogDialogTitle': 'Publish changes'; readonly 'templateEditorToolbar.addToCatalogDialogContent.stepsIntroduction': 'Follow the instructions below to create or update a template:'; readonly 'templateEditorToolbar.addToCatalogDialogContent.stepsListItems': 'Save the template files in a local directory\nCreate a pull request to a new or existing git repository\nIf the template already exists, the changes will be reflected in the software catalog once the pull request gets merged\nBut if you are creating a new template, follow the documentation linked below to register the new template repository in software catalog'; - readonly 'templateEditorToolbar.addToCatalogDialogActions.documentationButton': 'Go to the documentation'; readonly 'templateEditorToolbar.addToCatalogDialogActions.documentationUrl': 'https://backstage.io/docs/features/software-templates/adding-templates/'; + readonly 'templateEditorToolbar.addToCatalogDialogActions.documentationButton': 'Go to the documentation'; readonly 'templateEditorToolbarFileMenu.button': 'File'; readonly 'templateEditorToolbarFileMenu.options.openDirectory': 'Open template directory'; readonly 'templateEditorToolbarFileMenu.options.createDirectory': 'Create template directory'; From d0cd6a0dec97eff6587e786738388349e0a9e310 Mon Sep 17 00:00:00 2001 From: Severin Wischmann Date: Thu, 30 Jan 2025 13:36:11 +0100 Subject: [PATCH 5/6] Changes functionality in line with comment Based on [this comment](https://github.com/backstage/backstage/issues/28565#issuecomment-2624141216), the path is now the `id` Signed-off-by: Severin Wischmann --- .../src/autocomplete/autocomplete.test.ts | 16 ++++++++-------- .../src/autocomplete/autocomplete.ts | 4 +--- plugins/scaffolder-react/report.api.md | 1 - plugins/scaffolder-react/src/api/types.ts | 2 +- .../fields/RepoUrlPicker/GitlabRepoPicker.tsx | 2 +- .../fields/RepoUrlPicker/RepoUrlPicker.tsx | 3 +-- .../src/components/fields/RepoUrlPicker/types.ts | 2 -- .../fields/RepoUrlPicker/utils.test.ts | 6 ++---- .../src/components/fields/RepoUrlPicker/utils.ts | 7 +------ 9 files changed, 15 insertions(+), 28 deletions(-) diff --git a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts index a60d317077..a2e2f18ab2 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.test.ts @@ -79,8 +79,8 @@ describe('handleAutocompleteRequest', () => { mockClient.Users.showCurrentUser.mockResolvedValue({ id: 3 }); mockClient.Groups.allProjects.mockResolvedValue([ - { name: 'Repo 1', path: 'repo-1', id: 1 }, - { name: 'Repo 2', path: 'repo-2', id: 2 }, + { name: 'Repo 1', path: 'repo-1' }, + { name: 'Repo 2', path: 'repo-2' }, ]); const result = await handleAutocompleteRequest({ @@ -91,8 +91,8 @@ describe('handleAutocompleteRequest', () => { expect(result).toEqual({ results: [ - { title: 'Repo 1', path: 'repo-1', id: '1' }, - { title: 'Repo 2', path: 'repo-2', id: '2' }, + { title: 'Repo 1', id: 'repo-1' }, + { title: 'Repo 2', id: 'repo-2' }, ], }); }); @@ -104,8 +104,8 @@ describe('handleAutocompleteRequest', () => { mockClient.Users.showCurrentUser.mockResolvedValue({ id: 1 }); mockClient.Users.allProjects.mockResolvedValue([ - { name: 'repo1', id: 1 }, - { name: 'repo2', id: 2 }, + { name: 'Repo 1', path: 'repo-1' }, + { name: 'Repo 2', path: 'repo-2' }, ]); const result = await handleAutocompleteRequest({ @@ -116,8 +116,8 @@ describe('handleAutocompleteRequest', () => { expect(result).toEqual({ results: [ - { title: 'repo1', id: '1' }, - { title: 'repo2', id: '2' }, + { title: 'Repo 1', id: 'repo-1' }, + { title: 'Repo 2', id: 'repo-2' }, ], }); }); diff --git a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts index d9f2f4351d..4eddd844e5 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/autocomplete/autocomplete.ts @@ -32,7 +32,6 @@ export function createHandleAutocompleteRequest(options: { }): Promise<{ results: { title?: string; - path?: string; id: string; }[]; }> { @@ -98,8 +97,7 @@ export function createHandleAutocompleteRequest(options: { return { results: response.map(project => ({ title: project.name.trim(), - path: project.path, - id: project.id.toString(), + id: project.path, })), }; } diff --git a/plugins/scaffolder-react/report.api.md b/plugins/scaffolder-react/report.api.md index d83d64d834..8a6b4739a4 100644 --- a/plugins/scaffolder-react/report.api.md +++ b/plugins/scaffolder-react/report.api.md @@ -215,7 +215,6 @@ export interface ScaffolderApi { }): Promise<{ results: { title?: string; - path?: string; id: string; }[]; }>; diff --git a/plugins/scaffolder-react/src/api/types.ts b/plugins/scaffolder-react/src/api/types.ts index 293a6a55e7..8e4d989a55 100644 --- a/plugins/scaffolder-react/src/api/types.ts +++ b/plugins/scaffolder-react/src/api/types.ts @@ -245,5 +245,5 @@ export interface ScaffolderApi { provider: string; resource: string; context?: Record; - }): Promise<{ results: { title?: string; path?: string; id: string }[] }>; + }): Promise<{ results: { title?: string; id: string }[] }>; } diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx index abd7071f44..d97c9431ee 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/GitlabRepoPicker.tsx @@ -98,7 +98,7 @@ export const GitlabRepoPicker = ( .then(({ results }) => { onChange({ availableRepos: results.map(r => { - return { name: r.title!, path: r.path, id: r.id }; + return { name: r.title!, id: r.id }; }), }); }) diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx index 41b00cc642..ef6654b60c 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.tsx @@ -244,8 +244,7 @@ export const RepoUrlPicker = ( onChange={repo => setState(prevState => ({ ...prevState, - repoName: repo.path || repo.name, - id: repo.id || '', + repoName: repo.id || repo.name, })) } rawErrors={rawErrors} diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts b/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts index e5c62aed08..74d45fa401 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/types.ts @@ -15,7 +15,6 @@ */ export interface AvailableRepositories { name: string; - path?: string; id?: string; } @@ -26,7 +25,6 @@ export interface RepoUrlPickerState { organization?: string; workspace?: string; project?: string; - id?: string; availableRepos?: AvailableRepositories[]; } diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.test.ts b/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.test.ts index ce3c938e31..c90b357cf1 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.test.ts +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.test.ts @@ -53,10 +53,9 @@ describe('utils', () => { organization: 'organization', workspace: 'workspace', project: 'backstage', - id: '1234', }), ).toBe( - 'github.com?owner=owner&repo=backstage&organization=organization&workspace=workspace&project=backstage&id=1234', + 'github.com?owner=owner&repo=backstage&organization=organization&workspace=workspace&project=backstage', ); }); }); @@ -65,7 +64,7 @@ describe('utils', () => { it('should parse a complete string', () => { expect( parseRepoPickerUrl( - 'github.com?owner=owner&repo=backstage&organization=organization&workspace=workspace&project=backstage&id=1234', + 'github.com?owner=owner&repo=backstage&organization=organization&workspace=workspace&project=backstage', ), ).toEqual({ host: 'github.com', @@ -74,7 +73,6 @@ describe('utils', () => { organization: 'organization', workspace: 'workspace', project: 'backstage', - id: '1234', }); }); }); diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.ts b/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.ts index 145a3e256f..408b87413b 100644 --- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.ts +++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/utils.ts @@ -37,9 +37,6 @@ export function serializeRepoPickerUrl(data: RepoUrlPickerState) { if (data.project) { params.set('project', data.project); } - if (data.id) { - params.set('id', data.id); - } return `${data.host}?${params.toString()}`; } @@ -53,7 +50,6 @@ export function parseRepoPickerUrl( let organization = ''; let workspace = ''; let project = ''; - let id = ''; try { if (url) { @@ -64,10 +60,9 @@ export function parseRepoPickerUrl( organization = parsed.searchParams.get('organization') || ''; workspace = parsed.searchParams.get('workspace') || ''; project = parsed.searchParams.get('project') || ''; - id = parsed.searchParams.get('id') || ''; } } catch { /* ok */ } - return { host, owner, repoName, organization, workspace, project, id }; + return { host, owner, repoName, organization, workspace, project }; } From d92fd526a041f9e0720264a068f69562d7675e14 Mon Sep 17 00:00:00 2001 From: Ben Lambert Date: Tue, 4 Feb 2025 10:21:57 +0100 Subject: [PATCH 6/6] Fix bug in GitLab autocomplete onChange handler Signed-off-by: blam --- .changeset/smart-ligers-sniff.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.changeset/smart-ligers-sniff.md b/.changeset/smart-ligers-sniff.md index 2a5ec1fd27..42353eca2b 100644 --- a/.changeset/smart-ligers-sniff.md +++ b/.changeset/smart-ligers-sniff.md @@ -1,7 +1,6 @@ --- '@backstage/plugin-scaffolder-backend-module-gitlab': patch -'@backstage/plugin-scaffolder-react': patch '@backstage/plugin-scaffolder': patch --- -Changed field that is used in autocomplete +Fixed bug of passing wrong value to `onChange` handler when using `GitLab` autocomplete