From 1f8b61f9a673f4553cf88f437589b138732676ca Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Thu, 25 Oct 2018 07:45:22 +0200 Subject: [PATCH 01/15] load preferences --- public/app/features/org/OrgDetailsPage.tsx | 131 +++++++++++++++++++++ public/app/features/org/state/actions.ts | 40 +++++++ public/app/features/org/state/reducers.ts | 23 ++++ public/app/routes/routes.ts | 7 +- public/app/store/configureStore.ts | 2 + public/app/types/index.ts | 5 + public/app/types/organisation.ts | 15 +++ 7 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 public/app/features/org/OrgDetailsPage.tsx create mode 100644 public/app/features/org/state/actions.ts create mode 100644 public/app/features/org/state/reducers.ts create mode 100644 public/app/types/organisation.ts diff --git a/public/app/features/org/OrgDetailsPage.tsx b/public/app/features/org/OrgDetailsPage.tsx new file mode 100644 index 00000000000..08d98e1216e --- /dev/null +++ b/public/app/features/org/OrgDetailsPage.tsx @@ -0,0 +1,131 @@ +import React, { PureComponent } from 'react'; +import { hot } from 'react-hot-loader'; +import { connect } from 'react-redux'; +import PageHeader from '../../core/components/PageHeader/PageHeader'; +import { loadOrganisation } from './state/actions'; +import { NavModel, Organisation, OrganisationPreferences, StoreState } from 'app/types'; +import { getNavModel } from '../../core/selectors/navModel'; + +export interface Props { + navModel: NavModel; + organisation: Organisation; + preferences: OrganisationPreferences; + loadOrganisation: typeof loadOrganisation; +} + +interface State { + orgName: string; + hasSet: boolean; +} + +export class OrgDetailsPage extends PureComponent { + state = { + orgName: '', + hasSet: false, + }; + + async componentDidMount() { + await this.props.loadOrganisation(); + } + + onOrgNameChange = event => { + this.setState({ + orgName: event.target.value, + }); + }; + + onSubmitForm = event => {}; + + render() { + const { navModel, preferences } = this.props; + + const themes: any = [ + { value: '', text: 'Default' }, + { value: 'dark', text: 'Dark' }, + { value: 'light', text: 'Light' }, + ]; + + return ( +
+ +
+

Organisation profile

+
+
+
+ Organization name + +
+
+ +
+ +
+
+
+

Preferences

+ +
+ UI Theme +
+ +
+
+ +
+ + Home Dashboard + {/**/} + {/*Not finding dashboard you want? Star it first, then it should appear in this select box.*/} + {/**/} + + {/**/} +
+ +
+ +
+ + ); +}; + +export default SimplePicker; diff --git a/public/app/core/components/Tooltip/Tooltip.tsx b/public/app/core/components/Tooltip/Tooltip.tsx index a265c8487d3..62be658f7cf 100644 --- a/public/app/core/components/Tooltip/Tooltip.tsx +++ b/public/app/core/components/Tooltip/Tooltip.tsx @@ -1,37 +1,28 @@ -import React from 'react'; +import React, { PureComponent } from 'react'; import withTooltip from './withTooltip'; import { Target } from 'react-popper'; -interface TooltipProps { +interface Props { tooltipSetState: (prevState: object) => void; } -class Tooltip extends React.Component { - constructor(props) { - super(props); - this.showTooltip = this.showTooltip.bind(this); - this.hideTooltip = this.hideTooltip.bind(this); - } - - showTooltip() { +class Tooltip extends PureComponent { + showTooltip = () => { const { tooltipSetState } = this.props; - tooltipSetState(prevState => { - return { - ...prevState, - show: true, - }; - }); - } - hideTooltip() { + tooltipSetState(prevState => ({ + ...prevState, + show: true, + })); + }; + + hideTooltip = () => { const { tooltipSetState } = this.props; - tooltipSetState(prevState => { - return { - ...prevState, - show: false, - }; - }); - } + tooltipSetState(prevState => ({ + ...prevState, + show: false, + })); + }; render() { return ( diff --git a/public/app/features/dashboard/state/reducers.test.ts b/public/app/features/dashboard/state/reducers.test.ts index c5b67f58ac9..ced8866aad8 100644 --- a/public/app/features/dashboard/state/reducers.test.ts +++ b/public/app/features/dashboard/state/reducers.test.ts @@ -1,6 +1,6 @@ import { Action, ActionTypes } from './actions'; import { OrgRole, PermissionLevel, DashboardState } from 'app/types'; -import { inititalState, dashboardReducer } from './reducers'; +import { initialState, dashboardReducer } from './reducers'; describe('dashboard reducer', () => { describe('loadDashboardPermissions', () => { @@ -14,7 +14,7 @@ describe('dashboard reducer', () => { { id: 3, dashboardId: 1, role: OrgRole.Editor, permission: PermissionLevel.Edit }, ], }; - state = dashboardReducer(inititalState, action); + state = dashboardReducer(initialState, action); }); it('should add permissions to state', async () => { diff --git a/public/app/features/dashboard/state/reducers.ts b/public/app/features/dashboard/state/reducers.ts index 5100529d973..8a79a6c9f77 100644 --- a/public/app/features/dashboard/state/reducers.ts +++ b/public/app/features/dashboard/state/reducers.ts @@ -2,11 +2,11 @@ import { DashboardState } from 'app/types'; import { Action, ActionTypes } from './actions'; import { processAclItems } from 'app/core/utils/acl'; -export const inititalState: DashboardState = { +export const initialState: DashboardState = { permissions: [], }; -export const dashboardReducer = (state = inititalState, action: Action): DashboardState => { +export const dashboardReducer = (state = initialState, action: Action): DashboardState => { switch (action.type) { case ActionTypes.LoadDashboardPermissions: return { diff --git a/public/app/features/org/OrgDetailsPage.tsx b/public/app/features/org/OrgDetailsPage.tsx index 08d98e1216e..dd8eb9358dd 100644 --- a/public/app/features/org/OrgDetailsPage.tsx +++ b/public/app/features/org/OrgDetailsPage.tsx @@ -2,30 +2,50 @@ import React, { PureComponent } from 'react'; import { hot } from 'react-hot-loader'; import { connect } from 'react-redux'; import PageHeader from '../../core/components/PageHeader/PageHeader'; -import { loadOrganisation } from './state/actions'; -import { NavModel, Organisation, OrganisationPreferences, StoreState } from 'app/types'; +import PageLoader from '../../core/components/PageLoader/PageLoader'; +import { loadOrganization, loadOrganizationPreferences } from './state/actions'; +import { DashboardAcl, NavModel, Organization, OrganisationPreferences, StoreState } from 'app/types'; import { getNavModel } from '../../core/selectors/navModel'; +import OrgProfile from './OrgProfile'; +import OrgPreferences from './OrgPreferences'; export interface Props { navModel: NavModel; - organisation: Organisation; + organization: Organization; preferences: OrganisationPreferences; - loadOrganisation: typeof loadOrganisation; + starredDashboards: DashboardAcl[]; + loadOrganization: typeof loadOrganization; + loadOrganizationPreferences: typeof loadOrganizationPreferences; } interface State { orgName: string; - hasSet: boolean; + theme: string; + isReady: boolean; + selectedDashboard: DashboardAcl; } export class OrgDetailsPage extends PureComponent { state = { orgName: '', - hasSet: false, + theme: '', + isReady: false, + selectedDashboard: null, }; async componentDidMount() { - await this.props.loadOrganisation(); + this.fetchOrganisation(); + } + + async fetchOrganisation() { + const organization = await this.props.loadOrganization(); + // const preferences = await this.props.loadOrganizationPreferences(); + + this.setState({ + orgName: organization.name, + // theme: preferences.theme, + isReady: true, + }); } onOrgNameChange = event => { @@ -34,82 +54,41 @@ export class OrgDetailsPage extends PureComponent { }); }; - onSubmitForm = event => {}; + onSubmitForm = () => {}; + + onSubmitPreferences = () => {}; + + onDashboardSelected = dashboard => { + this.setState({ + selectedDashboard: dashboard, + }); + }; render() { - const { navModel, preferences } = this.props; - - const themes: any = [ - { value: '', text: 'Default' }, - { value: 'dark', text: 'Dark' }, - { value: 'light', text: 'Light' }, - ]; + const { navModel, preferences, starredDashboards } = this.props; return (
-

Organisation profile

- -
-
- Organization name - -
+ {!this.state.isReady ? ( + + ) : ( +
+ this.onOrgNameChange(name)} + onSubmit={this.onSubmitForm} + orgName={this.state.orgName} + /> + this.onDashboardSelected(dashboard)} + onTimeZoneChange={() => {}} + onSubmit={this.onSubmitPreferences} + />
- -
- -
- -
-

Preferences

- -
- UI Theme -
- -
-
- -
- - Home Dashboard - {/**/} - {/*Not finding dashboard you want? Star it first, then it should appear in this select box.*/} - {/**/} - - {/**/} -
- -
- -
- { + onOrgNameChange(event.target.value); + }} + value={orgName} + /> +
+
+
+ +
+
+
+ ); +}; + +export default OrgProfile; diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index e495e04855d..321a0328fec 100644 --- a/public/app/features/org/state/actions.ts +++ b/public/app/features/org/state/actions.ts @@ -1,15 +1,16 @@ import { ThunkAction } from 'redux-thunk'; -import { Organisation, OrganisationPreferences, StoreState } from 'app/types'; +import { DashboardAcl, Organization, OrganisationPreferences, StoreState } from 'app/types'; import { getBackendSrv } from '../../../core/services/backend_srv'; export enum ActionTypes { LoadOrganisation = 'LOAD_ORGANISATION', LoadPreferences = 'LOAD_PREFERENCES', + LoadStarredDashboards = 'LOAD_STARRED_DASHBOARDS', } -interface LoadOrganisationAction { +interface LoadOrganizationAction { type: ActionTypes.LoadOrganisation; - payload: Organisation; + payload: Organization; } interface LoadPreferencesAction { @@ -17,7 +18,12 @@ interface LoadPreferencesAction { payload: OrganisationPreferences; } -const organisationLoaded = (organisation: Organisation) => ({ +interface LoadStarredDashboardsAction { + type: ActionTypes.LoadStarredDashboards; + payload: DashboardAcl[]; +} + +const organisationLoaded = (organisation: Organization) => ({ type: ActionTypes.LoadOrganisation, payload: organisation, }); @@ -27,14 +33,31 @@ const preferencesLoaded = (preferences: OrganisationPreferences) => ({ payload: preferences, }); -export type Action = LoadOrganisationAction | LoadPreferencesAction; +const starredDashboardsLoaded = (dashboards: DashboardAcl[]) => ({ + type: ActionTypes.LoadStarredDashboards, + payload: dashboards, +}); + +export type Action = LoadOrganizationAction | LoadPreferencesAction | LoadStarredDashboardsAction; type ThunkResult = ThunkAction; -export function loadOrganisation(): ThunkResult { +export function loadOrganization(): ThunkResult { return async dispatch => { const organisationResponse = await getBackendSrv().get('/api/org'); - const preferencesResponse = await getBackendSrv().get('/api/org/preferences'); dispatch(organisationLoaded(organisationResponse)); + + return organisationResponse; + }; +} + +export function loadOrganizationPreferences(): ThunkResult { + return async dispatch => { + const preferencesResponse = await getBackendSrv().get('/api/org/preferences'); dispatch(preferencesLoaded(preferencesResponse)); + + const starredDashboards = await getBackendSrv().search({ starred: true }); + dispatch(starredDashboardsLoaded(starredDashboards)); + + return preferencesResponse; }; } diff --git a/public/app/features/org/state/reducers.ts b/public/app/features/org/state/reducers.ts index d8d484b118d..aafff9eefa9 100644 --- a/public/app/features/org/state/reducers.ts +++ b/public/app/features/org/state/reducers.ts @@ -1,9 +1,10 @@ -import { Organisation, OrganisationPreferences, OrganisationState } from 'app/types'; +import { DashboardAcl, Organization, OrganisationPreferences, OrganisationState } from 'app/types'; import { Action, ActionTypes } from './actions'; const initialState: OrganisationState = { - organisation: {} as Organisation, + organisation: {} as Organization, preferences: {} as OrganisationPreferences, + starredDashboards: [] as DashboardAcl[], }; const organisationReducer = (state = initialState, action: Action): OrganisationState => { @@ -13,6 +14,9 @@ const organisationReducer = (state = initialState, action: Action): Organisation case ActionTypes.LoadPreferences: return { ...state, preferences: action.payload }; + + case ActionTypes.LoadStarredDashboards: + return { ...state, starredDashboards: action.payload }; } return state; diff --git a/public/app/types/index.ts b/public/app/types/index.ts index 0c733e43e6c..5ab400e938d 100644 --- a/public/app/types/index.ts +++ b/public/app/types/index.ts @@ -22,7 +22,7 @@ import { } from './series'; import { PanelProps } from './panel'; import { PluginDashboard, PluginMeta, Plugin, PluginsState } from './plugins'; -import { Organisation, OrganisationPreferences, OrganisationState } from './organisation'; +import { Organization, OrganisationPreferences, OrganisationState } from './organization'; export { Team, @@ -71,7 +71,7 @@ export { DataQueryResponse, DataQueryOptions, PluginDashboard, - Organisation, + Organization, OrganisationState, OrganisationPreferences, }; diff --git a/public/app/types/organisation.ts b/public/app/types/organization.ts similarity index 61% rename from public/app/types/organisation.ts rename to public/app/types/organization.ts index 2fd49f5db79..7b738f61584 100644 --- a/public/app/types/organisation.ts +++ b/public/app/types/organization.ts @@ -1,4 +1,6 @@ -export interface Organisation { +import { DashboardAcl } from './acl'; + +export interface Organization { name: string; id: number; } @@ -10,6 +12,7 @@ export interface OrganisationPreferences { } export interface OrganisationState { - organisation: Organisation; + organisation: Organization; preferences: OrganisationPreferences; + starredDashboards: DashboardAcl[]; } From affb04a3ce70f41f88737922913b0cd28a8e5eb0 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Fri, 26 Oct 2018 14:15:37 +0200 Subject: [PATCH 03/15] moved state to redux, renamed entities --- .../core/components/Picker/SimplePicker.tsx | 16 +++- public/app/features/org/OrgDetailsPage.tsx | 86 +++++++++---------- public/app/features/org/OrgPreferences.tsx | 32 +++---- public/app/features/org/state/actions.ts | 82 +++++++++++++++--- public/app/features/org/state/reducers.ts | 28 ++++-- public/app/store/configureStore.ts | 4 +- public/app/types/index.ts | 8 +- public/app/types/organization.ts | 8 +- 8 files changed, 172 insertions(+), 92 deletions(-) diff --git a/public/app/core/components/Picker/SimplePicker.tsx b/public/app/core/components/Picker/SimplePicker.tsx index c7d0fcd0549..9e00f06d8c3 100644 --- a/public/app/core/components/Picker/SimplePicker.tsx +++ b/public/app/core/components/Picker/SimplePicker.tsx @@ -6,18 +6,28 @@ import ResetStyles from './ResetStyles'; interface Props { options: any[]; className?: string; + placeholder?: string; + width: number; onSelected: (item: any) => {} | void; getOptionValue: (item: any) => string; getOptionLabel: (item: any) => string; } -const SimplePicker: SFC = ({ className, getOptionLabel, getOptionValue, onSelected, options }) => { +const SimplePicker: SFC = ({ + className, + getOptionLabel, + getOptionValue, + onSelected, + options, + placeholder, + width, +}) => { return ( ); }; diff --git a/public/app/features/dashboard/state/actions.ts b/public/app/features/dashboard/state/actions.ts index 749edef58fb..d5e3024e7b5 100644 --- a/public/app/features/dashboard/state/actions.ts +++ b/public/app/features/dashboard/state/actions.ts @@ -13,6 +13,7 @@ import { export enum ActionTypes { LoadDashboardPermissions = 'LOAD_DASHBOARD_PERMISSIONS', + LoadStarredDashboards = 'LOAD_STARRED_DASHBOARDS', } export interface LoadDashboardPermissionsAction { @@ -20,7 +21,12 @@ export interface LoadDashboardPermissionsAction { payload: DashboardAcl[]; } -export type Action = LoadDashboardPermissionsAction; +export interface LoadStarredDashboardsAction { + type: ActionTypes.LoadStarredDashboards; + payload: DashboardAcl[]; +} + +export type Action = LoadDashboardPermissionsAction | LoadStarredDashboardsAction; type ThunkResult = ThunkAction; @@ -29,6 +35,11 @@ export const loadDashboardPermissions = (items: DashboardAclDTO[]): LoadDashboar payload: items, }); +const starredDashboardsLoaded = (dashboards: DashboardAcl[]) => ({ + type: ActionTypes.LoadStarredDashboards, + payload: dashboards, +}); + export function getDashboardPermissions(id: number): ThunkResult { return async dispatch => { const permissions = await getBackendSrv().get(`/api/dashboards/id/${id}/permissions`); @@ -36,6 +47,13 @@ export function getDashboardPermissions(id: number): ThunkResult { }; } +export function loadStarredDashboards(): ThunkResult { + return async dispatch => { + const starredDashboards = await getBackendSrv().search({ starred: true }); + dispatch(starredDashboardsLoaded(starredDashboards)); + }; +} + function toUpdateItem(item: DashboardAcl): DashboardAclUpdateDTO { return { userId: item.userId, diff --git a/public/app/features/org/OrgDetailsPage.tsx b/public/app/features/org/OrgDetailsPage.tsx index 75229afa83d..a96bda831db 100644 --- a/public/app/features/org/OrgDetailsPage.tsx +++ b/public/app/features/org/OrgDetailsPage.tsx @@ -12,7 +12,10 @@ import { setOrganizationTheme, setOrganizationHomeDashboard, setOrganizationTimezone, + updateOrganization, + updateOrganizationPreferences, } from './state/actions'; +import { loadStarredDashboards } from '../dashboard/state/actions'; import { DashboardAcl, NavModel, Organization, OrganizationPreferences, StoreState } from 'app/types'; import { getNavModel } from '../../core/selectors/navModel'; @@ -23,29 +26,33 @@ export interface Props { starredDashboards: DashboardAcl[]; loadOrganization: typeof loadOrganization; loadOrganizationPreferences: typeof loadOrganizationPreferences; + loadStarredDashboards: typeof loadStarredDashboards; setOrganizationName: typeof setOrganizationName; setOrganizationHomeDashboard: typeof setOrganizationHomeDashboard; setOrganizationTheme: typeof setOrganizationTheme; setOrganizationTimezone: typeof setOrganizationTimezone; + updateOrganization: typeof updateOrganization; + updateOrganizationPreferences: typeof updateOrganizationPreferences; } export class OrgDetailsPage extends PureComponent { async componentDidMount() { - this.fetchOrganisation(); - } - - async fetchOrganisation() { + await this.props.loadStarredDashboards(); await this.props.loadOrganization(); await this.props.loadOrganizationPreferences(); } - onOrgNameChange = event => { - this.props.setOrganizationName(event.target.value); + onOrgNameChange = name => { + this.props.setOrganizationName(name); }; - onSubmitForm = () => {}; + onUpdateOrganization = () => { + this.props.updateOrganization(); + }; - onSubmitPreferences = () => {}; + onSubmitPreferences = () => { + this.props.updateOrganizationPreferences(); + }; onThemeChange = theme => { this.props.setOrganizationTheme(theme); @@ -72,7 +79,7 @@ export class OrgDetailsPage extends PureComponent {
this.onOrgNameChange(name)} - onSubmit={this.onSubmitForm} + onSubmit={this.onUpdateOrganization} orgName={organization.name} /> = ({ ]; return ( -
+ { + event.preventDefault(); + onSubmit(); + }} + >

Preferences

UI Theme theme.value === preferences.theme)} options={themes} getOptionValue={i => i.value} getOptionLabel={i => i.text} - onSelected={theme => onThemeChange(theme)} + onSelected={theme => onThemeChange(theme.value)} width={20} />
@@ -53,6 +60,7 @@ const OrgPreferences: SFC = ({ dashboard.id === preferences.homeDashboardId)} getOptionValue={i => i.id} getOptionLabel={i => i.title} onSelected={(dashboard: DashboardAcl) => onDashboardChange(dashboard.id)} @@ -64,9 +72,10 @@ const OrgPreferences: SFC = ({
timezone.value === preferences.timezone)} getOptionValue={i => i.value} getOptionLabel={i => i.text} - onSelected={timezone => onTimeZoneChange(timezone)} + onSelected={timezone => onTimeZoneChange(timezone.value)} options={timezones} width={20} /> diff --git a/public/app/features/org/OrgProfile.tsx b/public/app/features/org/OrgProfile.tsx index 47eae00daf8..32c14b94e17 100644 --- a/public/app/features/org/OrgProfile.tsx +++ b/public/app/features/org/OrgProfile.tsx @@ -10,7 +10,14 @@ const OrgProfile: SFC = ({ onSubmit, onOrgNameChange, orgName }) => { return (

Organization profile

- + { + event.preventDefault(); + onSubmit(); + }} + >
Organization name diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index 1d54cf87132..ccbd7a6d68b 100644 --- a/public/app/features/org/state/actions.ts +++ b/public/app/features/org/state/actions.ts @@ -59,11 +59,6 @@ const preferencesLoaded = (preferences: OrganizationPreferences) => ({ payload: preferences, }); -const starredDashboardsLoaded = (dashboards: DashboardAcl[]) => ({ - type: ActionTypes.LoadStarredDashboards, - payload: dashboards, -}); - export const setOrganizationName = (orgName: string) => ({ type: ActionTypes.SetOrganizationName, payload: orgName, @@ -95,7 +90,7 @@ export type Action = export function loadOrganization(): ThunkResult { return async dispatch => { - const organisationResponse = await loadOrg(); + const organisationResponse = await getBackendSrv().get('/api/org'); dispatch(organisationLoaded(organisationResponse)); return organisationResponse; @@ -104,18 +99,27 @@ export function loadOrganization(): ThunkResult { export function loadOrganizationPreferences(): ThunkResult { return async dispatch => { - const preferencesResponse = await loadPreferences(); + const preferencesResponse = await getBackendSrv().get('/api/org/preferences'); dispatch(preferencesLoaded(preferencesResponse)); - - const starredDashboards = await getBackendSrv().search({ starred: true }); - dispatch(starredDashboardsLoaded(starredDashboards)); }; } -export async function loadOrg() { - return await await getBackendSrv().get('/api/org'); +export function updateOrganization() { + return async (dispatch, getStore) => { + const organization = getStore().organization.organization; + + await getBackendSrv().put('/api/org', { name: organization.name }); + + dispatch(loadOrganization()); + }; } -export async function loadPreferences() { - return await getBackendSrv().get('/api/org/preferences'); +export function updateOrganizationPreferences() { + return async (dispatch, getStore) => { + const preferences = getStore().organization.preferences; + + await getBackendSrv().put('/api/org/preferences', preferences); + + dispatch(loadOrganizationPreferences()); + }; } From 026588cbf1c58d41040c524b6708f9533275696f Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 29 Oct 2018 13:46:12 +0100 Subject: [PATCH 05/15] test and some refactoring --- .../app/features/org/OrgDetailsPage.test.tsx | 45 +++++ public/app/features/org/OrgDetailsPage.tsx | 43 +--- .../app/features/org/OrgPreferences.test.tsx | 28 +++ public/app/features/org/OrgPreferences.tsx | 185 ++++++++++-------- public/app/features/org/OrgProfile.test.tsx | 21 ++ public/app/features/org/OrgProfile.tsx | 2 +- .../OrgDetailsPage.test.tsx.snap | 36 ++++ .../OrgPreferences.test.tsx.snap | 125 ++++++++++++ .../__snapshots__/OrgProfile.test.tsx.snap | 46 +++++ public/app/types/acl.ts | 1 + 10 files changed, 411 insertions(+), 121 deletions(-) create mode 100644 public/app/features/org/OrgDetailsPage.test.tsx create mode 100644 public/app/features/org/OrgPreferences.test.tsx create mode 100644 public/app/features/org/OrgProfile.test.tsx create mode 100644 public/app/features/org/__snapshots__/OrgDetailsPage.test.tsx.snap create mode 100644 public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap create mode 100644 public/app/features/org/__snapshots__/OrgProfile.test.tsx.snap diff --git a/public/app/features/org/OrgDetailsPage.test.tsx b/public/app/features/org/OrgDetailsPage.test.tsx new file mode 100644 index 00000000000..2eb45fa368a --- /dev/null +++ b/public/app/features/org/OrgDetailsPage.test.tsx @@ -0,0 +1,45 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import { OrgDetailsPage, Props } from './OrgDetailsPage'; +import { NavModel, Organization, OrganizationPreferences } from '../../types'; + +const setup = (propOverrides?: object) => { + const props: Props = { + preferences: {} as OrganizationPreferences, + organization: {} as Organization, + navModel: {} as NavModel, + loadOrganization: jest.fn(), + loadOrganizationPreferences: jest.fn(), + loadStarredDashboards: jest.fn(), + setOrganizationName: jest.fn(), + updateOrganization: jest.fn(), + }; + + Object.assign(props, propOverrides); + + return shallow(); +}; + +describe('Render', () => { + it('should render component', () => { + const wrapper = setup(); + + expect(wrapper).toMatchSnapshot(); + }); + + it('should render organization and preferences', () => { + const wrapper = setup({ + organization: { + name: 'Cool org', + id: 1, + }, + preferences: { + homeDashboardId: 1, + theme: 'Default', + timezone: 'Default', + }, + }); + + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/public/app/features/org/OrgDetailsPage.tsx b/public/app/features/org/OrgDetailsPage.tsx index a96bda831db..fa065ba4f66 100644 --- a/public/app/features/org/OrgDetailsPage.tsx +++ b/public/app/features/org/OrgDetailsPage.tsx @@ -9,30 +9,21 @@ import { loadOrganization, loadOrganizationPreferences, setOrganizationName, - setOrganizationTheme, - setOrganizationHomeDashboard, - setOrganizationTimezone, updateOrganization, - updateOrganizationPreferences, } from './state/actions'; import { loadStarredDashboards } from '../dashboard/state/actions'; -import { DashboardAcl, NavModel, Organization, OrganizationPreferences, StoreState } from 'app/types'; +import { NavModel, Organization, OrganizationPreferences, StoreState } from 'app/types'; import { getNavModel } from '../../core/selectors/navModel'; export interface Props { navModel: NavModel; organization: Organization; preferences: OrganizationPreferences; - starredDashboards: DashboardAcl[]; loadOrganization: typeof loadOrganization; loadOrganizationPreferences: typeof loadOrganizationPreferences; loadStarredDashboards: typeof loadStarredDashboards; setOrganizationName: typeof setOrganizationName; - setOrganizationHomeDashboard: typeof setOrganizationHomeDashboard; - setOrganizationTheme: typeof setOrganizationTheme; - setOrganizationTimezone: typeof setOrganizationTimezone; updateOrganization: typeof updateOrganization; - updateOrganizationPreferences: typeof updateOrganizationPreferences; } export class OrgDetailsPage extends PureComponent { @@ -50,24 +41,8 @@ export class OrgDetailsPage extends PureComponent { this.props.updateOrganization(); }; - onSubmitPreferences = () => { - this.props.updateOrganizationPreferences(); - }; - - onThemeChange = theme => { - this.props.setOrganizationTheme(theme); - }; - - onHomeDashboardChange = dashboardId => { - this.props.setOrganizationHomeDashboard(dashboardId); - }; - - onTimeZoneChange = timeZone => { - this.props.setOrganizationTimezone(timeZone); - }; - render() { - const { navModel, organization, preferences, starredDashboards } = this.props; + const { navModel, organization, preferences } = this.props; return (
@@ -82,14 +57,7 @@ export class OrgDetailsPage extends PureComponent { onSubmit={this.onUpdateOrganization} orgName={organization.name} /> - this.onHomeDashboardChange(dashboardId)} - onThemeChange={theme => this.onThemeChange(theme)} - onTimeZoneChange={timeZone => this.onTimeZoneChange(timeZone)} - onSubmit={this.onSubmitPreferences} - /> +
)}
@@ -103,7 +71,6 @@ function mapStateToProps(state: StoreState) { navModel: getNavModel(state.navIndex, 'org-settings'), organization: state.organization.organization, preferences: state.organization.preferences, - starredDashboards: state.organization.starredDashboards, }; } @@ -112,11 +79,7 @@ const mapDispatchToProps = { loadOrganizationPreferences, loadStarredDashboards, setOrganizationName, - setOrganizationTheme, - setOrganizationHomeDashboard, - setOrganizationTimezone, updateOrganization, - updateOrganizationPreferences, }; export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(OrgDetailsPage)); diff --git a/public/app/features/org/OrgPreferences.test.tsx b/public/app/features/org/OrgPreferences.test.tsx new file mode 100644 index 00000000000..0f5d73eef48 --- /dev/null +++ b/public/app/features/org/OrgPreferences.test.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import { OrgPreferences, Props } from './OrgPreferences'; + +const setup = () => { + const props: Props = { + preferences: { + homeDashboardId: 1, + timezone: 'UTC', + theme: 'Default', + }, + starredDashboards: [{ id: 1, name: 'Standard dashboard' }], + setOrganizationTimezone: jest.fn(), + setOrganizationTheme: jest.fn(), + setOrganizationHomeDashboard: jest.fn(), + updateOrganizationPreferences: jest.fn(), + }; + + return shallow(); +}; + +describe('Render', () => { + it('should render component', () => { + const wrapper = setup(); + + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/public/app/features/org/OrgPreferences.tsx b/public/app/features/org/OrgPreferences.tsx index e7f54e0498e..49331733921 100644 --- a/public/app/features/org/OrgPreferences.tsx +++ b/public/app/features/org/OrgPreferences.tsx @@ -1,92 +1,117 @@ -import React, { SFC } from 'react'; +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 { + setOrganizationHomeDashboard, + setOrganizationTheme, + setOrganizationTimezone, + updateOrganizationPreferences, +} from './state/actions'; -interface Props { +export interface Props { preferences: OrganizationPreferences; starredDashboards: DashboardAcl[]; - onDashboardChange: (dashboardId: number) => void; - onTimeZoneChange: (timeZone: string) => void; - onThemeChange: (theme: string) => void; - onSubmit: () => void; + setOrganizationHomeDashboard: typeof setOrganizationHomeDashboard; + setOrganizationTheme: typeof setOrganizationTheme; + setOrganizationTimezone: typeof setOrganizationTimezone; + updateOrganizationPreferences: typeof updateOrganizationPreferences; } -const OrgPreferences: SFC = ({ - preferences, - starredDashboards, - onDashboardChange, - onSubmit, - onTimeZoneChange, - onThemeChange, -}) => { - const themes = [{ value: '', text: 'Default' }, { value: 'dark', text: 'Dark' }, { value: 'light', text: 'Light' }]; +const themes = [{ value: '', text: 'Default' }, { value: 'dark', text: 'Dark' }, { value: 'light', text: 'Light' }]; - const timezones = [ - { value: '', text: 'Default' }, - { value: 'browser', text: 'Local browser time' }, - { value: 'utc', text: 'UTC' }, - ]; +const timezones = [ + { value: '', text: 'Default' }, + { value: 'browser', text: 'Local browser time' }, + { value: 'utc', text: 'UTC' }, +]; - return ( - { - event.preventDefault(); - onSubmit(); - }} - > -

Preferences

-
- UI Theme - theme.value === preferences.theme)} - options={themes} - getOptionValue={i => i.value} - getOptionLabel={i => i.text} - onSelected={theme => onThemeChange(theme.value)} - width={20} - /> -
-
- - Home Dashboard - - - - - dashboard.id === preferences.homeDashboardId)} - getOptionValue={i => i.id} - getOptionLabel={i => i.title} - onSelected={(dashboard: DashboardAcl) => onDashboardChange(dashboard.id)} - options={starredDashboards} - placeholder="Chose default dashboard" - width={20} - /> -
-
- - timezone.value === preferences.timezone)} - getOptionValue={i => i.value} - getOptionLabel={i => i.text} - onSelected={timezone => onTimeZoneChange(timezone.value)} - options={timezones} - width={20} - /> -
-
- -
- - ); +export class OrgPreferences extends PureComponent { + onSubmitForm = event => { + event.preventDefault(); + this.props.updateOrganizationPreferences(); + }; + + render() { + const { + preferences, + starredDashboards, + setOrganizationHomeDashboard, + setOrganizationTimezone, + setOrganizationTheme, + } = this.props; + + starredDashboards.unshift({ id: 0, title: 'Default' }); + + return ( +
+

Preferences

+
+ UI Theme + theme.value === preferences.theme)} + options={themes} + getOptionValue={i => i.value} + getOptionLabel={i => i.text} + onSelected={theme => setOrganizationTheme(theme.value)} + width={20} + /> +
+
+ + Home Dashboard + + + + + dashboard.id === preferences.homeDashboardId)} + getOptionValue={i => i.id} + getOptionLabel={i => i.title} + onSelected={(dashboard: DashboardAcl) => setOrganizationHomeDashboard(dashboard.id)} + options={starredDashboards} + placeholder="Chose default dashboard" + width={20} + /> +
+
+ + timezone.value === preferences.timezone)} + getOptionValue={i => i.value} + getOptionLabel={i => i.text} + onSelected={timezone => setOrganizationTimezone(timezone.value)} + options={timezones} + width={20} + /> +
+
+ +
+ + ); + } +} + +function mapStateToProps(state) { + return { + preferences: state.organization.preferences, + starredDashboards: state.organization.starredDashboards, + }; +} + +const mapDispatchToProps = { + setOrganizationHomeDashboard, + setOrganizationTimezone, + setOrganizationTheme, + updateOrganizationPreferences, }; -export default OrgPreferences; +export default connect(mapStateToProps, mapDispatchToProps)(OrgPreferences); diff --git a/public/app/features/org/OrgProfile.test.tsx b/public/app/features/org/OrgProfile.test.tsx new file mode 100644 index 00000000000..d101eded13e --- /dev/null +++ b/public/app/features/org/OrgProfile.test.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import OrgProfile, { Props } from './OrgProfile'; + +const setup = () => { + const props: Props = { + orgName: 'Main org', + onSubmit: jest.fn(), + onOrgNameChange: jest.fn(), + }; + + return shallow(); +}; + +describe('Render', () => { + it('should render component', () => { + const wrapper = setup(); + + expect(wrapper).toMatchSnapshot(); + }); +}); diff --git a/public/app/features/org/OrgProfile.tsx b/public/app/features/org/OrgProfile.tsx index 32c14b94e17..22dfa7bb1ce 100644 --- a/public/app/features/org/OrgProfile.tsx +++ b/public/app/features/org/OrgProfile.tsx @@ -1,6 +1,6 @@ import React, { SFC } from 'react'; -interface Props { +export interface Props { orgName: string; onSubmit: () => void; onOrgNameChange: (orgName: string) => void; diff --git a/public/app/features/org/__snapshots__/OrgDetailsPage.test.tsx.snap b/public/app/features/org/__snapshots__/OrgDetailsPage.test.tsx.snap new file mode 100644 index 00000000000..28806d2bf1d --- /dev/null +++ b/public/app/features/org/__snapshots__/OrgDetailsPage.test.tsx.snap @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Render should render component 1`] = ` +
+ +
+ +
+
+`; + +exports[`Render should render organization and preferences 1`] = ` +
+ +
+
+ + +
+
+
+`; diff --git a/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap b/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap new file mode 100644 index 00000000000..4a0d0986e4f --- /dev/null +++ b/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap @@ -0,0 +1,125 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Render should render component 1`] = ` +
+

+ Preferences +

+
+ + UI Theme + + +
+
+ + Home Dashboard + + + + + +
+
+ + +
+
+ +
+ +`; diff --git a/public/app/features/org/__snapshots__/OrgProfile.test.tsx.snap b/public/app/features/org/__snapshots__/OrgProfile.test.tsx.snap new file mode 100644 index 00000000000..b49b63e4532 --- /dev/null +++ b/public/app/features/org/__snapshots__/OrgProfile.test.tsx.snap @@ -0,0 +1,46 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Render should render component 1`] = ` +
+

+ Organization profile +

+
+
+
+ + Organization name + + +
+
+
+ +
+
+
+`; diff --git a/public/app/types/acl.ts b/public/app/types/acl.ts index 21f7bdac2d4..2c512f56c49 100644 --- a/public/app/types/acl.ts +++ b/public/app/types/acl.ts @@ -39,6 +39,7 @@ export interface DashboardAcl { name?: string; inherited?: boolean; sortRank?: number; + title?: string; } export interface DashboardPermissionInfo { From 7dc5173a9b6d0a2c54fd4fb8efad7633ae6dea17 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 29 Oct 2018 14:21:11 +0100 Subject: [PATCH 06/15] removed angular code --- public/app/features/org/all.ts | 2 - public/app/features/org/org_details_ctrl.ts | 38 -------- .../app/features/org/partials/orgDetails.html | 21 ----- public/app/features/org/prefs_control.ts | 92 ------------------- 4 files changed, 153 deletions(-) delete mode 100644 public/app/features/org/org_details_ctrl.ts delete mode 100644 public/app/features/org/partials/orgDetails.html delete mode 100644 public/app/features/org/prefs_control.ts diff --git a/public/app/features/org/all.ts b/public/app/features/org/all.ts index 9cbcec8de0d..1349da5effa 100644 --- a/public/app/features/org/all.ts +++ b/public/app/features/org/all.ts @@ -4,5 +4,3 @@ import './change_password_ctrl'; import './new_org_ctrl'; import './user_invite_ctrl'; import './create_team_ctrl'; -import './org_details_ctrl'; -import './prefs_control'; diff --git a/public/app/features/org/org_details_ctrl.ts b/public/app/features/org/org_details_ctrl.ts deleted file mode 100644 index 1d4a92c6e8b..00000000000 --- a/public/app/features/org/org_details_ctrl.ts +++ /dev/null @@ -1,38 +0,0 @@ -import angular from 'angular'; - -export class OrgDetailsCtrl { - /** @ngInject */ - constructor($scope, $http, backendSrv, contextSrv, navModelSrv) { - $scope.init = () => { - $scope.getOrgInfo(); - $scope.navModel = navModelSrv.getNav('cfg', 'org-settings', 0); - }; - - $scope.getOrgInfo = () => { - backendSrv.get('/api/org').then(org => { - $scope.org = org; - $scope.address = org.address; - contextSrv.user.orgName = org.name; - }); - }; - - $scope.update = () => { - if (!$scope.orgForm.$valid) { - return; - } - const data = { name: $scope.org.name }; - backendSrv.put('/api/org', data).then($scope.getOrgInfo); - }; - - $scope.updateAddress = () => { - if (!$scope.addressForm.$valid) { - return; - } - backendSrv.put('/api/org/address', $scope.address).then($scope.getOrgInfo); - }; - - $scope.init(); - } -} - -angular.module('grafana.controllers').controller('OrgDetailsCtrl', OrgDetailsCtrl); diff --git a/public/app/features/org/partials/orgDetails.html b/public/app/features/org/partials/orgDetails.html deleted file mode 100644 index f5a49e3d3ee..00000000000 --- a/public/app/features/org/partials/orgDetails.html +++ /dev/null @@ -1,21 +0,0 @@ - - -
-

Organization profile

- -
-
-
- Organization name - -
-
- -
- -
-
- -
- - diff --git a/public/app/features/org/prefs_control.ts b/public/app/features/org/prefs_control.ts deleted file mode 100644 index 74dde250eec..00000000000 --- a/public/app/features/org/prefs_control.ts +++ /dev/null @@ -1,92 +0,0 @@ -import config from 'app/core/config'; -import coreModule from 'app/core/core_module'; - -export class PrefsControlCtrl { - prefs: any; - oldTheme: any; - prefsForm: any; - mode: string; - - timezones: any = [ - { value: '', text: 'Default' }, - { value: 'browser', text: 'Local browser time' }, - { value: 'utc', text: 'UTC' }, - ]; - themes: any = [{ value: '', text: 'Default' }, { value: 'dark', text: 'Dark' }, { value: 'light', text: 'Light' }]; - - /** @ngInject */ - constructor(private backendSrv, private $location) {} - - $onInit() { - return this.backendSrv.get(`/api/${this.mode}/preferences`).then(prefs => { - this.prefs = prefs; - this.oldTheme = prefs.theme; - }); - } - - updatePrefs() { - if (!this.prefsForm.$valid) { - return; - } - - const cmd = { - theme: this.prefs.theme, - timezone: this.prefs.timezone, - homeDashboardId: this.prefs.homeDashboardId, - }; - - this.backendSrv.put(`/api/${this.mode}/preferences`, cmd).then(() => { - window.location.href = config.appSubUrl + this.$location.path(); - }); - } -} - -const template = ` -
-

Preferences

- -
- UI Theme -
- -
-
- -
- - Home Dashboard - - Not finding dashboard you want? Star it first, then it should appear in this select box. - - - - -
- -
- -
- -
-
- -
- -
-
-`; - -export function prefsControlDirective() { - return { - restrict: 'E', - controller: PrefsControlCtrl, - bindToController: true, - controllerAs: 'ctrl', - template: template, - scope: { - mode: '@', - }, - }; -} - -coreModule.directive('prefsControl', prefsControlDirective); From 70f6100d53f159fd5b0de9a65f9fe4242b8ae3bb Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 29 Oct 2018 15:08:36 +0100 Subject: [PATCH 07/15] 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[]; } From 12336e154840bf3812c1fd36fe560292da4c17c0 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Mon, 29 Oct 2018 15:59:16 +0100 Subject: [PATCH 08/15] using label component --- public/app/core/components/Label/Label.tsx | 4 ++-- public/app/features/org/OrgPreferences.tsx | 16 ++++++---------- .../__snapshots__/OrgPreferences.test.tsx.snap | 16 ++++------------ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/public/app/core/components/Label/Label.tsx b/public/app/core/components/Label/Label.tsx index 6d4fd20dbfe..9b8fb6c6e19 100644 --- a/public/app/core/components/Label/Label.tsx +++ b/public/app/core/components/Label/Label.tsx @@ -5,11 +5,12 @@ interface Props { tooltip?: string; for?: string; children: ReactNode; + width?: number; } export const Label: SFC = props => { return ( - + {props.children} {props.tooltip && ( @@ -19,4 +20,3 @@ export const Label: SFC = props => { ); }; - diff --git a/public/app/features/org/OrgPreferences.tsx b/public/app/features/org/OrgPreferences.tsx index ab0e163ca3f..6116584a34b 100644 --- a/public/app/features/org/OrgPreferences.tsx +++ b/public/app/features/org/OrgPreferences.tsx @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import { connect } from 'react-redux'; -import Tooltip from '../../core/components/Tooltip/Tooltip'; +import { Label } from '../../core/components/Label/Label'; import SimplePicker from '../../core/components/Picker/SimplePicker'; import { Dashboard, OrganizationPreferences } from 'app/types'; import { @@ -59,16 +59,12 @@ export class OrgPreferences extends PureComponent { />
- + + dashboard.id === preferences.homeDashboardId)} getOptionValue={i => i.id} diff --git a/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap b/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap index c1443e4eefd..06bf464a4a0 100644 --- a/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap +++ b/public/app/features/org/__snapshots__/OrgPreferences.test.tsx.snap @@ -44,20 +44,12 @@ exports[`Render should render component 1`] = `
- Home Dashboard - - - - + Date: Mon, 29 Oct 2018 16:01:14 +0100 Subject: [PATCH 09/15] rename type --- public/app/features/org/OrgPreferences.tsx | 6 +++--- public/app/features/org/state/actions.ts | 4 ++-- public/app/features/org/state/reducers.ts | 4 ++-- public/app/types/{dashboard.ts => dashboardSearchHit.ts} | 2 +- public/app/types/index.ts | 4 ++-- public/app/types/organization.ts | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) rename public/app/types/{dashboard.ts => dashboardSearchHit.ts} (85%) diff --git a/public/app/features/org/OrgPreferences.tsx b/public/app/features/org/OrgPreferences.tsx index 6116584a34b..4600aeb0a7b 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 { Label } from '../../core/components/Label/Label'; import SimplePicker from '../../core/components/Picker/SimplePicker'; -import { Dashboard, OrganizationPreferences } from 'app/types'; +import { DashboardSearchHit, OrganizationPreferences } from 'app/types'; import { setOrganizationHomeDashboard, setOrganizationTheme, @@ -12,7 +12,7 @@ import { export interface Props { preferences: OrganizationPreferences; - starredDashboards: Dashboard[]; + starredDashboards: DashboardSearchHit[]; setOrganizationHomeDashboard: typeof setOrganizationHomeDashboard; setOrganizationTheme: typeof setOrganizationTheme; setOrganizationTimezone: typeof setOrganizationTimezone; @@ -69,7 +69,7 @@ export class OrgPreferences extends PureComponent { defaultValue={starredDashboards.find(dashboard => dashboard.id === preferences.homeDashboardId)} getOptionValue={i => i.id} getOptionLabel={i => i.title} - onSelected={(dashboard: Dashboard) => setOrganizationHomeDashboard(dashboard.id)} + onSelected={(dashboard: DashboardSearchHit) => setOrganizationHomeDashboard(dashboard.id)} options={starredDashboards} placeholder="Chose default dashboard" width={20} diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index 72d6b371060..18ac0cac7ac 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 { Dashboard, Organization, OrganizationPreferences, StoreState } from 'app/types'; +import { DashboardSearchHit, 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: Dashboard[]; + payload: DashboardSearchHit[]; } interface SetOrganizationNameAction { diff --git a/public/app/features/org/state/reducers.ts b/public/app/features/org/state/reducers.ts index a9a5a597d25..02ffa0d3423 100644 --- a/public/app/features/org/state/reducers.ts +++ b/public/app/features/org/state/reducers.ts @@ -1,10 +1,10 @@ -import { Dashboard, Organization, OrganizationPreferences, OrganizationState } from 'app/types'; +import { DashboardSearchHit, Organization, OrganizationPreferences, OrganizationState } from 'app/types'; import { Action, ActionTypes } from './actions'; const initialState: OrganizationState = { organization: {} as Organization, preferences: {} as OrganizationPreferences, - starredDashboards: [] as Dashboard[], + starredDashboards: [] as DashboardSearchHit[], }; const organizationReducer = (state = initialState, action: Action): OrganizationState => { diff --git a/public/app/types/dashboard.ts b/public/app/types/dashboardSearchHit.ts similarity index 85% rename from public/app/types/dashboard.ts rename to public/app/types/dashboardSearchHit.ts index 338957e56e8..0fca8389e0b 100644 --- a/public/app/types/dashboard.ts +++ b/public/app/types/dashboardSearchHit.ts @@ -1,6 +1,6 @@ import { DashboardAcl } from './acl'; -export interface Dashboard { +export interface DashboardSearchHit { id: number; tags: string[]; title: string; diff --git a/public/app/types/index.ts b/public/app/types/index.ts index f6b9783df20..7bdf709f023 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 { Dashboard, DashboardState } from './dashboard'; +import { DashboardSearchHit, DashboardState } from './dashboardSearchHit'; import { DashboardAcl, OrgRole, PermissionLevel } from './acl'; import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys'; import { Invitee, OrgUser, User, UsersState } from './user'; @@ -84,7 +84,7 @@ export { AppNotificationsState, AppNotificationSeverity, AppNotificationTimeout, - Dashboard, + DashboardSearchHit, }; export interface StoreState { diff --git a/public/app/types/organization.ts b/public/app/types/organization.ts index a6c537e7f7c..aa7476b361b 100644 --- a/public/app/types/organization.ts +++ b/public/app/types/organization.ts @@ -1,4 +1,4 @@ -import { Dashboard } from './dashboard'; +import { DashboardSearchHit } from './dashboardSearchHit'; export interface Organization { name: string; @@ -14,5 +14,5 @@ export interface OrganizationPreferences { export interface OrganizationState { organization: Organization; preferences: OrganizationPreferences; - starredDashboards: Dashboard[]; + starredDashboards: DashboardSearchHit[]; } From 7a10bf0141649243f05d1c21172d8b79d6c0f693 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Tue, 30 Oct 2018 09:45:47 +0100 Subject: [PATCH 10/15] revert file name change --- public/app/types/dashboard.ts | 5 +++++ public/app/types/index.ts | 3 ++- public/app/types/organization.ts | 2 +- public/app/types/{dashboardSearchHit.ts => search.ts} | 6 ------ 4 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 public/app/types/dashboard.ts rename public/app/types/{dashboardSearchHit.ts => search.ts} (58%) diff --git a/public/app/types/dashboard.ts b/public/app/types/dashboard.ts new file mode 100644 index 00000000000..d33405c985e --- /dev/null +++ b/public/app/types/dashboard.ts @@ -0,0 +1,5 @@ +import { DashboardAcl } from './acl'; + +export interface DashboardState { + permissions: DashboardAcl[]; +} diff --git a/public/app/types/index.ts b/public/app/types/index.ts index 7bdf709f023..f99e8046289 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 { DashboardSearchHit, DashboardState } from './dashboardSearchHit'; +import { DashboardState } from './dashboard'; import { DashboardAcl, OrgRole, PermissionLevel } from './acl'; import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys'; import { Invitee, OrgUser, User, UsersState } from './user'; @@ -29,6 +29,7 @@ import { AppNotificationsState, AppNotificationTimeout, } from './appNotifications'; +import { DashboardSearchHit } from './search'; export { Team, diff --git a/public/app/types/organization.ts b/public/app/types/organization.ts index aa7476b361b..f525ecc6d83 100644 --- a/public/app/types/organization.ts +++ b/public/app/types/organization.ts @@ -1,4 +1,4 @@ -import { DashboardSearchHit } from './dashboardSearchHit'; +import { DashboardSearchHit } from './search'; export interface Organization { name: string; diff --git a/public/app/types/dashboardSearchHit.ts b/public/app/types/search.ts similarity index 58% rename from public/app/types/dashboardSearchHit.ts rename to public/app/types/search.ts index 0fca8389e0b..e5e17288de1 100644 --- a/public/app/types/dashboardSearchHit.ts +++ b/public/app/types/search.ts @@ -1,5 +1,3 @@ -import { DashboardAcl } from './acl'; - export interface DashboardSearchHit { id: number; tags: string[]; @@ -9,7 +7,3 @@ export interface DashboardSearchHit { uri: string; url: string; } - -export interface DashboardState { - permissions: DashboardAcl[]; -} From 58e94fc0fa0a4ca00af4ce2ec3a081573c602035 Mon Sep 17 00:00:00 2001 From: Peter Holmberg Date: Tue, 30 Oct 2018 13:09:59 +0100 Subject: [PATCH 11/15] moved state --- public/app/core/actions/user.ts | 28 +++++++++++++++++++ public/app/core/reducers/index.ts | 2 ++ public/app/core/reducers/user.ts | 15 ++++++++++ .../app/features/dashboard/state/actions.ts | 12 -------- public/app/features/org/OrgDetailsPage.tsx | 2 +- public/app/features/org/OrgPreferences.tsx | 2 +- public/app/features/org/state/actions.ts | 9 +----- public/app/features/org/state/reducers.ts | 6 +--- public/app/types/index.ts | 4 ++- public/app/types/organization.ts | 3 -- public/app/types/user.ts | 8 +++++- 11 files changed, 59 insertions(+), 32 deletions(-) create mode 100644 public/app/core/actions/user.ts create mode 100644 public/app/core/reducers/user.ts diff --git a/public/app/core/actions/user.ts b/public/app/core/actions/user.ts new file mode 100644 index 00000000000..dba0588c058 --- /dev/null +++ b/public/app/core/actions/user.ts @@ -0,0 +1,28 @@ +import { ThunkAction } from 'redux-thunk'; +import { getBackendSrv } from '../services/backend_srv'; +import { DashboardAcl, DashboardSearchHit, StoreState } from '../../types'; + +type ThunkResult = ThunkAction; + +export type Action = LoadStarredDashboardsAction; + +export enum ActionTypes { + LoadStarredDashboards = 'LOAD_STARRED_DASHBOARDS', +} + +interface LoadStarredDashboardsAction { + type: ActionTypes.LoadStarredDashboards; + payload: DashboardSearchHit[]; +} + +const starredDashboardsLoaded = (dashboards: DashboardAcl[]) => ({ + type: ActionTypes.LoadStarredDashboards, + payload: dashboards, +}); + +export function loadStarredDashboards(): ThunkResult { + return async dispatch => { + const starredDashboards = await getBackendSrv().search({ starred: true }); + dispatch(starredDashboardsLoaded(starredDashboards)); + }; +} diff --git a/public/app/core/reducers/index.ts b/public/app/core/reducers/index.ts index 1c8670ed0d6..6455849ab46 100644 --- a/public/app/core/reducers/index.ts +++ b/public/app/core/reducers/index.ts @@ -1,9 +1,11 @@ import { navIndexReducer as navIndex } from './navModel'; import { locationReducer as location } from './location'; import { appNotificationsReducer as appNotifications } from './appNotification'; +import { userReducer as user } from './user'; export default { navIndex, location, appNotifications, + user, }; diff --git a/public/app/core/reducers/user.ts b/public/app/core/reducers/user.ts new file mode 100644 index 00000000000..d49395060ce --- /dev/null +++ b/public/app/core/reducers/user.ts @@ -0,0 +1,15 @@ +import { DashboardSearchHit, UserState } from '../../types'; +import { Action, ActionTypes } from '../actions/user'; + +const initialState: UserState = { + starredDashboards: [] as DashboardSearchHit[], +}; + +export const userReducer = (state: UserState = initialState, action: Action): UserState => { + switch (action.type) { + case ActionTypes.LoadStarredDashboards: + return { ...state, starredDashboards: action.payload }; + } + + return state; +}; diff --git a/public/app/features/dashboard/state/actions.ts b/public/app/features/dashboard/state/actions.ts index d5e3024e7b5..bc35ff31ff0 100644 --- a/public/app/features/dashboard/state/actions.ts +++ b/public/app/features/dashboard/state/actions.ts @@ -35,11 +35,6 @@ export const loadDashboardPermissions = (items: DashboardAclDTO[]): LoadDashboar payload: items, }); -const starredDashboardsLoaded = (dashboards: DashboardAcl[]) => ({ - type: ActionTypes.LoadStarredDashboards, - payload: dashboards, -}); - export function getDashboardPermissions(id: number): ThunkResult { return async dispatch => { const permissions = await getBackendSrv().get(`/api/dashboards/id/${id}/permissions`); @@ -47,13 +42,6 @@ export function getDashboardPermissions(id: number): ThunkResult { }; } -export function loadStarredDashboards(): ThunkResult { - return async dispatch => { - const starredDashboards = await getBackendSrv().search({ starred: true }); - dispatch(starredDashboardsLoaded(starredDashboards)); - }; -} - function toUpdateItem(item: DashboardAcl): DashboardAclUpdateDTO { return { userId: item.userId, diff --git a/public/app/features/org/OrgDetailsPage.tsx b/public/app/features/org/OrgDetailsPage.tsx index fa065ba4f66..86a3fab3268 100644 --- a/public/app/features/org/OrgDetailsPage.tsx +++ b/public/app/features/org/OrgDetailsPage.tsx @@ -11,7 +11,7 @@ import { setOrganizationName, updateOrganization, } from './state/actions'; -import { loadStarredDashboards } from '../dashboard/state/actions'; +import { loadStarredDashboards } from '../../core/actions/user'; import { NavModel, Organization, OrganizationPreferences, StoreState } from 'app/types'; import { getNavModel } from '../../core/selectors/navModel'; diff --git a/public/app/features/org/OrgPreferences.tsx b/public/app/features/org/OrgPreferences.tsx index 4600aeb0a7b..a8133ba4a1c 100644 --- a/public/app/features/org/OrgPreferences.tsx +++ b/public/app/features/org/OrgPreferences.tsx @@ -99,7 +99,7 @@ export class OrgPreferences extends PureComponent { function mapStateToProps(state) { return { preferences: state.organization.preferences, - starredDashboards: state.organization.starredDashboards, + starredDashboards: state.user.starredDashboards, }; } diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index 18ac0cac7ac..719364d26de 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 { DashboardSearchHit, Organization, OrganizationPreferences, StoreState } from 'app/types'; +import { Organization, OrganizationPreferences, StoreState } from 'app/types'; import { getBackendSrv } from '../../../core/services/backend_srv'; type ThunkResult = ThunkAction; @@ -7,7 +7,6 @@ type ThunkResult = ThunkAction; export enum ActionTypes { LoadOrganization = 'LOAD_ORGANISATION', LoadPreferences = 'LOAD_PREFERENCES', - LoadStarredDashboards = 'LOAD_STARRED_DASHBOARDS', SetOrganizationName = 'SET_ORGANIZATION_NAME', SetOrganizationTheme = 'SET_ORGANIZATION_THEME', SetOrganizationHomeDashboard = 'SET_ORGANIZATION_HOME_DASHBOARD', @@ -24,11 +23,6 @@ interface LoadPreferencesAction { payload: OrganizationPreferences; } -interface LoadStarredDashboardsAction { - type: ActionTypes.LoadStarredDashboards; - payload: DashboardSearchHit[]; -} - interface SetOrganizationNameAction { type: ActionTypes.SetOrganizationName; payload: string; @@ -82,7 +76,6 @@ export const setOrganizationTimezone = (timezone: string) => ({ export type Action = | LoadOrganizationAction | LoadPreferencesAction - | LoadStarredDashboardsAction | SetOrganizationNameAction | SetOrganizationThemeAction | SetOrganizationHomeDashboardAction diff --git a/public/app/features/org/state/reducers.ts b/public/app/features/org/state/reducers.ts index 02ffa0d3423..b79f915a731 100644 --- a/public/app/features/org/state/reducers.ts +++ b/public/app/features/org/state/reducers.ts @@ -1,10 +1,9 @@ -import { DashboardSearchHit, Organization, OrganizationPreferences, OrganizationState } from 'app/types'; +import { Organization, OrganizationPreferences, OrganizationState } from 'app/types'; import { Action, ActionTypes } from './actions'; const initialState: OrganizationState = { organization: {} as Organization, preferences: {} as OrganizationPreferences, - starredDashboards: [] as DashboardSearchHit[], }; const organizationReducer = (state = initialState, action: Action): OrganizationState => { @@ -15,9 +14,6 @@ const organizationReducer = (state = initialState, action: Action): Organization case ActionTypes.LoadPreferences: return { ...state, preferences: action.payload }; - case ActionTypes.LoadStarredDashboards: - return { ...state, starredDashboards: action.payload }; - case ActionTypes.SetOrganizationName: return { ...state, organization: { ...state.organization, name: action.payload } }; diff --git a/public/app/types/index.ts b/public/app/types/index.ts index f99e8046289..c51622682d4 100644 --- a/public/app/types/index.ts +++ b/public/app/types/index.ts @@ -6,7 +6,7 @@ import { FolderDTO, FolderState, FolderInfo } from './folders'; import { DashboardState } from './dashboard'; import { DashboardAcl, OrgRole, PermissionLevel } from './acl'; import { ApiKey, ApiKeysState, NewApiKey } from './apiKeys'; -import { Invitee, OrgUser, User, UsersState } from './user'; +import { Invitee, OrgUser, User, UsersState, UserState } from './user'; import { DataSource, DataSourcesState } from './datasources'; import { TimeRange, @@ -86,6 +86,7 @@ export { AppNotificationSeverity, AppNotificationTimeout, DashboardSearchHit, + UserState, }; export interface StoreState { @@ -100,4 +101,5 @@ export interface StoreState { users: UsersState; organization: OrganizationState; appNotifications: AppNotificationsState; + user: UserState; } diff --git a/public/app/types/organization.ts b/public/app/types/organization.ts index f525ecc6d83..52cb130e082 100644 --- a/public/app/types/organization.ts +++ b/public/app/types/organization.ts @@ -1,5 +1,3 @@ -import { DashboardSearchHit } from './search'; - export interface Organization { name: string; id: number; @@ -14,5 +12,4 @@ export interface OrganizationPreferences { export interface OrganizationState { organization: Organization; preferences: OrganizationPreferences; - starredDashboards: DashboardSearchHit[]; } diff --git a/public/app/types/user.ts b/public/app/types/user.ts index c0b7b135ff8..37c80074dca 100644 --- a/public/app/types/user.ts +++ b/public/app/types/user.ts @@ -1,4 +1,6 @@ -export interface OrgUser { +import { DashboardSearchHit } from './search'; + +export interface OrgUser { avatarUrl: string; email: string; lastSeenAt: string; @@ -43,3 +45,7 @@ export interface UsersState { externalUserMngInfo: string; hasFetched: boolean; } + +export interface UserState { + starredDashboards: DashboardSearchHit[]; +} From 99d0beeaa90d68bde7bcc278c63a6194fe8edad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 31 Oct 2018 12:18:19 -0700 Subject: [PATCH 12/15] reload page after preferences update --- public/app/features/org/state/actions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/features/org/state/actions.ts b/public/app/features/org/state/actions.ts index 719364d26de..4df9083c323 100644 --- a/public/app/features/org/state/actions.ts +++ b/public/app/features/org/state/actions.ts @@ -113,6 +113,6 @@ export function updateOrganizationPreferences() { await getBackendSrv().put('/api/org/preferences', preferences); - dispatch(loadOrganizationPreferences()); + window.location.reload(); }; } From 17386c49d44414789f2fb902b8f6048c44fa7f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 31 Oct 2018 12:21:16 -0700 Subject: [PATCH 13/15] moved new teams page --- public/app/features/all.ts | 1 + public/app/features/org/all.ts | 1 - .../{org/create_team_ctrl.ts => teams/CreateTeamCtrl.ts} | 0 public/app/features/{org => teams}/partials/create_team.html | 0 public/app/routes/routes.ts | 2 +- 5 files changed, 2 insertions(+), 2 deletions(-) rename public/app/features/{org/create_team_ctrl.ts => teams/CreateTeamCtrl.ts} (100%) rename public/app/features/{org => teams}/partials/create_team.html (100%) diff --git a/public/app/features/all.ts b/public/app/features/all.ts index 7f6f84b7676..d62eb8cacdc 100644 --- a/public/app/features/all.ts +++ b/public/app/features/all.ts @@ -9,3 +9,4 @@ import './admin'; import './alerting/NotificationsEditCtrl'; import './alerting/NotificationsListCtrl'; import './manage-dashboards'; +import './teams/CreateTeamCtrl'; diff --git a/public/app/features/org/all.ts b/public/app/features/org/all.ts index 1349da5effa..f87905c6b1b 100644 --- a/public/app/features/org/all.ts +++ b/public/app/features/org/all.ts @@ -3,4 +3,3 @@ import './select_org_ctrl'; import './change_password_ctrl'; import './new_org_ctrl'; import './user_invite_ctrl'; -import './create_team_ctrl'; diff --git a/public/app/features/org/create_team_ctrl.ts b/public/app/features/teams/CreateTeamCtrl.ts similarity index 100% rename from public/app/features/org/create_team_ctrl.ts rename to public/app/features/teams/CreateTeamCtrl.ts diff --git a/public/app/features/org/partials/create_team.html b/public/app/features/teams/partials/create_team.html similarity index 100% rename from public/app/features/org/partials/create_team.html rename to public/app/features/teams/partials/create_team.html diff --git a/public/app/routes/routes.ts b/public/app/routes/routes.ts index 35ecfcecc0a..7e70ac34274 100644 --- a/public/app/routes/routes.ts +++ b/public/app/routes/routes.ts @@ -167,7 +167,7 @@ export function setupAngularRoutes($routeProvider, $locationProvider) { }, }) .when('/org/teams/new', { - templateUrl: 'public/app/features/org/partials/create_team.html', + templateUrl: 'public/app/features/teams/partials/create_team.html', controller: 'CreateTeamCtrl', controllerAs: 'ctrl', }) From dcf8327dc97f94dcc29b0868f37d615977cea6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 31 Oct 2018 12:25:46 -0700 Subject: [PATCH 14/15] moved profile pages to it's own feature folder --- public/app/features/all.ts | 2 ++ public/app/features/org/all.ts | 2 -- .../change_password_ctrl.ts => profile/ChangePasswordCtrl.ts} | 0 .../features/{org/profile_ctrl.ts => profile/ProfileCtrl.ts} | 0 .../features/{org => profile}/partials/change_password.html | 0 public/app/features/{org => profile}/partials/profile.html | 0 public/app/routes/routes.ts | 4 ++-- 7 files changed, 4 insertions(+), 4 deletions(-) rename public/app/features/{org/change_password_ctrl.ts => profile/ChangePasswordCtrl.ts} (100%) rename public/app/features/{org/profile_ctrl.ts => profile/ProfileCtrl.ts} (100%) rename public/app/features/{org => profile}/partials/change_password.html (100%) rename public/app/features/{org => profile}/partials/profile.html (100%) diff --git a/public/app/features/all.ts b/public/app/features/all.ts index d62eb8cacdc..ccdc7d7a820 100644 --- a/public/app/features/all.ts +++ b/public/app/features/all.ts @@ -10,3 +10,5 @@ import './alerting/NotificationsEditCtrl'; import './alerting/NotificationsListCtrl'; import './manage-dashboards'; import './teams/CreateTeamCtrl'; +import './profile/ProfileCtrl'; +import './profile/ChangePasswordCtrl'; diff --git a/public/app/features/org/all.ts b/public/app/features/org/all.ts index f87905c6b1b..18d75f71dca 100644 --- a/public/app/features/org/all.ts +++ b/public/app/features/org/all.ts @@ -1,5 +1,3 @@ -import './profile_ctrl'; import './select_org_ctrl'; -import './change_password_ctrl'; import './new_org_ctrl'; import './user_invite_ctrl'; diff --git a/public/app/features/org/change_password_ctrl.ts b/public/app/features/profile/ChangePasswordCtrl.ts similarity index 100% rename from public/app/features/org/change_password_ctrl.ts rename to public/app/features/profile/ChangePasswordCtrl.ts diff --git a/public/app/features/org/profile_ctrl.ts b/public/app/features/profile/ProfileCtrl.ts similarity index 100% rename from public/app/features/org/profile_ctrl.ts rename to public/app/features/profile/ProfileCtrl.ts diff --git a/public/app/features/org/partials/change_password.html b/public/app/features/profile/partials/change_password.html similarity index 100% rename from public/app/features/org/partials/change_password.html rename to public/app/features/profile/partials/change_password.html diff --git a/public/app/features/org/partials/profile.html b/public/app/features/profile/partials/profile.html similarity index 100% rename from public/app/features/org/partials/profile.html rename to public/app/features/profile/partials/profile.html diff --git a/public/app/routes/routes.ts b/public/app/routes/routes.ts index 7e70ac34274..6770011278f 100644 --- a/public/app/routes/routes.ts +++ b/public/app/routes/routes.ts @@ -179,12 +179,12 @@ export function setupAngularRoutes($routeProvider, $locationProvider) { }, }) .when('/profile', { - templateUrl: 'public/app/features/org/partials/profile.html', + templateUrl: 'public/app/features/profile/partials/profile.html', controller: 'ProfileCtrl', controllerAs: 'ctrl', }) .when('/profile/password', { - templateUrl: 'public/app/features/org/partials/change_password.html', + templateUrl: 'public/app/features/profile/partials/change_password.html', controller: 'ChangePasswordCtrl', }) .when('/profile/select-org', { From d64edc4a29a6edb3fe589a7591c422c338b53c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 31 Oct 2018 12:28:26 -0700 Subject: [PATCH 15/15] renamed org files to match new naming guide --- public/app/features/org/{new_org_ctrl.ts => NewOrgCtrl.ts} | 0 .../features/org/{select_org_ctrl.ts => SelectOrgCtrl.ts} | 0 .../features/org/{user_invite_ctrl.ts => UserInviteCtrl.ts} | 0 public/app/features/org/all.ts | 6 +++--- 4 files changed, 3 insertions(+), 3 deletions(-) rename public/app/features/org/{new_org_ctrl.ts => NewOrgCtrl.ts} (100%) rename public/app/features/org/{select_org_ctrl.ts => SelectOrgCtrl.ts} (100%) rename public/app/features/org/{user_invite_ctrl.ts => UserInviteCtrl.ts} (100%) diff --git a/public/app/features/org/new_org_ctrl.ts b/public/app/features/org/NewOrgCtrl.ts similarity index 100% rename from public/app/features/org/new_org_ctrl.ts rename to public/app/features/org/NewOrgCtrl.ts diff --git a/public/app/features/org/select_org_ctrl.ts b/public/app/features/org/SelectOrgCtrl.ts similarity index 100% rename from public/app/features/org/select_org_ctrl.ts rename to public/app/features/org/SelectOrgCtrl.ts diff --git a/public/app/features/org/user_invite_ctrl.ts b/public/app/features/org/UserInviteCtrl.ts similarity index 100% rename from public/app/features/org/user_invite_ctrl.ts rename to public/app/features/org/UserInviteCtrl.ts diff --git a/public/app/features/org/all.ts b/public/app/features/org/all.ts index 18d75f71dca..c905853cf49 100644 --- a/public/app/features/org/all.ts +++ b/public/app/features/org/all.ts @@ -1,3 +1,3 @@ -import './select_org_ctrl'; -import './new_org_ctrl'; -import './user_invite_ctrl'; +import './SelectOrgCtrl'; +import './NewOrgCtrl'; +import './UserInviteCtrl';