Commit 2ac202b2 by Torkel Ödegaard

moving things around

parent de456f8b
...@@ -12,7 +12,6 @@ function getNotFoundModel(): NavModel { ...@@ -12,7 +12,6 @@ function getNotFoundModel(): NavModel {
}; };
return { return {
breadcrumbs: [node],
node: node, node: node,
main: node, main: node,
}; };
...@@ -53,7 +52,6 @@ const navModelReducer = (state = initialState, action: Action): NavModel => { ...@@ -53,7 +52,6 @@ const navModelReducer = (state = initialState, action: Action): NavModel => {
return { return {
main: main, main: main,
node: node, node: node,
breadcrumbs: [],
}; };
} }
} }
......
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer';
import { ServerStats } from './ServerStats'; import { ServerStats } from './ServerStats';
import { RootStore } from 'app/stores/RootStore/RootStore'; import { initNav } from 'test/mocks/common';
import { backendSrv, createNavTree } from 'test/mocks/common'; import { ServerStat } from '../apis';
describe('ServerStats', () => { describe('ServerStats', () => {
it('Should render table with stats', done => { it('Should render table with stats', done => {
backendSrv.get.mockReturnValue( const stats: ServerStat[] = [{ name: 'test', value: 'asd' }];
Promise.resolve({
dashboards: 10,
})
);
const store = RootStore.create( let getServerStats = () => {
{}, return Promise.resolve(stats);
{ };
backendSrv: backendSrv,
navTree: createNavTree('cfg', 'admin', 'server-stats'),
}
);
const page = renderer.create(<ServerStats backendSrv={backendSrv} {...store} />); const page = renderer.create(<ServerStats initNav={initNav} getServerStats={getServerStats} />);
setTimeout(() => { setTimeout(() => {
expect(page.toJSON()).toMatchSnapshot(); expect(page.toJSON()).toMatchSnapshot();
......
import React from 'react'; import React, { 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 { initNav } from 'app/core/actions'; import { initNav } from 'app/core/actions';
...@@ -14,7 +14,7 @@ interface State { ...@@ -14,7 +14,7 @@ interface State {
stats: ServerStat[]; stats: ServerStat[];
} }
export class ServerStats extends React.Component<Props, State> { export class ServerStats extends PureComponent<Props, State> {
constructor(props) { constructor(props) {
super(props); super(props);
......
...@@ -7,7 +7,7 @@ import appEvents from 'app/core/app_events'; ...@@ -7,7 +7,7 @@ import appEvents from 'app/core/app_events';
import Highlighter from 'react-highlight-words'; import Highlighter from 'react-highlight-words';
import { initNav, updateLocation } from 'app/core/actions'; import { initNav, updateLocation } from 'app/core/actions';
import { ContainerProps } from 'app/types'; import { ContainerProps } from 'app/types';
import { getAlertRules, AlertRule } from '../apis'; import { getAlertRules, AlertRule } from './state/apis';
interface Props extends ContainerProps { interface Props extends ContainerProps {
updateLocation: typeof updateLocation; updateLocation: typeof updateLocation;
......
import _ from 'lodash'; import _ from 'lodash';
import { ThresholdMapper } from './threshold_mapper'; import { ThresholdMapper } from './state/ThresholdMapper';
import { QueryPart } from 'app/core/components/query_part/query_part'; import { QueryPart } from 'app/core/components/query_part/query_part';
import alertDef from './alert_def'; import alertDef from './state/alertDef';
import config from 'app/core/config'; import config from 'app/core/config';
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
......
import './notifications_list_ctrl';
import './notification_edit_ctrl';
import { describe, it, expect } from 'test/lib/common'; import { describe, it, expect } from 'test/lib/common';
import { ThresholdMapper } from '../threshold_mapper'; import { ThresholdMapper } from './threshold_mapper';
describe('ThresholdMapper', () => { describe('ThresholdMapper', () => {
describe('with greater than evaluator', () => { describe('with greater than evaluator', () => {
......
import { getBackendSrv } from 'app/core/services/backend_srv'; import { getBackendSrv } from 'app/core/services/backend_srv';
import alertDef from '../alert_def'; import alertDef from './alertDef';
import moment from 'moment'; import moment from 'moment';
export interface AlertRule { export interface AlertRule {
......
...@@ -9,5 +9,6 @@ import './snapshot/all'; ...@@ -9,5 +9,6 @@ import './snapshot/all';
import './panel/all'; import './panel/all';
import './org/all'; import './org/all';
import './admin/admin'; import './admin/admin';
import './alerting/all'; import './alerting/NotificationsEditCtrl';
import './alerting/NotificationsListCtrl';
import './styleguide/styleguide'; import './styleguide/styleguide';
import _ from 'lodash'; import _ from 'lodash';
import $ from 'jquery'; import $ from 'jquery';
import coreModule from 'app/core/core_module'; import coreModule from 'app/core/core_module';
import alertDef from '../alerting/alert_def'; import alertDef from '../alerting/state/alertDef';
/** @ngInject **/ /** @ngInject **/
export function annotationTooltipDirective($sanitize, dashboardSrv, contextSrv, $compile) { export function annotationTooltipDirective($sanitize, dashboardSrv, contextSrv, $compile) {
......
import _ from 'lodash'; import _ from 'lodash';
import moment from 'moment'; import moment from 'moment';
import alertDef from '../../../features/alerting/alert_def'; import alertDef from '../../../features/alerting/state/alertDef';
import { PanelCtrl } from 'app/plugins/sdk'; import { PanelCtrl } from 'app/plugins/sdk';
import * as dateMath from 'app/core/utils/datemath'; import * as dateMath from 'app/core/utils/datemath';
......
import { PanelCtrl } from 'app/features/panel/panel_ctrl'; import { PanelCtrl } from 'app/features/panel/panel_ctrl';
import { MetricsPanelCtrl } from 'app/features/panel/metrics_panel_ctrl'; import { MetricsPanelCtrl } from 'app/features/panel/metrics_panel_ctrl';
import { QueryCtrl } from 'app/features/panel/query_ctrl'; import { QueryCtrl } from 'app/features/panel/query_ctrl';
import { alertTab } from 'app/features/alerting/alert_tab_ctrl'; import { alertTab } from 'app/features/alerting/AlertTabCtrl';
import { loadPluginCss } from 'app/features/plugins/plugin_loader'; import { loadPluginCss } from 'app/features/plugins/plugin_loader';
export { PanelCtrl, MetricsPanelCtrl, QueryCtrl, alertTab, loadPluginCss }; export { PanelCtrl, MetricsPanelCtrl, QueryCtrl, alertTab, loadPluginCss };
...@@ -2,7 +2,7 @@ import './dashboard_loaders'; ...@@ -2,7 +2,7 @@ import './dashboard_loaders';
import './ReactContainer'; import './ReactContainer';
import ServerStats from 'app/features/admin/containers/ServerStats'; import ServerStats from 'app/features/admin/containers/ServerStats';
import AlertRuleList from 'app/features/alerting/containers/AlertRuleList'; import AlertRuleList from 'app/features/alerting/AlertRuleList';
import FolderSettings from 'app/containers/ManageDashboards/FolderSettings'; import FolderSettings from 'app/containers/ManageDashboards/FolderSettings';
import FolderPermissions from 'app/containers/ManageDashboards/FolderPermissions'; import FolderPermissions from 'app/containers/ManageDashboards/FolderPermissions';
import TeamPages from 'app/containers/Teams/TeamPages'; import TeamPages from 'app/containers/Teams/TeamPages';
......
import moment from 'moment'; import moment from 'moment';
import alertDef from 'app/features/alerting/alert_def'; import alertDef from 'app/features/alerting/state/alertDef';
export function setStateFields(rule, state) { export function setStateFields(rule, state) {
const stateModel = alertDef.getStateDisplayModel(state); const stateModel = alertDef.getStateDisplayModel(state);
......
import { NavModel } from './navModel'; import { NavModel } from './navModel';
import { initNav } from 'app/core/actions';
export interface ContainerProps { export interface ContainerProps {
navModel: NavModel; navModel: NavModel;
initNav: (...args: string[]) => void; initNav: typeof initNav;
} }
...@@ -9,11 +9,11 @@ export interface NavModelItem { ...@@ -9,11 +9,11 @@ export interface NavModelItem {
hideFromTabs?: boolean; hideFromTabs?: boolean;
divider?: boolean; divider?: boolean;
children?: NavModelItem[]; children?: NavModelItem[];
breadcrumbs?: NavModelItem[];
target?: string; target?: string;
} }
export interface NavModel { export interface NavModel {
breadcrumbs: NavModelItem[];
main: NavModelItem; main: NavModelItem;
node: NavModelItem; node: NavModelItem;
} }
import { NavModel, NavModelItem } from 'app/types';
export const backendSrv = { export const backendSrv = {
get: jest.fn(), get: jest.fn(),
getDashboard: jest.fn(), getDashboard: jest.fn(),
...@@ -17,3 +19,30 @@ export function createNavTree(...args) { ...@@ -17,3 +19,30 @@ export function createNavTree(...args) {
return root; return root;
} }
export function getNavModel(title: string, tabs: string[]): NavModel {
const node: NavModelItem = {
id: title,
text: title,
icon: 'fa fa-fw fa-warning',
subTitle: 'subTitle',
url: title,
children: [],
breadcrumbs: [],
};
for (let tab of tabs) {
node.children.push({
id: tab,
icon: 'icon',
subTitle: 'subTitle',
url: title,
text: title,
});
}
return {
node: node,
main: node,
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment