Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions workspaces/bulk-import/.changeset/plenty-fans-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@red-hat-developer-hub/backstage-plugin-bulk-import': major
---

Simplified bulk-import routing structure:

- The plugin now uses a single `/bulk-import` path instead of multiple paths
- Removed `/bulk-import/repositories`, `/bulk-import/repositories/repositories`, and `/bulk-import/repositories/add` routes
- Any undefined paths under `/bulk-import/*` will redirect to `/bulk-import`
- **BREAKING**: Removed `addRepositoriesRouteRef` from plugin exports
4 changes: 2 additions & 2 deletions workspaces/bulk-import/packages/app/e2e-tests/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ test.describe('Bulk Import', () => {
await expect(sidebar).toMatchAriaSnapshot(`
- button "${translations.common.save}"
- link "${translations.common.cancel}":
- /url: /bulk-import/repositories
- /url: /bulk-import
- button "${translations.common.cancel}"
`);

Expand Down Expand Up @@ -249,7 +249,7 @@ test.describe('Bulk Import', () => {
await expect(addRepoFooter).toMatchAriaSnapshot(`
- button "${translations.common.import}"
- link "${translations.common.cancel}":
- /url: /bulk-import/repositories
- /url: /bulk-import
- button "${translations.common.cancel}"
`);
await sharedPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ to this repository so that the component can
be added to the [software catalog](http://localhost:3000/catalog).
After this pull request is merged, the component will become available.
For more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).
View the import job in your app [here](http://localhost:3000/bulk-import/repositories?repository=${repositories.frontendApp.url}&defaultBranch=${repositories.frontendApp.defaultBranch}).`,
View the import job in your app [here](http://localhost:3000/bulk-import?repository=${repositories.frontendApp.url}&defaultBranch=${repositories.frontendApp.defaultBranch}).`,
catalogInfoContent: `apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function getPreviewSidebarSnapshots(t: BulkImportMessages) {
- text: ${prBodyLabel}
- textbox "${prBodyLabel}":
- /placeholder: ${t.previewFile.pullRequest.bodyPlaceholder}
- text: /This pull request adds a \\*\\*Backstage entity metadata file\\*\\* to this repository so that the component can be added to the \\[software catalog\\]\\(http:\\/\\/localhost:\\d+\\/catalog\\)\\. After this pull request is merged, the component will become available\\. For more information, read an \\[overview of the Backstage software catalog\\]\\(https:\\/\\/backstage\\.io\\/docs\\/features\\/software-catalog\\/\\)\\. View the import job in your app \\[here\\]\\(http:\\/\\/localhost:\\d+\\/bulk-import\\/repositories\\?repository=https:\\/\\/github\\.com\\/test-org\\/backend-service&defaultBranch=main\\)\\./
- text: /This pull request adds a \\*\\*Backstage entity metadata file\\*\\* to this repository so that the component can be added to the \\[software catalog\\]\\(http:\\/\\/localhost:\\d+\\/catalog\\)\\. After this pull request is merged, the component will become available\\. For more information, read an \\[overview of the Backstage software catalog\\]\\(https:\\/\\/backstage\\.io\\/docs\\/features\\/software-catalog\\/\\)\\. View the import job in your app \\[here\\]\\(http:\\/\\/localhost:\\d+\\/bulk-import\\?repository=https:\\/\\/github\\.com\\/test-org\\/backend-service&defaultBranch=main\\)\\./
`,

/**
Expand Down Expand Up @@ -149,7 +149,7 @@ export function getPreviewSidebarSnapshots(t: BulkImportMessages) {
- /url: https://backstage.io/docs/features/software-catalog/
- text: . View the import job in your app
- link "here":
- /url: http://localhost:3000/bulk-import/repositories?repository=https://github.com/test-org/backend-service&defaultBranch=main
- /url: http://localhost:3000/bulk-import?repository=https://github.com/test-org/backend-service&defaultBranch=main
- text: .
`,

Expand Down
3 changes: 1 addition & 2 deletions workspaces/bulk-import/packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ const routes = (
</Route>
<Route path="/settings" element={<UserSettingsPage />} />
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
<Route path="/bulk-import" element={<Navigate to="repositories" />} />
<Route path="/bulk-import/repositories" element={<BulkImportPage />} />
<Route path="/bulk-import/*" element={<BulkImportPage />} />
<Route path="/notifications" element={<NotificationsPage />} />
<Route path="/orchestrator" element={<OrchestratorPage />} />
<Route path="/rbac" element={<RbacPage />} />
Expand Down
6 changes: 1 addition & 5 deletions workspaces/bulk-import/plugins/bulk-import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ g, user:default/<login-id/user-name>, role:default/team_a
import { BulkImportPage } from '@red-hat-developer-hub/backstage-plugin-bulk-import';
...
/* highlight-add-start */
<Route
path="/bulk-import"
element={<Navigate to="repositories" />}
/>
<Route
path="/bulk-import/repositories"
path="/bulk-import/*"
element={<BulkImportPage />}
/>
/* highlight-add-end */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dynamicPlugins:
module: BulkImportPlugin
importName: BulkImportIcon
dynamicRoutes:
- path: /bulk-import/repositories
- path: /bulk-import
importName: BulkImportPage
module: BulkImportPlugin
menuItem:
Expand Down
2 changes: 1 addition & 1 deletion workspaces/bulk-import/plugins/bulk-import/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ createDevApp()
</TestApiProvider>
),
title: 'Bulk import',
path: '/bulk-import/repositories',
path: '/bulk-import',
icon: BulkImportIcon,
})
.render();
1 change: 0 additions & 1 deletion workspaces/bulk-import/plugins/bulk-import/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const BulkImportPage: () => JSX_2.Element;
// @public
export const bulkImportPlugin: BackstagePlugin< {
root: RouteRef<undefined>;
addRepositories: SubRouteRef<undefined>;
tasks: SubRouteRef<PathParams<"/import-history/:repoUrl">>;
}, {}, {}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const AddRepositoriesFormFooter = () => {
) : (
submitButton
)}
<Link to="/bulk-import/repositories">
<Link to="/bulk-import">
<Button variant="outlined">{t('common.cancel')}</Button>
</Link>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const BulkImportSidebarItem = () => {
return allowed ? (
<SidebarItem
text={t('sidebar.bulkImport')}
to="bulk-import/repositories"
to="bulk-import"
icon={BulkImportIcon}
/>
) : null;
Expand All @@ -70,7 +70,7 @@ export const BulkImportSidebarItem = () => {
return (
<SidebarItem
text={t('sidebar.bulkImport')}
to="bulk-import/repositories"
to="bulk-import"
icon={BulkImportIcon}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const AddedRepositoryTableRow = ({
{importFlow === ImportFlow.Scaffolder ||
importFlow === ImportFlow.Orchestrator ? (
<Link
to={`/bulk-import/repositories/import-history/${encodeURIComponent(
to={`/bulk-import/import-history/${encodeURIComponent(
data.repoUrl || '',
)}`}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,16 @@ describe('Router component', () => {
expect(screen.queryByText('Add Repositories')).toBeInTheDocument();
});

it('renders AddRepositoriesPage when path is "/repositories"', () => {
it('redirects undefined paths to bulk-import root', () => {
render(
<MemoryRouter initialEntries={['/repositories']}>
<MemoryRouter initialEntries={['/some-undefined-path']}>
<Router />
</MemoryRouter>,
);

expect(screen.queryByText('Add Repositories')).toBeInTheDocument();
});

it('renders Add repositories page when path matches addRepositoriesRouteRef', () => {
render(
<MemoryRouter initialEntries={['/add']}>
<Router />
</MemoryRouter>,
);

expect(screen.queryByText('Add Repositories')).toBeInTheDocument();
// The catch-all route redirects to /bulk-import, which then renders AddRepositoriesPage
// Since we're testing in isolation with MemoryRouter, the redirect happens but
// we may not see the content. This test verifies the route exists and doesn't crash.
expect(screen.queryByText('Add Repositories')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import { Route, Routes } from 'react-router-dom';
import { Navigate, Route, Routes } from 'react-router-dom';

import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import { addRepositoriesRouteRef, importHistoryRouteRef } from '../routes';
import { importHistoryRouteRef } from '../routes';
import { AddRepositoriesPage } from './AddRepositories/AddRepositoriesPage';
import { ImportHistoryPage } from './Repositories/ImportHistoryPage';

Expand All @@ -32,15 +32,12 @@ export const Router = () => (
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/" element={<AddRepositoriesPage />} />
<Route path="repositories" element={<AddRepositoriesPage />} />
<Route
path={addRepositoriesRouteRef.path}
element={<AddRepositoriesPage />}
/>
<Route
path={importHistoryRouteRef.path}
element={<ImportHistoryPage />}
/>
{/* Redirect any undefined paths to the root */}
<Route path="*" element={<Navigate to="/bulk-import" replace />} />
</Routes>
</QueryClientProvider>
);
7 changes: 1 addition & 6 deletions workspaces/bulk-import/plugins/bulk-import/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ import {
bulkImportApiRef,
BulkImportBackendClient,
} from './api/BulkImportBackendClient';
import {
addRepositoriesRouteRef,
importHistoryRouteRef,
rootRouteRef,
} from './routes';
import { importHistoryRouteRef, rootRouteRef } from './routes';

/**
* @public
Expand All @@ -41,7 +37,6 @@ export const bulkImportPlugin = createPlugin({
id: 'bulk-import',
routes: {
root: rootRouteRef,
addRepositories: addRepositoriesRouteRef,
tasks: importHistoryRouteRef,
},
apis: [
Expand Down
6 changes: 0 additions & 6 deletions workspaces/bulk-import/plugins/bulk-import/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ export const rootRouteRef = createRouteRef({
id: 'bulk-import',
});

export const addRepositoriesRouteRef = createSubRouteRef({
id: 'bulk-import-repositories-add',
parent: rootRouteRef,
path: '/add',
});

export const importHistoryRouteRef = createSubRouteRef({
id: 'bulk-import-actions',
parent: rootRouteRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ describe('Repository utils', () => {
number: 105,
url: 'https://github.com/che-electron/client/pull/105',
title: 'Add catalog-info.yaml config file',
body: 'This pull request adds a **Backstage entity metadata file**\nto this repository so that the component can\nbe added to the [software catalog](http://localhost:3000/catalog).\nAfter this pull request is merged, the component will become available.\nFor more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).\nView the import job in your app [here](http://localhost:3000/bulk-import/repositories?repository=https://github.com/che-electron/client&defaultBranch=master).',
body: 'This pull request adds a **Backstage entity metadata file**\nto this repository so that the component can\nbe added to the [software catalog](http://localhost:3000/catalog).\nAfter this pull request is merged, the component will become available.\nFor more information, read an [overview of the Backstage software catalog](https://backstage.io/docs/features/software-catalog/).\nView the import job in your app [here](http://localhost:3000/bulk-import?repository=https://github.com/che-electron/client&defaultBranch=master).',
catalogInfoContent:
'apiVersion: backstage.io/v1alpha1\nkind: Component\nmetadata:\n name: client\n annotations:\n github.com/project-slug: che-electron/client\nspec:\n type: other\n lifecycle: unknown\n owner: user:default/debsmita1\n',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ export const getPRTemplate = (
gitProvider: 'github' | 'gitlab',
): PullRequestPreview => {
const importJobUrl = repositoryUrl
? `${baseUrl}/bulk-import/repositories?repository=${repositoryUrl}&defaultBranch=${defaultBranch}`
: `${baseUrl}/bulk-import/repositories`;
? `${baseUrl}/bulk-import?repository=${repositoryUrl}&defaultBranch=${defaultBranch}`
: `${baseUrl}/bulk-import`;
const name = cleanComponentName(componentName);
return {
componentName: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,27 @@ test.describe('Bulk import plugin', () => {
timeout: 20000,
});
});

test('Direct navigation to /bulk-import works', async () => {
await page.goto('/bulk-import');
await expect(
page.getByRole('heading', { name: 'Bulk import', exact: true }),
).toBeVisible({
timeout: 20000,
});
// Verify URL is /bulk-import
expect(page.url()).toContain('/bulk-import');
});

test('Undefined paths redirect to /bulk-import', async () => {
await page.goto('/bulk-import/some-undefined-path');
await expect(
page.getByRole('heading', { name: 'Bulk import', exact: true }),
).toBeVisible({
timeout: 20000,
});
// Verify URL redirects to /bulk-import
expect(page.url()).toContain('/bulk-import');
expect(page.url()).not.toContain('some-undefined-path');
});
});
2 changes: 1 addition & 1 deletion workspaces/extensions/dynamic-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins:
- name: bulkImportIcon3
importName: BulkImportIcon3
dynamicRoutes:
- path: /bulk-import/repositories
- path: /bulk-import
importName: BulkImportPage
menuItem:
icon: bulkImportIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
- name: bulkImportIcon
importName: BulkImportIcon
dynamicRoutes:
- path: /bulk-import/repositories
- path: /bulk-import
importName: BulkImportPage
menuItem:
icon: bulkImportIcon
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/backstage-plugin-global-floating-action-button': patch
---

Updated documentation examples to use the new `/bulk-import` route instead of `/bulk-import/repositories`
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ The sections below are relevant for static plugins. If the plugin is expected to
icon: <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#e8eaed"><g><rect fill="none" height="24" width="24"/></g><g><path d="M11,7L9.6,8.4l2.6,2.6H2v2h10.2l-2.6,2.6L11,17l5-5L11,7z M20,19h-8v2h8c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-8v2h8V19z"/></g></svg>
label: 'Bulk import'
toolTip: 'Register multiple repositories in bulk'
to: /bulk-import/repositories
to: /bulk-import
# end of fab config
appIcons:
- name: bulkImportIcon
importName: BulkImportIcon
dynamicRoutes:
- path: /bulk-import/repositories
- path: /bulk-import
importName: BulkImportPage
menuItem:
icon: bulkImportIcon
Expand Down Expand Up @@ -94,13 +94,13 @@ The sections below are relevant for static plugins. If the plugin is expected to
icon: <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#e8eaed"><g><rect fill="none" height="24" width="24"/></g><g><path d="M11,7L9.6,8.4l2.6,2.6H2v2h10.2l-2.6,2.6L11,17l5-5L11,7z M20,19h-8v2h8c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-8v2h8V19z"/></g></svg>
label: 'Bulk import'
toolTip: 'Register multiple repositories in bulk'
to: /bulk-import/repositories
to: /bulk-import
# end of fab config
appIcons:
- name: bulkImportIcon
importName: BulkImportIcon
dynamicRoutes:
- path: /bulk-import/repositories
- path: /bulk-import
importName: BulkImportPage
menuItem:
icon: bulkImportIcon
Expand Down Expand Up @@ -150,14 +150,14 @@ The sections below are relevant for static plugins. If the plugin is expected to
icon: <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#e8eaed"><g><rect fill="none" height="24" width="24"/></g><g><path d="M11,7L9.6,8.4l2.6,2.6H2v2h10.2l-2.6,2.6L11,17l5-5L11,7z M20,19h-8v2h8c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-8v2h8V19z"/></g></svg>
label: 'Bulk import'
toolTip: 'Register multiple repositories in bulk'
to: /bulk-import/repositories
to: /bulk-import
visibleOnPaths: ['/catalog', '/settings']
# end of fab config
appIcons:
- name: bulkImportIcon
importName: BulkImportIcon
dynamicRoutes:
- path: /bulk-import/repositories
- path: /bulk-import
importName: BulkImportPage
menuItem:
icon: bulkImportIcon
Expand All @@ -184,14 +184,14 @@ The sections below are relevant for static plugins. If the plugin is expected to
icon: <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#e8eaed"><g><rect fill="none" height="24" width="24"/></g><g><path d="M11,7L9.6,8.4l2.6,2.6H2v2h10.2l-2.6,2.6L11,17l5-5L11,7z M20,19h-8v2h8c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-8v2h8V19z"/></g></svg>
label: 'Bulk import'
toolTip: 'Register multiple repositories in bulk'
to: /bulk-import/repositories
to: /bulk-import
excludeOnPaths: ['/bulk-import']
# end of fab config
appIcons:
- name: bulkImportIcon
importName: BulkImportIcon
dynamicRoutes:
- path: /bulk-import/repositories
- path: /bulk-import
importName: BulkImportPage
menuItem:
icon: bulkImportIcon
Expand Down
2 changes: 1 addition & 1 deletion workspaces/quickstart/app-config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ app:
cta:
text: Import
textKey: steps.importApplication.ctaTitle
link: /bulk-import/repositories
link: /bulk-import
- title: Learn about the Catalog
titleKey: steps.learnAboutCatalog.title
roles:
Expand Down
2 changes: 1 addition & 1 deletion workspaces/quickstart/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ app:
cta:
text: Import
textKey: steps.importApplication.ctaTitle
link: /bulk-import/repositories
link: /bulk-import
- title: Learn about the Catalog
titleKey: steps.learnAboutCatalog.title
roles:
Expand Down
Loading