moved state

This commit is contained in:
Peter Holmberg
2018-10-30 13:09:59 +01:00
parent 7a10bf0141
commit 58e94fc0fa
11 changed files with 59 additions and 32 deletions

View File

@@ -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<void> {
return async dispatch => {
const permissions = await getBackendSrv().get(`/api/dashboards/id/${id}/permissions`);
@@ -47,13 +42,6 @@ export function getDashboardPermissions(id: number): ThunkResult<void> {
};
}
export function loadStarredDashboards(): ThunkResult<void> {
return async dispatch => {
const starredDashboards = await getBackendSrv().search({ starred: true });
dispatch(starredDashboardsLoaded(starredDashboards));
};
}
function toUpdateItem(item: DashboardAcl): DashboardAclUpdateDTO {
return {
userId: item.userId,

View File

@@ -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';

View File

@@ -99,7 +99,7 @@ export class OrgPreferences extends PureComponent<Props> {
function mapStateToProps(state) {
return {
preferences: state.organization.preferences,
starredDashboards: state.organization.starredDashboards,
starredDashboards: state.user.starredDashboards,
};
}

View File

@@ -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<R> = ThunkAction<R, StoreState, undefined, any>;
@@ -7,7 +7,6 @@ type ThunkResult<R> = ThunkAction<R, StoreState, undefined, any>;
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

View File

@@ -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 } };