mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: Shows SubMenu when filtering directly from table (#21017)
* Fix: Shows SubMenu when filtering from table Fixes #20270 * Tests: Updates snapshots * Refactor: Changes after PR comments * Refactor: Changes template
This commit is contained in:
parent
4698cef2a2
commit
8495af4c52
@ -1,16 +1,22 @@
|
|||||||
import angular, { ILocationService } from 'angular';
|
import angular, { ILocationService } from 'angular';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { VariableSrv } from 'app/features/templating/all';
|
import { VariableSrv } from 'app/features/templating/all';
|
||||||
|
import { CoreEvents } from '../../../../types';
|
||||||
|
|
||||||
export class SubMenuCtrl {
|
export class SubMenuCtrl {
|
||||||
annotations: any;
|
annotations: any;
|
||||||
variables: any;
|
variables: any;
|
||||||
dashboard: any;
|
dashboard: any;
|
||||||
|
submenuEnabled: boolean;
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
constructor(private variableSrv: VariableSrv, private $location: ILocationService) {
|
constructor(private variableSrv: VariableSrv, private $location: ILocationService) {
|
||||||
this.annotations = this.dashboard.templating.list;
|
this.annotations = this.dashboard.templating.list;
|
||||||
this.variables = this.variableSrv.variables;
|
this.variables = this.variableSrv.variables;
|
||||||
|
this.submenuEnabled = false;
|
||||||
|
this.dashboard.events.on(CoreEvents.submenuVisibilityChanged, (enabled: boolean) => {
|
||||||
|
this.submenuEnabled = enabled;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
annotationStateChanged() {
|
annotationStateChanged() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="submenu-controls">
|
<div class="submenu-controls" ng-hide="ctrl.submenuEnabled === false">
|
||||||
<div ng-repeat="variable in ctrl.variables" ng-hide="variable.hide === 2" class="submenu-item gf-form-inline">
|
<div ng-repeat="variable in ctrl.variables" ng-hide="variable.hide === 2" class="submenu-item gf-form-inline">
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<label
|
<label
|
||||||
|
@ -1,37 +1,33 @@
|
|||||||
// Libraries
|
// Libraries
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import React, { PureComponent, MouseEvent } from 'react';
|
import React, { MouseEvent, PureComponent } from 'react';
|
||||||
import { hot } from 'react-hot-loader';
|
import { hot } from 'react-hot-loader';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
// Services & Utils
|
// Services & Utils
|
||||||
import { createErrorNotification } from 'app/core/copy/appNotification';
|
import { createErrorNotification } from 'app/core/copy/appNotification';
|
||||||
import { getMessageFromError } from 'app/core/utils/errors';
|
import { getMessageFromError } from 'app/core/utils/errors';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { DashboardGrid } from '../dashgrid/DashboardGrid';
|
import { DashboardGrid } from '../dashgrid/DashboardGrid';
|
||||||
import { DashNav } from '../components/DashNav';
|
import { DashNav } from '../components/DashNav';
|
||||||
import { SubMenu } from '../components/SubMenu';
|
import { SubMenu } from '../components/SubMenu';
|
||||||
import { DashboardSettings } from '../components/DashboardSettings';
|
import { DashboardSettings } from '../components/DashboardSettings';
|
||||||
import { CustomScrollbar, Alert } from '@grafana/ui';
|
import { Alert, CustomScrollbar } from '@grafana/ui';
|
||||||
|
|
||||||
// Redux
|
// Redux
|
||||||
import { initDashboard } from '../state/initDashboard';
|
import { initDashboard } from '../state/initDashboard';
|
||||||
import { cleanUpDashboard } from '../state/actions';
|
import { cleanUpDashboard } from '../state/actions';
|
||||||
import { updateLocation } from 'app/core/actions';
|
import { notifyApp, updateLocation } from 'app/core/actions';
|
||||||
import { notifyApp } from 'app/core/actions';
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {
|
import {
|
||||||
StoreState,
|
AppNotificationSeverity,
|
||||||
|
DashboardInitError,
|
||||||
DashboardInitPhase,
|
DashboardInitPhase,
|
||||||
DashboardRouteInfo,
|
DashboardRouteInfo,
|
||||||
DashboardInitError,
|
StoreState,
|
||||||
AppNotificationSeverity,
|
|
||||||
} from 'app/types';
|
} from 'app/types';
|
||||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||||
import { PanelInspector } from '../components/Inspector/PanelInspector';
|
import { PanelInspector } from '../components/Inspector/PanelInspector';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
urlUid?: string;
|
urlUid?: string;
|
||||||
urlSlug?: string;
|
urlSlug?: string;
|
||||||
@ -301,7 +297,7 @@ export class DashboardPage extends PureComponent<Props, State> {
|
|||||||
{initError && this.renderInitFailedState()}
|
{initError && this.renderInitFailedState()}
|
||||||
|
|
||||||
<div className={gridWrapperClasses}>
|
<div className={gridWrapperClasses}>
|
||||||
{dashboard.meta.submenuEnabled && <SubMenu dashboard={dashboard} />}
|
<SubMenu dashboard={dashboard} />
|
||||||
<DashboardGrid
|
<DashboardGrid
|
||||||
dashboard={dashboard}
|
dashboard={dashboard}
|
||||||
isEditing={isEditing}
|
isEditing={isEditing}
|
||||||
|
@ -118,6 +118,98 @@ exports[`DashboardPage Dashboard init completed Should render dashboard grid 1`
|
|||||||
<div
|
<div
|
||||||
className="dashboard-container"
|
className="dashboard-container"
|
||||||
>
|
>
|
||||||
|
<SubMenu
|
||||||
|
dashboard={
|
||||||
|
DashboardModel {
|
||||||
|
"annotations": Object {
|
||||||
|
"list": Array [
|
||||||
|
Object {
|
||||||
|
"builtIn": 1,
|
||||||
|
"datasource": "-- Grafana --",
|
||||||
|
"enable": true,
|
||||||
|
"hide": true,
|
||||||
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
|
"name": "Annotations & Alerts",
|
||||||
|
"type": "dashboard",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"autoUpdate": undefined,
|
||||||
|
"description": undefined,
|
||||||
|
"editable": true,
|
||||||
|
"events": Emitter {
|
||||||
|
"emitter": EventEmitter {
|
||||||
|
"_events": Object {},
|
||||||
|
"_eventsCount": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gnetId": null,
|
||||||
|
"graphTooltip": 0,
|
||||||
|
"id": null,
|
||||||
|
"links": Array [],
|
||||||
|
"meta": Object {
|
||||||
|
"canEdit": true,
|
||||||
|
"canMakeEditable": false,
|
||||||
|
"canSave": true,
|
||||||
|
"canShare": true,
|
||||||
|
"canStar": true,
|
||||||
|
"fullscreen": false,
|
||||||
|
"isEditing": false,
|
||||||
|
"showSettings": true,
|
||||||
|
},
|
||||||
|
"originalTemplating": Array [],
|
||||||
|
"originalTime": Object {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now",
|
||||||
|
},
|
||||||
|
"panels": Array [
|
||||||
|
PanelModel {
|
||||||
|
"cachedPluginOptions": Object {},
|
||||||
|
"datasource": null,
|
||||||
|
"events": Emitter {
|
||||||
|
"emitter": EventEmitter {
|
||||||
|
"_events": Object {},
|
||||||
|
"_eventsCount": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gridPos": Object {
|
||||||
|
"h": 1,
|
||||||
|
"w": 1,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
},
|
||||||
|
"id": 1,
|
||||||
|
"targets": Array [
|
||||||
|
Object {
|
||||||
|
"refId": "A",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "My graph",
|
||||||
|
"transparent": false,
|
||||||
|
"type": "graph",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"refresh": undefined,
|
||||||
|
"revision": undefined,
|
||||||
|
"schemaVersion": 21,
|
||||||
|
"snapshot": undefined,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": Array [],
|
||||||
|
"templating": Object {
|
||||||
|
"list": Array [],
|
||||||
|
},
|
||||||
|
"time": Object {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now",
|
||||||
|
},
|
||||||
|
"timepicker": Object {},
|
||||||
|
"timezone": "",
|
||||||
|
"title": "My dashboard",
|
||||||
|
"uid": null,
|
||||||
|
"version": 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<DashboardGrid
|
<DashboardGrid
|
||||||
dashboard={
|
dashboard={
|
||||||
DashboardModel {
|
DashboardModel {
|
||||||
@ -448,6 +540,98 @@ exports[`DashboardPage When dashboard has editview url state should render setti
|
|||||||
<div
|
<div
|
||||||
className="dashboard-container"
|
className="dashboard-container"
|
||||||
>
|
>
|
||||||
|
<SubMenu
|
||||||
|
dashboard={
|
||||||
|
DashboardModel {
|
||||||
|
"annotations": Object {
|
||||||
|
"list": Array [
|
||||||
|
Object {
|
||||||
|
"builtIn": 1,
|
||||||
|
"datasource": "-- Grafana --",
|
||||||
|
"enable": true,
|
||||||
|
"hide": true,
|
||||||
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
|
"name": "Annotations & Alerts",
|
||||||
|
"type": "dashboard",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"autoUpdate": undefined,
|
||||||
|
"description": undefined,
|
||||||
|
"editable": true,
|
||||||
|
"events": Emitter {
|
||||||
|
"emitter": EventEmitter {
|
||||||
|
"_events": Object {},
|
||||||
|
"_eventsCount": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gnetId": null,
|
||||||
|
"graphTooltip": 0,
|
||||||
|
"id": null,
|
||||||
|
"links": Array [],
|
||||||
|
"meta": Object {
|
||||||
|
"canEdit": true,
|
||||||
|
"canMakeEditable": false,
|
||||||
|
"canSave": true,
|
||||||
|
"canShare": true,
|
||||||
|
"canStar": true,
|
||||||
|
"fullscreen": false,
|
||||||
|
"isEditing": false,
|
||||||
|
"showSettings": true,
|
||||||
|
},
|
||||||
|
"originalTemplating": Array [],
|
||||||
|
"originalTime": Object {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now",
|
||||||
|
},
|
||||||
|
"panels": Array [
|
||||||
|
PanelModel {
|
||||||
|
"cachedPluginOptions": Object {},
|
||||||
|
"datasource": null,
|
||||||
|
"events": Emitter {
|
||||||
|
"emitter": EventEmitter {
|
||||||
|
"_events": Object {},
|
||||||
|
"_eventsCount": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"gridPos": Object {
|
||||||
|
"h": 1,
|
||||||
|
"w": 1,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
},
|
||||||
|
"id": 1,
|
||||||
|
"targets": Array [
|
||||||
|
Object {
|
||||||
|
"refId": "A",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"title": "My graph",
|
||||||
|
"transparent": false,
|
||||||
|
"type": "graph",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"refresh": undefined,
|
||||||
|
"revision": undefined,
|
||||||
|
"schemaVersion": 21,
|
||||||
|
"snapshot": undefined,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": Array [],
|
||||||
|
"templating": Object {
|
||||||
|
"list": Array [],
|
||||||
|
},
|
||||||
|
"time": Object {
|
||||||
|
"from": "now-6h",
|
||||||
|
"to": "now",
|
||||||
|
},
|
||||||
|
"timepicker": Object {},
|
||||||
|
"timezone": "",
|
||||||
|
"title": "My dashboard",
|
||||||
|
"uid": null,
|
||||||
|
"version": 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<DashboardGrid
|
<DashboardGrid
|
||||||
dashboard={
|
dashboard={
|
||||||
DashboardModel {
|
DashboardModel {
|
||||||
|
@ -1,23 +1,18 @@
|
|||||||
// Libaries
|
// Libaries
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import { DEFAULT_ANNOTATION_COLOR } from '@grafana/ui';
|
import { DEFAULT_ANNOTATION_COLOR } from '@grafana/ui';
|
||||||
import { GRID_COLUMN_COUNT, REPEAT_DIR_VERTICAL, GRID_CELL_HEIGHT, GRID_CELL_VMARGIN } from 'app/core/constants';
|
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT, REPEAT_DIR_VERTICAL } from 'app/core/constants';
|
||||||
|
|
||||||
// Utils & Services
|
// Utils & Services
|
||||||
import { Emitter } from 'app/core/utils/emitter';
|
import { Emitter } from 'app/core/utils/emitter';
|
||||||
import { contextSrv } from 'app/core/services/context_srv';
|
import { contextSrv } from 'app/core/services/context_srv';
|
||||||
import sortByKeys from 'app/core/utils/sort_by_keys';
|
import sortByKeys from 'app/core/utils/sort_by_keys';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { PanelModel, GridPos, panelAdded, panelRemoved } from './PanelModel';
|
import { GridPos, panelAdded, PanelModel, panelRemoved } from './PanelModel';
|
||||||
import { DashboardMigrator } from './DashboardMigrator';
|
import { DashboardMigrator } from './DashboardMigrator';
|
||||||
import { TimeRange, TimeZone, AppEvent } from '@grafana/data';
|
import { AppEvent, dateTime, DateTimeInput, isDateTime, PanelEvents, TimeRange, TimeZone, toUtc } from '@grafana/data';
|
||||||
import { UrlQueryValue } from '@grafana/runtime';
|
import { UrlQueryValue } from '@grafana/runtime';
|
||||||
import { PanelEvents } from '@grafana/data';
|
import { CoreEvents, DashboardMeta, KIOSK_MODE_TV } from 'app/types';
|
||||||
import { KIOSK_MODE_TV, DashboardMeta, CoreEvents } from 'app/types';
|
|
||||||
import { toUtc, DateTimeInput, dateTime, isDateTime } from '@grafana/data';
|
|
||||||
|
|
||||||
export interface CloneOptions {
|
export interface CloneOptions {
|
||||||
saveVariables?: boolean;
|
saveVariables?: boolean;
|
||||||
@ -660,6 +655,7 @@ export class DashboardModel {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
})();
|
})();
|
||||||
|
this.events.emit(CoreEvents.submenuVisibilityChanged, this.meta.submenuEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPanelInfoById(panelId: number) {
|
getPanelInfoById(panelId: number) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { DataFrame, TimeRange } from '@grafana/data';
|
import { DataFrame, eventFactory, TimeRange } from '@grafana/data';
|
||||||
import { IHttpResponse } from 'angular';
|
import { IHttpResponse } from 'angular';
|
||||||
import { DashboardModel } from 'app/features/dashboard/state';
|
import { DashboardModel } from 'app/features/dashboard/state';
|
||||||
import { eventFactory } from '@grafana/data';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Payloads
|
* Event Payloads
|
||||||
@ -121,6 +120,7 @@ export const repeatsProcessed = eventFactory('repeats-processed');
|
|||||||
export const rowExpanded = eventFactory('row-expanded');
|
export const rowExpanded = eventFactory('row-expanded');
|
||||||
export const rowCollapsed = eventFactory('row-collapsed');
|
export const rowCollapsed = eventFactory('row-collapsed');
|
||||||
export const templateVariableValueUpdated = eventFactory('template-variable-value-updated');
|
export const templateVariableValueUpdated = eventFactory('template-variable-value-updated');
|
||||||
|
export const submenuVisibilityChanged = eventFactory<boolean>('submenu-visibility-changed');
|
||||||
|
|
||||||
export const dataFramesReceived = eventFactory<DataFrame[]>('data-frames-received');
|
export const dataFramesReceived = eventFactory<DataFrame[]>('data-frames-received');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user