|
|
@@ -3,88 +3,84 @@ import { hot } from 'react-hot-loader';
|
|
|
import { connect } from 'react-redux';
|
|
|
import PageHeader from '../../core/components/PageHeader/PageHeader';
|
|
|
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';
|
|
|
+import {
|
|
|
+ loadOrganization,
|
|
|
+ loadOrganizationPreferences,
|
|
|
+ setOrganizationName,
|
|
|
+ setOrganizationTheme,
|
|
|
+ setOrganizationHomeDashboard,
|
|
|
+ setOrganizationTimezone,
|
|
|
+} from './state/actions';
|
|
|
+import { DashboardAcl, NavModel, Organization, OrganizationPreferences, StoreState } from 'app/types';
|
|
|
+import { getNavModel } from '../../core/selectors/navModel';
|
|
|
|
|
|
export interface Props {
|
|
|
navModel: NavModel;
|
|
|
organization: Organization;
|
|
|
- preferences: OrganisationPreferences;
|
|
|
+ preferences: OrganizationPreferences;
|
|
|
starredDashboards: DashboardAcl[];
|
|
|
loadOrganization: typeof loadOrganization;
|
|
|
loadOrganizationPreferences: typeof loadOrganizationPreferences;
|
|
|
+ setOrganizationName: typeof setOrganizationName;
|
|
|
+ setOrganizationHomeDashboard: typeof setOrganizationHomeDashboard;
|
|
|
+ setOrganizationTheme: typeof setOrganizationTheme;
|
|
|
+ setOrganizationTimezone: typeof setOrganizationTimezone;
|
|
|
}
|
|
|
|
|
|
-interface State {
|
|
|
- orgName: string;
|
|
|
- theme: string;
|
|
|
- isReady: boolean;
|
|
|
- selectedDashboard: DashboardAcl;
|
|
|
-}
|
|
|
-
|
|
|
-export class OrgDetailsPage extends PureComponent<Props, State> {
|
|
|
- state = {
|
|
|
- orgName: '',
|
|
|
- theme: '',
|
|
|
- isReady: false,
|
|
|
- selectedDashboard: null,
|
|
|
- };
|
|
|
-
|
|
|
+export class OrgDetailsPage extends PureComponent<Props> {
|
|
|
async componentDidMount() {
|
|
|
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,
|
|
|
- });
|
|
|
+ await this.props.loadOrganization();
|
|
|
+ await this.props.loadOrganizationPreferences();
|
|
|
}
|
|
|
|
|
|
onOrgNameChange = event => {
|
|
|
- this.setState({
|
|
|
- orgName: event.target.value,
|
|
|
- });
|
|
|
+ this.props.setOrganizationName(event.target.value);
|
|
|
};
|
|
|
|
|
|
onSubmitForm = () => {};
|
|
|
|
|
|
onSubmitPreferences = () => {};
|
|
|
|
|
|
- onDashboardSelected = dashboard => {
|
|
|
- this.setState({
|
|
|
- selectedDashboard: dashboard,
|
|
|
- });
|
|
|
+ onThemeChange = theme => {
|
|
|
+ this.props.setOrganizationTheme(theme);
|
|
|
+ };
|
|
|
+
|
|
|
+ onHomeDashboardChange = dashboardId => {
|
|
|
+ this.props.setOrganizationHomeDashboard(dashboardId);
|
|
|
+ };
|
|
|
+
|
|
|
+ onTimeZoneChange = timeZone => {
|
|
|
+ this.props.setOrganizationTimezone(timeZone);
|
|
|
};
|
|
|
|
|
|
render() {
|
|
|
- const { navModel, preferences, starredDashboards } = this.props;
|
|
|
+ const { navModel, organization, preferences, starredDashboards } = this.props;
|
|
|
|
|
|
return (
|
|
|
<div>
|
|
|
<PageHeader model={navModel} />
|
|
|
<div className="page-container page-body">
|
|
|
- {!this.state.isReady ? (
|
|
|
- <PageLoader pageName="Organisation" />
|
|
|
+ {Object.keys(organization).length === 0 || Object.keys(preferences).length === 0 ? (
|
|
|
+ <PageLoader pageName="Organization" />
|
|
|
) : (
|
|
|
<div>
|
|
|
<OrgProfile
|
|
|
onOrgNameChange={name => this.onOrgNameChange(name)}
|
|
|
onSubmit={this.onSubmitForm}
|
|
|
- orgName={this.state.orgName}
|
|
|
+ orgName={organization.name}
|
|
|
/>
|
|
|
<OrgPreferences
|
|
|
preferences={preferences}
|
|
|
starredDashboards={starredDashboards}
|
|
|
- onDashboardSelected={dashboard => this.onDashboardSelected(dashboard)}
|
|
|
- onTimeZoneChange={() => {}}
|
|
|
+ onDashboardChange={dashboardId => this.onHomeDashboardChange(dashboardId)}
|
|
|
+ onThemeChange={theme => this.onThemeChange(theme)}
|
|
|
+ onTimeZoneChange={timeZone => this.onTimeZoneChange(timeZone)}
|
|
|
onSubmit={this.onSubmitPreferences}
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -98,15 +94,19 @@ export class OrgDetailsPage extends PureComponent<Props, State> {
|
|
|
function mapStateToProps(state: StoreState) {
|
|
|
return {
|
|
|
navModel: getNavModel(state.navIndex, 'org-settings'),
|
|
|
- organisation: state.organisation.organisation,
|
|
|
- preferences: state.organisation.preferences,
|
|
|
- starredDashboards: state.organisation.starredDashboards,
|
|
|
+ organization: state.organization.organization,
|
|
|
+ preferences: state.organization.preferences,
|
|
|
+ starredDashboards: state.organization.starredDashboards,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
const mapDispatchToProps = {
|
|
|
loadOrganization,
|
|
|
loadOrganizationPreferences,
|
|
|
+ setOrganizationName,
|
|
|
+ setOrganizationTheme,
|
|
|
+ setOrganizationHomeDashboard,
|
|
|
+ setOrganizationTimezone,
|
|
|
};
|
|
|
|
|
|
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(OrgDetailsPage));
|