Skip to content

Scenes: Updating to v6 #1019

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 22 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5b1af90
Wip
leventebalogh Jan 28, 2025
a734969
Wip
leventebalogh Jan 28, 2025
1cdaeff
Wip
leventebalogh Feb 7, 2025
ba8b336
chore: remove ts-ignore
gtk-grafana Feb 10, 2025
1732931
Merge remote-tracking branch 'origin/main' into update-to-scenes-v6
gtk-grafana Feb 25, 2025
92a9f9f
Merge branch 'main' into update-to-scenes-v6
gtk-grafana Feb 26, 2025
e6c57f8
Merge branch 'main' into update-to-scenes-v6
gtk-grafana Feb 26, 2025
3fa482d
Merge branch 'main' into update-to-scenes-v6
gtk-grafana Feb 27, 2025
3b5780e
Merge branch 'main' into update-to-scenes-v6
gtk-grafana Mar 27, 2025
cdfac0a
chore(scenes-update): resolve react-router-dom and remove SVG usage
tskarhed Apr 4, 2025
1fa1238
Merge branch 'main' into update-to-scenes-v6
tskarhed Apr 4, 2025
5abc1d8
chore(scenes): update name of private method
tskarhed Apr 4, 2025
88a057a
Merge branch 'main' into update-to-scenes-v6
gtk-grafana Apr 7, 2025
44524c0
Merge branch 'main' into update-to-scenes-v6
L2D2Grafana Apr 8, 2025
3544c9c
chore: (scenes6) - update yarn.lock for merge conflicts
L2D2Grafana Apr 8, 2025
8b3c86c
chore: (scenes6) - use svg, turn on video for debugging
L2D2Grafana Apr 8, 2025
a2131ef
chore: (scenes6) - use canary version of scenes
L2D2Grafana Apr 16, 2025
861e150
Merge branch 'main' into update-to-scenes-v6
L2D2Grafana Apr 16, 2025
6588b18
chore: (scenes6) - update renderSelectForVariable to MultiOrSingleVal…
L2D2Grafana Apr 16, 2025
5fe6d7e
Merge branch 'main' into update-to-scenes-v6
L2D2Grafana Apr 17, 2025
de7231b
chore: (scenes6) - update to [email protected]
L2D2Grafana Apr 17, 2025
50804ba
chore: (scenes6) - revert playwright config changes
L2D2Grafana Apr 17, 2025
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 @@ -68,7 +68,6 @@ const config = async (env): Promise<Configuration> => {
'redux',
'rxjs',
'react-router',
'react-router-dom',
'd3',
'angular',
/^@grafana\/ui/i,
Expand Down
2 changes: 1 addition & 1 deletion .cprc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"features": {
"bundleGrafanaUI": false,
"useReactRouterV6": false
"useReactRouterV6": true
}
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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 @@ -120,7 +119,7 @@
"@grafana/data": "^11.6.0",
"@grafana/lezer-logql": "^0.2.7",
"@grafana/runtime": "^11.6.0",
"@grafana/scenes": "5.41.1",
"@grafana/scenes": "^6.9.0",
"@grafana/ui": "^11.6.0",
"@hello-pangea/dnd": "^16.6.0",
"@lezer/common": "^1.2.1",
Expand All @@ -129,13 +128,13 @@
"re2js": "^1.1.0",
"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"
},
"resolutions": {
"**/fast-loops": "^1.1.4"
"react-router-dom": "^6.22.0"
},
"packageManager": "[email protected]"
}
6 changes: 2 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PluginOptions } from '@grafana/plugin-e2e';
import { defineConfig, devices } from '@playwright/test';
import { dirname } from 'node:path';
import {E2ESubPath} from "./tests/fixtures/explore";
import { E2ESubPath } from './tests/fixtures/explore';

const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`;

Expand Down Expand Up @@ -31,14 +31,12 @@ export default defineConfig<PluginOptions>({
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: `http://localhost:3001${E2ESubPath}`,


/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

// Turn on when debugging local tests
// video: {
// mode: 'on',
// }
// },
},
expect: { timeout: 15000 },

Expand Down
6 changes: 3 additions & 3 deletions src/Components/LogExplorationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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';

const getSceneApp = () =>
new SceneApp({
pages: [makeIndexPage(), makeRedirectPage()],
urlSyncOptions: {
createBrowserHistorySteps: false,
createBrowserHistorySteps: true,
updateUrlOnInit: true,
},
});
Expand All @@ -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
1 change: 0 additions & 1 deletion src/Components/ServiceScene/LogsPanelScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ export class LogsPanelScene extends SceneObjectBase<LogsPanelSceneState> {
.setOption('enableInfiniteScrolling', true)
.setOption('onNewLogsReceived', this.updateVisibleRange)
.setOption('logRowMenuIconsAfter', [<CopyLinkButton onClick={this.handleShareLogLineClick} key={0} />])

.setHeaderActions(
new LogOptionsScene({ visualizationType, onChangeVisualizationType: parentModel.setVisualizationType })
)
Expand Down
5 changes: 2 additions & 3 deletions src/services/CustomConstantVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Observable, of } from 'rxjs';
import {
MultiValueVariable,
MultiValueVariableState,
renderSelectForVariable,
MultiOrSingleValueSelect,
SceneComponentProps,
VariableGetOptionsArgs,
VariableValueOption,
Expand All @@ -29,8 +29,7 @@ export class CustomConstantVariable extends MultiValueVariable<CustomConstantVar
public getValueOptions(args: VariableGetOptionsArgs): Observable<VariableValueOption[]> {
return of(this.state.options);
}

public static Component = ({ model }: SceneComponentProps<MultiValueVariable>) => {
return renderSelectForVariable(model);
return MultiOrSingleValueSelect({ model });
};
}
2 changes: 1 addition & 1 deletion src/services/LogsSceneQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export class LogsSceneQueryRunner extends SceneQueryRunner {

// @todo can we make runWithTimeRange protected? (https://github.com/grafana/scenes/pull/866)
// Hack to call private method
this['runWithTimeRange'](timeRange);
this['runWithTimeRangeAndScopes'](timeRange);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oofdah, I should have cleaned this up by now, created #1201 to track my shame

}
}
2 changes: 1 addition & 1 deletion src/services/logqlMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function parseLabelFilters(query: string, filter: IndexedLabelFilter[]) {
if (!identifierPosition || identifierPosition.length === 0) {
continue;
}

const valuePosition = getAllPositionsInNodeByType(matcher, String);
const operator = query.substring(identifierPosition[0].to, valuePosition[0].from);
const key = identifierPosition[0].getExpression(query);
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