From 70f6100d53f159fd5b0de9a65f9fe4242b8ae3bb Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 29 Oct 2018 15:08:36 +0100 Subject: [PATCH] fixed type --- .../app/features/org/OrgPreferences.test.tsx | 2 +- public/app/features/org/OrgPreferences.tsx | 8 +++---- .../OrgPreferences.test.tsx.snap | 23 +++++++++++++++++-- public/app/features/org/state/actions.ts | 4 ++-- public/app/features/org/state/reducers.ts | 4 ++-- public/app/types/acl.ts | 1 - public/app/types/dashboard.ts | 10 ++++++++ public/app/types/index.ts | 3 ++- public/app/types/organization.ts | 4 ++-- 9 files changed, 44 insertions(+), 15 deletions(-) diff --git a/public/app/features/org/OrgPreferences.test.tsx b/public/app/features/org/OrgPreferences.test.tsx index 0f5d73eef48..e79e43d04f2 100644 --- a/public/app/features/org/OrgPreferences.test.tsx +++ b/public/app/features/org/OrgPreferences.test.tsx @@ -9,7 +9,7 @@ const setup = () => { timezone: 'UTC', theme: 'Default', }, - starredDashboards: [{ id: 1, name: 'Standard dashboard' }], + starredDashboards: [{ id: 1, title: 'Standard dashboard', url: '', uri: '', uid: '', type: '', tags: [] }], setOrganizationTimezone: jest.fn(), setOrganizationTheme: jest.fn(), setOrganizationHomeDashboard: jest.fn(), diff --git a/public/app/features/org/OrgPreferences.tsx b/public/app/features/org/OrgPreferences.tsx index 49331733921..ab0e163ca3f 100644 --- a/public/app/features/org/OrgPreferences.tsx +++ b/public/app/features/org/OrgPreferences.tsx @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; import Tooltip from '../../core/components/Tooltip/Tooltip'; import SimplePicker from '../../core/components/Picker/SimplePicker'; -import { DashboardAcl, OrganizationPreferences } from 'app/types'; +import { Dashboard, OrganizationPreferences } from 'app/types'; import { setOrganizationHomeDashboard, setOrganizationTheme, @@ -12,7 +12,7 @@ import { export interface Props { preferences: OrganizationPreferences; - starredDashboards: DashboardAcl[]; + starredDashboards: Dashboard[]; setOrganizationHomeDashboard: typeof setOrganizationHomeDashboard; setOrganizationTheme: typeof setOrganizationTheme; setOrganizationTimezone: typeof setOrganizationTimezone; @@ -42,7 +42,7 @@ export class OrgPreferences extends PureComponent { setOrganizationTheme, } = this.props; - starredDashboards.unshift({ id: 0, title: 'Default' }); + starredDashboards.unshift({ id: 0, title: 'Default', tags: [], type: '', uid: '', uri: '', url: '' }); return (
@@ -73,7 +73,7 @@ export class OrgPreferences extends PureComponent { defaultValue={starredDashboards.find(dashboard => dashboard.id === preferences.homeDashboardId)} getOptionValue={i => i.id} getOptionLabel={i => i.title} - onSelected={(dashboard: DashboardAcl) => setOrganizationHomeDashboard(dashboard.id)} + onSelected={(dashboard: Dashboard) => setOrganizationHomeDashboard(dashboard.id)} options={starredDashboards} placeholder="Chose default dashboard" width={20} diff --git a/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap b/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap index 4a0d0986e4f..c1443e4eefd 100644 --- a/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap +++ b/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap @@ -62,7 +62,12 @@ exports[`Render should render component 1`] = ` defaultValue={ Object { "id": 1, - "name": "Standard dashboard", + "tags": Array [], + "title": "Standard dashboard", + "type": "", + "uid": "", + "uri": "", + "url": "", } } getOptionLabel={[Function]} @@ -70,9 +75,23 @@ exports[`Render should render component 1`] = ` onSelected={[Function]} options={ Array [ + Object { + "id": 0, + "tags": Array [], + "title": "Default", + "type": "", + "uid": "", + "uri": "", + "url": "", + }, Object { "id": 1, - "name": "Standard dashboard", + "tags": Array [], + "title": "Standard dashboard", + "type": "", + "uid": "", + "uri": "", + "url": "", }, ] } diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index ccbd7a6d68b..72d6b371060 100644 --- a/public/app/features/org/state/actions.ts +++ b/public/app/features/org/state/actions.ts @@ -1,5 +1,5 @@ import { ThunkAction } from 'redux-thunk'; -import { DashboardAcl, Organization, OrganizationPreferences, StoreState } from 'app/types'; +import { Dashboard, Organization, OrganizationPreferences, StoreState } from 'app/types'; import { getBackendSrv } from '../../../core/services/backend_srv'; type ThunkResult = ThunkAction; @@ -26,7 +26,7 @@ interface LoadPreferencesAction { interface LoadStarredDashboardsAction { type: ActionTypes.LoadStarredDashboards; - payload: DashboardAcl[]; + payload: Dashboard[]; } interface SetOrganizationNameAction { diff --git a/public/app/features/org/state/reducers.ts b/public/app/features/org/state/reducers.ts index 959f5d99356..a9a5a597d25 100644 --- a/public/app/features/org/state/reducers.ts +++ b/public/app/features/org/state/reducers.ts @@ -1,10 +1,10 @@ -import { DashboardAcl, Organization, OrganizationPreferences, OrganizationState } from 'app/types'; +import { Dashboard, Organization, OrganizationPreferences, OrganizationState } from 'app/types'; import { Action, ActionTypes } from './actions'; const initialState: OrganizationState = { organization: {} as Organization, preferences: {} as OrganizationPreferences, - starredDashboards: [] as DashboardAcl[], + starredDashboards: [] as Dashboard[], }; const organizationReducer = (state = initialState, action: Action): OrganizationState => { diff --git a/public/app/types/acl.ts b/public/app/types/acl.ts index 2c512f56c49..21f7bdac2d4 100644 --- a/public/app/types/acl.ts +++ b/public/app/types/acl.ts @@ -39,7 +39,6 @@ export interface DashboardAcl { name?: string; inherited?: boolean; sortRank?: number; - title?: string; } export interface DashboardPermissionInfo { diff --git a/public/app/types/dashboard.ts b/public/app/types/dashboard.ts index d33405c985e..338957e56e8 100644 --- a/public/app/types/dashboard.ts +++ b/public/app/types/dashboard.ts @@ -1,5 +1,15 @@ import { DashboardAcl } from './acl'; +export interface Dashboard { + id: number; + tags: string[]; + title: string; + type: string; + uid: string; + uri: string; + url: string; +} + export interface DashboardState { permissions: DashboardAcl[]; } diff --git a/public/app/types/index.ts b/public/app/types/index.ts index d5264f908d5..f6b9783df20 100644 --- a/public/app/types/index.ts +++ b/public/app/types/index.ts @@ -3,7 +3,7 @@ import { AlertRuleDTO, AlertRule, AlertRulesState } from './alerting'; import { LocationState, LocationUpdate, UrlQueryMap, UrlQueryValue } from './location'; import { NavModel, NavModelItem, NavIndex } from './navModel'; import { FolderDTO, FolderState, FolderInfo } from './folders'; -import { DashboardState } from './dashboard'; +import { Dashboard, DashboardState } from './dashboard'; import { DashboardAcl, OrgRole, PermissionLevel } from './acl'; import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys'; import { Invitee, OrgUser, User, UsersState } from './user'; @@ -84,6 +84,7 @@ export { AppNotificationsState, AppNotificationSeverity, AppNotificationTimeout, + Dashboard, }; export interface StoreState { diff --git a/public/app/types/organization.ts b/public/app/types/organization.ts index 0d50c1d5f87..a6c537e7f7c 100644 --- a/public/app/types/organization.ts +++ b/public/app/types/organization.ts @@ -1,4 +1,4 @@ -import { DashboardAcl } from './acl'; +import { Dashboard } from './dashboard'; export interface Organization { name: string; @@ -14,5 +14,5 @@ export interface OrganizationPreferences { export interface OrganizationState { organization: Organization; preferences: OrganizationPreferences; - starredDashboards: DashboardAcl[]; + starredDashboards: Dashboard[]; }