diff --git a/public/app/features/admin/AdminEditOrgPage.tsx b/public/app/features/admin/AdminEditOrgPage.tsx index 0a61c6d08d9..455ca42bed5 100644 --- a/public/app/features/admin/AdminEditOrgPage.tsx +++ b/public/app/features/admin/AdminEditOrgPage.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState, useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; import Page from 'app/core/components/Page/Page'; import { useSelector } from 'react-redux'; import { StoreState, OrgUser, AccessControlAction } from 'app/types'; @@ -37,7 +37,7 @@ const removeOrgUser = async (orgUser: OrgUser, orgId: UrlQueryValue) => { interface Props extends GrafanaRouteComponentProps<{ id: string }> {} -export const AdminEditOrgPage: FC = ({ match }) => { +export default function AdminEditOrgPage({ match }: Props) { const navIndex = useSelector((state: StoreState) => state.navIndex); const navModel = getNavModel(navIndex, 'global-orgs'); const orgId = parseInt(match.params.id, 10); @@ -123,6 +123,4 @@ export const AdminEditOrgPage: FC = ({ match }) => { ); -}; - -export default AdminEditOrgPage; +} diff --git a/public/app/features/admin/AdminListOrgsPage.tsx b/public/app/features/admin/AdminListOrgsPage.tsx index 925b62b5fd7..f9e70493822 100644 --- a/public/app/features/admin/AdminListOrgsPage.tsx +++ b/public/app/features/admin/AdminListOrgsPage.tsx @@ -1,4 +1,4 @@ -import React, { FC, useEffect } from 'react'; +import React, { useEffect } from 'react'; import { getNavModel } from 'app/core/selectors/navModel'; import Page from 'app/core/components/Page/Page'; import { useSelector } from 'react-redux'; @@ -22,7 +22,7 @@ const getErrorMessage = (error: any) => { return error?.data?.message || 'An unexpected error happened.'; }; -export const AdminListOrgsPages: FC = () => { +export default function AdminListOrgsPages() { const navIndex = useSelector((state: StoreState) => state.navIndex); const navModel = getNavModel(navIndex, 'global-orgs'); const [state, fetchOrgs] = useAsyncFn(async () => await getOrgs(), []); @@ -56,6 +56,4 @@ export const AdminListOrgsPages: FC = () => { ); -}; - -export default AdminListOrgsPages; +} diff --git a/public/app/features/admin/AdminOrgsTable.tsx b/public/app/features/admin/AdminOrgsTable.tsx index ab290859152..f8c9003d80d 100644 --- a/public/app/features/admin/AdminOrgsTable.tsx +++ b/public/app/features/admin/AdminOrgsTable.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react'; +import React, { useState } from 'react'; import { AccessControlAction, Organization } from 'app/types'; import { Button, ConfirmModal } from '@grafana/ui'; import { contextSrv } from 'app/core/core'; @@ -8,7 +8,7 @@ interface Props { onDelete: (orgId: number) => void; } -export const AdminOrgsTable: FC = ({ orgs, onDelete }) => { +export function AdminOrgsTable({ orgs, onDelete }: Props) { const canDeleteOrgs = contextSrv.hasPermission(AccessControlAction.OrgsDelete); const [deleteOrg, setDeleteOrg] = useState(); @@ -64,4 +64,4 @@ export const AdminOrgsTable: FC = ({ orgs, onDelete }) => { )} ); -}; +} diff --git a/public/app/features/admin/AdminSettings.tsx b/public/app/features/admin/AdminSettings.tsx index d6b8a2d3533..d54470c49cc 100644 --- a/public/app/features/admin/AdminSettings.tsx +++ b/public/app/features/admin/AdminSettings.tsx @@ -1,5 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; +import { useAsync } from 'react-use'; import { getBackendSrv } from '@grafana/runtime'; import { NavModel } from '@grafana/data'; @@ -13,37 +14,21 @@ interface Props { navModel: NavModel; } -interface State { - settings: Settings; - isLoading: boolean; -} +function AdminSettings({ navModel }: Props) { + const { loading, value: settings } = useAsync( + () => getBackendSrv().get('/api/admin/settings') as Promise, + [] + ); -export class AdminSettings extends React.PureComponent { - state: State = { - settings: {}, - isLoading: true, - }; - - async componentDidMount() { - const settings: Settings = await getBackendSrv().get('/api/admin/settings'); - this.setState({ - settings, - isLoading: false, - }); - } - - render() { - const { settings, isLoading } = this.state; - const { navModel } = this.props; - - return ( - - -
- These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables). To change - these you currently need to restart Grafana. -
+ return ( + + +
+ These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables). To change + these you currently need to restart Grafana. +
+ {settings && ( {Object.entries(settings).map(([sectionName, sectionSettings], i) => ( @@ -62,10 +47,10 @@ export class AdminSettings extends React.PureComponent { ))}
-
-
- ); - } + )} +
+
+ ); } const mapStateToProps = (state: StoreState) => ({ diff --git a/public/app/features/admin/LicenseChrome.tsx b/public/app/features/admin/LicenseChrome.tsx index ed6b89a2192..1acf09e3696 100644 --- a/public/app/features/admin/LicenseChrome.tsx +++ b/public/app/features/admin/LicenseChrome.tsx @@ -32,9 +32,10 @@ interface Props { header: string; subheader?: string; editionNotice?: string; + children?: React.ReactNode; } -export const LicenseChrome: React.FC = ({ header, editionNotice, subheader, children }) => { +export function LicenseChrome({ header, editionNotice, subheader, children }: Props) { const theme = useTheme(); const styles = getStyles(theme); @@ -68,7 +69,7 @@ export const LicenseChrome: React.FC = ({ header, editionNotice, subheade {editionNotice &&
{editionNotice}
} ); -}; +} interface CircleProps { size: string; diff --git a/public/app/features/admin/OrgRolePicker.tsx b/public/app/features/admin/OrgRolePicker.tsx index 0335f827ce6..88e30c8a547 100644 --- a/public/app/features/admin/OrgRolePicker.tsx +++ b/public/app/features/admin/OrgRolePicker.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React from 'react'; import { OrgRole } from '@grafana/data'; import { Select } from '@grafana/ui'; @@ -13,14 +13,7 @@ interface Props { const options = Object.keys(OrgRole).map((key) => ({ label: key, value: key })); -export const OrgRolePicker: FC = ({ - value, - onChange, - 'aria-label': ariaLabel, - inputId, - autoFocus, - ...restProps -}) => { +export function OrgRolePicker({ value, onChange, 'aria-label': ariaLabel, inputId, autoFocus, ...restProps }: Props) { return (