diff --git a/apps/scope/README.md b/apps/scope/README.md index 034ae1eda36..88809dab8fe 100644 --- a/apps/scope/README.md +++ b/apps/scope/README.md @@ -9,3 +9,5 @@ go test --tags "pro" -timeout 30s -run ^TestIntegrationOpenAPIs$ github.com/graf ``` ./hack/update-codegen.sh scope ``` + +This should generate a diff in the Enterprise repo. Make sure to open a PR there too. diff --git a/apps/scope/pkg/apis/scope/v0alpha1/types.go b/apps/scope/pkg/apis/scope/v0alpha1/types.go index f4c18dbb729..799195b2832 100644 --- a/apps/scope/pkg/apis/scope/v0alpha1/types.go +++ b/apps/scope/pkg/apis/scope/v0alpha1/types.go @@ -154,8 +154,8 @@ type ScopeNodeSpec struct { LinkID string `json:"linkId,omitempty"` // the k8s name // ?? should this be a slice of links - // Redirect to a specific URL when this node is selected. - RedirectUrl string `json:"redirectUrl,omitempty"` + // Redirect to a specific path when this node is selected. + RedirectPath string `json:"redirectPath,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/apps/scope/pkg/apis/scope/v0alpha1/zz_generated.openapi.go b/apps/scope/pkg/apis/scope/v0alpha1/zz_generated.openapi.go index 7cd7d1287b2..243b0ff2c2e 100644 --- a/apps/scope/pkg/apis/scope/v0alpha1/zz_generated.openapi.go +++ b/apps/scope/pkg/apis/scope/v0alpha1/zz_generated.openapi.go @@ -866,9 +866,9 @@ func schema_pkg_apis_scope_v0alpha1_ScopeNodeSpec(ref common.ReferenceCallback) Format: "", }, }, - "redirectUrl": { + "redirectPath": { SchemaProps: spec.SchemaProps{ - Description: "Redirect to a specific URL when this node is selected.", + Description: "Redirect to a specific path when this node is selected.", Type: []string{"string"}, Format: "", }, diff --git a/e2e-playwright/utils/scope-helpers.ts b/e2e-playwright/utils/scope-helpers.ts index 867b0ae3c8d..4fb12cc41da 100644 --- a/e2e-playwright/utils/scope-helpers.ts +++ b/e2e-playwright/utils/scope-helpers.ts @@ -19,7 +19,7 @@ export type TestScope = { type?: string; category?: string; addLinks?: boolean; - redirectUrl?: string; + redirectPath?: string; }; type ScopeDashboardBinding = Resource; @@ -56,8 +56,8 @@ export async function scopeNodeChildrenRequest( linkType: 'scope', linkId: `scope-${scope.name}`, }), - ...(scope.redirectUrl && { - redirectUrl: scope.redirectUrl, + ...(scope.redirectPath && { + redirectPath: scope.redirectPath, }), }, })), diff --git a/e2e-playwright/utils/scopes.ts b/e2e-playwright/utils/scopes.ts index 2dc1923cb7f..c5b141d4eb7 100644 --- a/e2e-playwright/utils/scopes.ts +++ b/e2e-playwright/utils/scopes.ts @@ -111,14 +111,14 @@ export const testScopesWithRedirect = (): TestScope[] => { { name: 'sn-redirect-custom', title: 'Custom Redirect', - redirectUrl: '/d/cuj-dashboard-2', // Use existing dashboard + redirectPath: '/d/cuj-dashboard-2', // Use existing dashboard filters: [{ key: 'namespace', operator: 'equals', value: 'custom-redirect' }], addLinks: true, }, { name: 'sn-redirect-fallback', title: 'Fallback Navigation', - // No redirectUrl - should fall back to scope navigation + // No redirectPath - should fall back to scope navigation filters: [{ key: 'namespace', operator: 'equals', value: 'fallback-nav' }], dashboardUid: 'cuj-dashboard-2', // Use existing dashboard dashboardTitle: 'CUJ Dashboard 2', diff --git a/packages/grafana-data/src/types/scopes.ts b/packages/grafana-data/src/types/scopes.ts index e69029f1efa..98b32dfa0c7 100644 --- a/packages/grafana-data/src/types/scopes.ts +++ b/packages/grafana-data/src/types/scopes.ts @@ -84,8 +84,8 @@ export interface ScopeNodeSpec { // Id of the parent node. parentName?: string; - // Redirect to a specific URL when this node is selected. - redirectUrl?: string; + // Redirect to a specific path when this node is selected. + redirectPath?: string; } // TODO: Use Resource from apiserver when we export the types diff --git a/public/app/features/scopes/selector/ScopesSelectorService.test.ts b/public/app/features/scopes/selector/ScopesSelectorService.test.ts index d6873709bd7..39e444fc6a5 100644 --- a/public/app/features/scopes/selector/ScopesSelectorService.test.ts +++ b/public/app/features/scopes/selector/ScopesSelectorService.test.ts @@ -719,11 +719,11 @@ describe('ScopesSelectorService', () => { parentName: '', nodeType: 'leaf', title: 'test-scope-node', - redirectUrl: '/custom-redirect-url', + redirectPath: '/custom-redirect-url', }, }; - // Mock fetchNodes to return the node with redirectUrl + // Mock fetchNodes to return the node with redirectPath apiClient.fetchNodes = jest .fn() .mockImplementation((options: { parent?: string; query?: string; limit?: number }) => { @@ -755,7 +755,7 @@ describe('ScopesSelectorService', () => { parentName: '', nodeType: 'leaf', title: 'test-scope-node', - redirectUrl: '/priority-redirect', + redirectPath: '/priority-redirect', }, }; @@ -767,7 +767,7 @@ describe('ScopesSelectorService', () => { }, ]; - // Mock fetchNodes to return the node with redirectUrl + // Mock fetchNodes to return the node with redirectPath apiClient.fetchNodes = jest .fn() .mockImplementation((options: { parent?: string; query?: string; limit?: number }) => { @@ -790,7 +790,7 @@ describe('ScopesSelectorService', () => { // Then apply to trigger the redirect await service.apply(); - // Should use redirectUrl, not scope navigation + // Should use redirectPath, not scope navigation expect(locationService.push).toHaveBeenCalledWith('/priority-redirect'); expect(locationService.push).toHaveBeenCalledTimes(1); }); diff --git a/public/app/features/scopes/selector/ScopesSelectorService.ts b/public/app/features/scopes/selector/ScopesSelectorService.ts index ab191148474..370258d4785 100644 --- a/public/app/features/scopes/selector/ScopesSelectorService.ts +++ b/public/app/features/scopes/selector/ScopesSelectorService.ts @@ -389,9 +389,9 @@ export class ScopesSelectorService extends ScopesServiceBase { - // Check if the selected scope has a redirect URL - if (scopeNode && scopeNode.spec.redirectUrl && typeof scopeNode.spec.redirectUrl === 'string') { - locationService.push(scopeNode.spec.redirectUrl); + // Check if the selected scope has a redirect path + if (scopeNode && scopeNode.spec.redirectPath && typeof scopeNode.spec.redirectPath === 'string') { + locationService.push(scopeNode.spec.redirectPath); return; }