mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Refactor: Adds Redux Toolkit package * Refactor: Uses configureStore from Redux Toolkit * Refactor: Migrates applicationReducer * Refactor: Migrates appNotificationsReducer * Refactor: Migrates locationReducer * Refactor: Migrates navModelReducer * Refactor: Migrates teamsReducer and teamReducer * Refactor: Migrates cleanUpAction * Refactor: Migrates alertRulesReducer * Refactor: Cleans up recursiveCleanState * Refactor: Switched to Angular compatible reducers * Refactor: Migrates folderReducer * Refactor: Migrates dashboardReducer * Migrates panelEditorReducer * Refactor: Migrates dataSourcesReducer * Refactor: Migrates usersReducer * Refactor: Migrates organizationReducer * Refactor: Migrates pluginsReducer * Refactor: Migrates ldapReducer and ldapUserReducer * Refactor: Migrates apiKeysReducer * Refactor: Migrates exploreReducer and itemReducer * Refactor: Removes actionCreatorFactory and reducerFactory * Refactor: Moves mocks to test section * Docs: Removes sections about home grown framework * Update contribute/style-guides/redux.md Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Refactor: Cleans up some code * Refactor: Adds state typings * Refactor: Cleans up typings * Refactor: Adds comment about ImmerJs autoFreeze Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import { hot } from 'react-hot-loader';
|
|
import { connect } from 'react-redux';
|
|
import { NavModel } from '@grafana/data';
|
|
|
|
import Page from 'app/core/components/Page/Page';
|
|
import OrgProfile from './OrgProfile';
|
|
import SharedPreferences from 'app/core/components/SharedPreferences/SharedPreferences';
|
|
import { loadOrganization, updateOrganization } from './state/actions';
|
|
import { Organization, StoreState } from 'app/types';
|
|
import { getNavModel } from 'app/core/selectors/navModel';
|
|
import { setOrganizationName } from './state/reducers';
|
|
|
|
export interface Props {
|
|
navModel: NavModel;
|
|
organization: Organization;
|
|
loadOrganization: typeof loadOrganization;
|
|
setOrganizationName: typeof setOrganizationName;
|
|
updateOrganization: typeof updateOrganization;
|
|
}
|
|
|
|
export class OrgDetailsPage extends PureComponent<Props> {
|
|
async componentDidMount() {
|
|
await this.props.loadOrganization();
|
|
}
|
|
|
|
onOrgNameChange = (name: string) => {
|
|
this.props.setOrganizationName(name);
|
|
};
|
|
|
|
onUpdateOrganization = () => {
|
|
this.props.updateOrganization();
|
|
};
|
|
|
|
render() {
|
|
const { navModel, organization } = this.props;
|
|
const isLoading = Object.keys(organization).length === 0;
|
|
|
|
return (
|
|
<Page navModel={navModel}>
|
|
<Page.Contents isLoading={isLoading}>
|
|
{!isLoading && (
|
|
<div>
|
|
<OrgProfile
|
|
onOrgNameChange={name => this.onOrgNameChange(name)}
|
|
onSubmit={this.onUpdateOrganization}
|
|
orgName={organization.name}
|
|
/>
|
|
<SharedPreferences resourceUri="org" />
|
|
</div>
|
|
)}
|
|
</Page.Contents>
|
|
</Page>
|
|
);
|
|
}
|
|
}
|
|
|
|
function mapStateToProps(state: StoreState) {
|
|
return {
|
|
navModel: getNavModel(state.navIndex, 'org-settings'),
|
|
organization: state.organization.organization,
|
|
};
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
loadOrganization,
|
|
setOrganizationName,
|
|
updateOrganization,
|
|
};
|
|
|
|
export default hot(module)(connect(mapStateToProps, mapDispatchToProps)(OrgDetailsPage));
|