Skip to content
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

Scenes: Updating to v6 #1019

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
1 change: 0 additions & 1 deletion .config/webpack/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const config = async (env): Promise<Configuration> => {
'redux',
'rxjs',
'react-router',
'react-router-dom',
'd3',
'angular',
'@grafana/ui',
Expand Down
5 changes: 4 additions & 1 deletion .cprc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"features": {}
"features": {
"bundleGrafanaUI": false,
"useReactRouterV6": true
}
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"@types/jest": "^29.5.0",
"@types/lodash": "^4.14.194",
"@types/node": "^20.8.7",
"@types/react-router-dom": "^5.2.0",
"@types/react-scroll-sync": "^0.9.0",
"@types/react-table": "^7.7.20",
"@types/testing-library__jest-dom": "5.14.8",
Expand Down Expand Up @@ -105,7 +104,7 @@
"@grafana/data": "^11.3.0",
"@grafana/lezer-logql": "^0.2.7",
"@grafana/runtime": "^11.3.0",
"@grafana/scenes": "5.41.0",
"@grafana/scenes": "6.0.0--canary.979.13200094417.0",
"@grafana/ui": "^11.3.0",
"@hello-pangea/dnd": "^16.6.0",
"@lezer/common": "^1.2.1",
Expand All @@ -114,7 +113,7 @@
"@types/react-table": "^7.7.20",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-router-dom": "^5.2.0",
"react-router-dom": "^6.22.0",
"rxjs": "7.8.1",
"tslib": "2.5.3",
"uuid": "^10.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/Components/LogExplorationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect } from 'react';

import { SceneApp, useSceneApp } from '@grafana/scenes';
import { config } from '@grafana/runtime';
import { Redirect } from 'react-router-dom';
import { Navigate } from 'react-router-dom';
import { makeIndexPage, makeRedirectPage } from './Pages';
import { initializeMetadataService } from '../services/metadata';

Expand Down Expand Up @@ -31,7 +31,7 @@ function LogExplorationView() {
const userPermissions = config.bootData.user.permissions;
const canUseApp = userPermissions?.['grafana-lokiexplore-app:read'] || userPermissions?.['datasources:explore'];
if (!canUseApp) {
return <Redirect to="/" />;
return <Navigate to="/" replace />;
}

if (!isInitialized) {
Expand Down
4 changes: 3 additions & 1 deletion src/Components/Pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function makeIndexPage() {
url: prefixRoute(PageSlugs.explore),
layout: PageLayoutType.Custom,
preserveUrlKeys: SERVICE_URL_KEYS,
routePath: prefixRoute(PageSlugs.explore),
routePath: `${PageSlugs.explore}/*`,
getScene: (routeMatch) => getServicesScene(routeMatch),
drilldowns: [
{
Expand Down Expand Up @@ -122,6 +122,7 @@ export function makeBreakdownPage(
title: capitalizeFirstLetter(slug),
layout: PageLayoutType.Custom,
url: ROUTES[slug](labelValue, labelName),
routePath: ROUTE_DEFINITIONS[slug],
preserveUrlKeys: DRILLDOWN_URL_KEYS,
getParentPage: () => parent,
getScene: (routeMatch) => getServicesScene(routeMatch),
Expand Down Expand Up @@ -150,6 +151,7 @@ export function makeBreakdownValuePage(
title: capitalizeFirstLetter(breakdownLabel),
layout: PageLayoutType.Custom,
url: SUB_ROUTES[slug](labelValue, labelName, breakdownLabel),
routePath: CHILD_ROUTE_DEFINITIONS[slug],
preserveUrlKeys: DRILLDOWN_URL_KEYS,
getParentPage: () => parent,
getScene: (routeMatch) => getServicesScene(routeMatch),
Expand Down
14 changes: 7 additions & 7 deletions src/services/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ export const SUB_ROUTES = {
};

export const ROUTE_DEFINITIONS: Record<keyof typeof PageSlugs, string> = {
explore: prefixRoute(PageSlugs.explore),
logs: prefixRoute(`${PageSlugs.explore}/:labelName/:labelValue/${PageSlugs.logs}`),
fields: prefixRoute(`${PageSlugs.explore}/:labelName/:labelValue/${PageSlugs.fields}`),
patterns: prefixRoute(`${PageSlugs.explore}/:labelName/:labelValue/${PageSlugs.patterns}`),
labels: prefixRoute(`${PageSlugs.explore}/:labelName/:labelValue/${PageSlugs.labels}`),
explore: `${PageSlugs.explore}/*`,
logs: `:labelName/:labelValue/${PageSlugs.logs}`,
fields: `:labelName/:labelValue/${PageSlugs.fields}`,
patterns: `:labelName/:labelValue/${PageSlugs.patterns}`,
labels: `:labelName/:labelValue/${PageSlugs.labels}`,
};

export const CHILD_ROUTE_DEFINITIONS: Record<keyof typeof ValueSlugs, string> = {
field: prefixRoute(`${PageSlugs.explore}/:labelName/:labelValue/${ValueSlugs.field}/:breakdownLabel`),
label: prefixRoute(`${PageSlugs.explore}/:labelName/:labelValue/${ValueSlugs.label}/:breakdownLabel`),
field: `:labelName/:labelValue/${ValueSlugs.field}/:breakdownLabel`,
label: `:labelName/:labelValue/${ValueSlugs.label}/:breakdownLabel`,
};

export const EXPLORATIONS_ROUTE = `${PLUGIN_BASE_URL}/${PageSlugs.explore}`;
Expand Down
Loading
Loading