2018-10-25 00:45:22 -05:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { NavModel } from '@grafana/data';
|
|
|
|
|
2019-01-16 09:16:19 -06:00
|
|
|
import Page from 'app/core/components/Page/Page';
|
2018-10-25 09:56:49 -05:00
|
|
|
import OrgProfile from './OrgProfile';
|
2018-11-15 06:37:29 -06:00
|
|
|
import SharedPreferences from 'app/core/components/SharedPreferences/SharedPreferences';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { loadOrganization, updateOrganization } from './state/actions';
|
2019-04-30 09:46:46 -05:00
|
|
|
import { Organization, StoreState } from 'app/types';
|
2019-01-17 02:01:17 -06:00
|
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
2020-01-13 01:03:22 -06:00
|
|
|
import { setOrganizationName } from './state/reducers';
|
2020-06-24 03:55:39 -05:00
|
|
|
import { VerticalGroup } from '@grafana/ui';
|
2018-10-25 00:45:22 -05:00
|
|
|
|
|
|
|
export interface Props {
|
|
|
|
navModel: NavModel;
|
2018-10-25 09:56:49 -05:00
|
|
|
organization: Organization;
|
|
|
|
loadOrganization: typeof loadOrganization;
|
2018-10-26 07:15:37 -05:00
|
|
|
setOrganizationName: typeof setOrganizationName;
|
2018-10-26 07:51:33 -05:00
|
|
|
updateOrganization: typeof updateOrganization;
|
2018-10-25 00:45:22 -05:00
|
|
|
}
|
|
|
|
|
2018-10-26 07:15:37 -05:00
|
|
|
export class OrgDetailsPage extends PureComponent<Props> {
|
2018-10-25 00:45:22 -05:00
|
|
|
async componentDidMount() {
|
2018-10-26 07:15:37 -05:00
|
|
|
await this.props.loadOrganization();
|
2018-10-25 00:45:22 -05:00
|
|
|
}
|
|
|
|
|
2020-06-24 03:55:39 -05:00
|
|
|
onUpdateOrganization = (orgName: string) => {
|
|
|
|
this.props.setOrganizationName(orgName);
|
2018-10-26 07:51:33 -05:00
|
|
|
this.props.updateOrganization();
|
|
|
|
};
|
2018-10-25 00:45:22 -05:00
|
|
|
|
2018-10-25 09:56:49 -05:00
|
|
|
render() {
|
2018-11-15 06:37:29 -06:00
|
|
|
const { navModel, organization } = this.props;
|
|
|
|
const isLoading = Object.keys(organization).length === 0;
|
2018-10-25 00:45:22 -05:00
|
|
|
|
|
|
|
return (
|
2019-01-17 02:01:17 -06:00
|
|
|
<Page navModel={navModel}>
|
2019-01-16 09:16:19 -06:00
|
|
|
<Page.Contents isLoading={isLoading}>
|
2019-02-11 08:13:20 -06:00
|
|
|
{!isLoading && (
|
2021-04-30 03:04:01 -05:00
|
|
|
<VerticalGroup spacing="lg">
|
2020-06-24 03:55:39 -05:00
|
|
|
<OrgProfile onSubmit={this.onUpdateOrganization} orgName={organization.name} />
|
2019-02-11 08:13:20 -06:00
|
|
|
<SharedPreferences resourceUri="org" />
|
2020-06-24 03:55:39 -05:00
|
|
|
</VerticalGroup>
|
2019-02-11 08:13:20 -06:00
|
|
|
)}
|
2019-01-16 09:16:19 -06:00
|
|
|
</Page.Contents>
|
|
|
|
</Page>
|
2018-10-25 00:45:22 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapStateToProps(state: StoreState) {
|
|
|
|
return {
|
|
|
|
navModel: getNavModel(state.navIndex, 'org-settings'),
|
2018-10-26 07:15:37 -05:00
|
|
|
organization: state.organization.organization,
|
2018-10-25 00:45:22 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = {
|
2018-10-25 09:56:49 -05:00
|
|
|
loadOrganization,
|
2018-10-26 07:15:37 -05:00
|
|
|
setOrganizationName,
|
2018-10-26 07:51:33 -05:00
|
|
|
updateOrganization,
|
2018-10-25 00:45:22 -05:00
|
|
|
};
|
|
|
|
|
2021-08-31 05:55:05 -05:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(OrgDetailsPage);
|