Skip to content

Commit

Permalink
Show empty panel for services tab
Browse files Browse the repository at this point in the history
  • Loading branch information
adrapereira committed Feb 21, 2024
1 parent 9792adb commit cc71d01
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
64 changes: 64 additions & 0 deletions src/components/Explore/TracesByService/Tabs/ServicesTabScene.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from 'react';

import {
SceneCanvasText,
SceneComponentProps,
SceneFlexItem,
SceneFlexLayout,
SceneObjectBase,
SceneObjectState,
} from '@grafana/scenes';

export interface ServicesTabSceneState extends SceneObjectState {
loading?: boolean;
panel?: SceneFlexLayout;
}

export class ServicesTabScene extends SceneObjectBase<ServicesTabSceneState> {
constructor(state: Partial<ServicesTabSceneState>) {
super({
...state,
});

this.addActivationHandler(this._onActivate.bind(this));
}

public _onActivate() {
if (!this.state.panel) {
this.setState({
panel: this.getVizPanel(),
});
}
}

private getVizPanel() {
return new SceneFlexLayout({
direction: 'row',
children: [
new SceneFlexItem({
body: new SceneCanvasText({
text: 'No content available yet',
fontSize: 20,
align: 'center',
}),
}),
],
});
}

public static Component = ({ model }: SceneComponentProps<ServicesTabScene>) => {
const { panel } = model.useState();

if (!panel) {
return;
}

return <panel.Component model={panel} />;
};
}

export function buildServicesTabScene() {
return new SceneFlexItem({
body: new ServicesTabScene({}),
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from '../../../utils/shared';
import { getExplorationFor } from '../../../utils/utils';
import { ShareExplorationButton } from './ShareExplorationButton';
import { buildServicesTabScene } from './Tabs/ServicesTabScene';

export interface TraceSceneState extends SceneObjectState {
body: SceneFlexLayout;
Expand Down Expand Up @@ -97,7 +98,7 @@ export class TracesByServiceScene extends SceneObjectBase<TraceSceneState> {

const actionViewsDefinitions: ActionViewDefinition[] = [
{ displayName: 'Spans', value: 'spans', getScene: buildTracesListScene },
{ displayName: 'Services', value: 'services', getScene: buildTracesListScene },
{ displayName: 'Services', value: 'services', getScene: buildServicesTabScene },
];

export interface TracesActionBarState extends SceneObjectState {}
Expand Down

0 comments on commit cc71d01

Please sign in to comment.