-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(connections): add ConnectionsRouterClassBase for pluggable connection routing #27662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
923b0d4
feat(connections): add ConnectionsRouterClassBase for pluggable conne…
harsh-vador 09733cd
address gitar
harsh-vador 33a04ee
fix checkstyle
harsh-vador c20defa
add edit ingestion path
harsh-vador 68898d8
fix checkstyle
harsh-vador fc3d150
Merge branch 'main' into classbase-askcollate-connections-support
harsh-vador 0af3b99
Merge branch 'main' into classbase-askcollate-connections-support
harsh-vador File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
openmetadata-ui/src/main/resources/ui/src/utils/ConnectionsRouterClassBase.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| /* | ||
| * Copyright 2025 Collate. | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import connectionsRouterClassBase, { | ||
| ConnectionsRouterClassBase, | ||
| } from './ConnectionsRouterClassBase'; | ||
|
|
||
| jest.mock('./RouterUtils', () => ({ | ||
| getServiceDetailsPath: (fqn: string, serviceCategory: string, tab?: string) => | ||
| tab | ||
| ? `/service/${serviceCategory}/${fqn}/${tab}` | ||
| : `/service/${serviceCategory}/${fqn}`, | ||
| getEditConnectionPath: (serviceCategory: string, fqn: string) => | ||
| `/service/${serviceCategory}/${fqn}/connection/edit-connection`, | ||
| getAddServicePath: (serviceCategory: string) => | ||
| `/${serviceCategory}/add-service`, | ||
| getPathByServiceFQN: (serviceCategory: string, fqn: string) => | ||
| `/service/${serviceCategory}/${fqn}/connection`, | ||
| getLogsViewerPath: ( | ||
| logEntityType: string, | ||
| logEntityName: string, | ||
| ingestionName: string | ||
| ) => `/logs/${logEntityType}/${logEntityName}/${ingestionName}`, | ||
| getSettingPath: (category: string, option: string) => | ||
| `/settings/${category}/${option}`, | ||
| })); | ||
|
|
||
| jest.mock('./ServiceUtils', () => ({ | ||
| getServiceRouteFromServiceType: (type: string) => `${type}Route`, | ||
| })); | ||
|
|
||
| jest.mock('../constants/constants', () => ({ | ||
| ROUTES: { | ||
| SETTINGS_WITH_CATEGORY: '/settings/:settingCategory', | ||
| }, | ||
| PLACEHOLDER_SETTING_CATEGORY: ':settingCategory', | ||
| })); | ||
|
|
||
| jest.mock('../constants/GlobalSettings.constants', () => ({ | ||
| GlobalSettingsMenuCategory: { | ||
| SERVICES: 'services', | ||
| }, | ||
| })); | ||
|
|
||
| describe('ConnectionsRouterClassBase', () => { | ||
| let router: ConnectionsRouterClassBase; | ||
|
|
||
| beforeEach(() => { | ||
| router = new ConnectionsRouterClassBase(); | ||
| }); | ||
|
|
||
| describe('embeddedMode', () => { | ||
| it('setEmbeddedMode should be a no-op', () => { | ||
| router.setEmbeddedMode(true); | ||
|
|
||
| expect(router.isEmbeddedMode()).toBe(false); | ||
| }); | ||
|
|
||
| it('isEmbeddedMode should always return false', () => { | ||
| expect(router.isEmbeddedMode()).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getSettingsServicesPath', () => { | ||
| it('should return the generic settings services path when no category given', () => { | ||
| expect(router.getSettingsServicesPath()).toBe('/settings/services'); | ||
| }); | ||
|
|
||
| it('should return the specific service-type tab path when serviceCategory given', () => { | ||
| expect(router.getSettingsServicesPath('databaseServices')).toBe( | ||
| '/settings/services/databaseServicesRoute' | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getServiceDetailsPath', () => { | ||
| it('should return service details path without tab', () => { | ||
| expect(router.getServiceDetailsPath('databaseServices', 'my-db')).toBe( | ||
| '/service/databaseServices/my-db' | ||
| ); | ||
| }); | ||
|
|
||
| it('should return service details path with tab', () => { | ||
| expect( | ||
| router.getServiceDetailsPath('databaseServices', 'my-db', 'connection') | ||
| ).toBe('/service/databaseServices/my-db/connection'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getEditConnectionPath', () => { | ||
| it('should return the edit connection path', () => { | ||
| expect(router.getEditConnectionPath('databaseServices', 'my-db')).toBe( | ||
| '/service/databaseServices/my-db/connection/edit-connection' | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getAddServicePath', () => { | ||
| it('should return the add service path', () => { | ||
| expect(router.getAddServicePath('databaseServices')).toBe( | ||
| '/databaseServices/add-service' | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getPathByServiceFQN', () => { | ||
| it('should return service path with connection tab', () => { | ||
| expect(router.getPathByServiceFQN('databaseServices', 'my-db')).toBe( | ||
| '/service/databaseServices/my-db/connection' | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getLogsViewerPath', () => { | ||
| it('should return the logs viewer path', () => { | ||
| expect( | ||
| router.getLogsViewerPath('databaseServices', 'my-db', 'pipeline-1') | ||
| ).toBe('/logs/databaseServices/my-db/pipeline-1'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('singleton default export', () => { | ||
| it('default export should be an instance of ConnectionsRouterClassBase', () => { | ||
| expect(connectionsRouterClassBase).toBeInstanceOf( | ||
| ConnectionsRouterClassBase | ||
| ); | ||
| }); | ||
|
|
||
| it('repeated imports should reference the same singleton', () => { | ||
| const { default: reimport } = jest.requireActual<{ | ||
| default: ConnectionsRouterClassBase; | ||
| }>('./ConnectionsRouterClassBase'); | ||
|
|
||
| expect(reimport).toBe(connectionsRouterClassBase); | ||
| }); | ||
| }); | ||
| }); |
97 changes: 97 additions & 0 deletions
97
openmetadata-ui/src/main/resources/ui/src/utils/ConnectionsRouterClassBase.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * Copyright 2025 Collate. | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import type { ServiceTypes } from 'Models'; | ||
| import { PLACEHOLDER_SETTING_CATEGORY, ROUTES } from '../constants/constants'; | ||
| import { GlobalSettingsMenuCategory } from '../constants/GlobalSettings.constants'; | ||
| import { | ||
| getAddServicePath, | ||
| getEditConnectionPath, | ||
| getEditIngestionPath, | ||
| getLogsViewerPath, | ||
| getPathByServiceFQN, | ||
| getServiceDetailsPath, | ||
| getSettingPath, | ||
| } from './RouterUtils'; | ||
| import { getServiceRouteFromServiceType } from './ServiceUtils'; | ||
|
|
||
| class ConnectionsRouterClassBase { | ||
| public setEmbeddedMode(_flag: boolean): void { | ||
| // no-op in base; overridden in Collate | ||
| } | ||
|
|
||
| public isEmbeddedMode(): boolean { | ||
| return false; | ||
| } | ||
|
|
||
| public getSettingsServicesPath(serviceCategory?: string): string { | ||
| if (serviceCategory) { | ||
| return getSettingPath( | ||
| GlobalSettingsMenuCategory.SERVICES, | ||
| getServiceRouteFromServiceType(serviceCategory as ServiceTypes) | ||
| ); | ||
| } | ||
|
|
||
| return ROUTES.SETTINGS_WITH_CATEGORY.replace( | ||
| PLACEHOLDER_SETTING_CATEGORY, | ||
| GlobalSettingsMenuCategory.SERVICES | ||
| ); | ||
| } | ||
|
|
||
| public getServiceDetailsPath( | ||
| serviceCategory: string, | ||
| fqn: string, | ||
| tab?: string | ||
| ): string { | ||
| return getServiceDetailsPath(fqn, serviceCategory, tab); | ||
| } | ||
|
|
||
| public getEditConnectionPath(serviceCategory: string, fqn: string): string { | ||
| return getEditConnectionPath(serviceCategory, fqn); | ||
| } | ||
|
|
||
| public getAddServicePath(serviceCategory: string): string { | ||
| return getAddServicePath(serviceCategory); | ||
| } | ||
|
|
||
| public getPathByServiceFQN(serviceCategory: string, fqn: string): string { | ||
| return getPathByServiceFQN(serviceCategory, fqn); | ||
| } | ||
|
|
||
| public getEditIngestionPath( | ||
| serviceCategory: string, | ||
| fqn: string, | ||
| ingestionFqn: string, | ||
| ingestionType: string | ||
| ): string { | ||
| return getEditIngestionPath( | ||
| serviceCategory, | ||
| fqn, | ||
| ingestionFqn, | ||
| ingestionType | ||
| ); | ||
| } | ||
|
|
||
| public getLogsViewerPath( | ||
| logEntityType: string, | ||
| logEntityName: string, | ||
| ingestionName: string | ||
| ): string { | ||
| return getLogsViewerPath(logEntityType, logEntityName, ingestionName); | ||
| } | ||
| } | ||
|
|
||
| const connectionsRouterClassBase = new ConnectionsRouterClassBase(); | ||
|
|
||
| export default connectionsRouterClassBase; | ||
| export { ConnectionsRouterClassBase }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.