diff --git a/public/app/core/components/Page/OldNavOnly.tsx b/public/app/core/components/Page/OldNavOnly.tsx new file mode 100644 index 00000000000..62a97548086 --- /dev/null +++ b/public/app/core/components/Page/OldNavOnly.tsx @@ -0,0 +1,10 @@ +import React from 'react'; + +interface Props { + children: React.ReactNode; +} + +/** Remove after topnav feature toggle is removed */ +export function OldNavOnly({ children }: Props): React.ReactElement | null { + return <>{children}; +} diff --git a/public/app/core/components/Page/Page.tsx b/public/app/core/components/Page/Page.tsx index 52c96ecd0a3..8404ccb2226 100644 --- a/public/app/core/components/Page/Page.tsx +++ b/public/app/core/components/Page/Page.tsx @@ -2,7 +2,7 @@ import { css, cx } from '@emotion/css'; import React from 'react'; -import { GrafanaTheme2 } from '@grafana/data'; +import { GrafanaTheme2, NavModel, NavModelItem } from '@grafana/data'; import { config } from '@grafana/runtime'; import { CustomScrollbar, useStyles2 } from '@grafana/ui'; @@ -10,6 +10,7 @@ import { Footer } from '../Footer/Footer'; import { PageHeader } from '../PageHeader/PageHeader'; import { Page as NewPage } from '../PageNew/Page'; +import { OldNavOnly } from './OldNavOnly'; import { PageContents } from './PageContents'; import { PageLayoutType, PageType } from './types'; import { usePageNav } from './usePageNav'; @@ -31,7 +32,7 @@ export const OldPage: PageType = ({ usePageTitle(navModel, pageNav); - const pageHeaderNav = pageNav ?? navModel?.main; + const pageHeaderNav = getPageHeaderNav(navModel, pageNav); return (
@@ -58,8 +59,17 @@ export const OldPage: PageType = ({ ); }; +function getPageHeaderNav(navModel?: NavModel, pageNav?: NavModelItem): NavModelItem | undefined { + if (pageNav?.children && pageNav.children.length > 0) { + return pageNav; + } + + return navModel?.main; +} + OldPage.Header = PageHeader; OldPage.Contents = PageContents; +OldPage.OldNavOnly = OldNavOnly; export const Page: PageType = config.featureToggles.topnav ? NewPage : OldPage; diff --git a/public/app/core/components/Page/types.ts b/public/app/core/components/Page/types.ts index 104c5a98c34..4f06651fe57 100644 --- a/public/app/core/components/Page/types.ts +++ b/public/app/core/components/Page/types.ts @@ -1,9 +1,10 @@ -import { FC, HTMLAttributes, RefCallback } from 'react'; +import React, { FC, HTMLAttributes, RefCallback } from 'react'; import { NavModel, NavModelItem } from '@grafana/data'; import { PageHeader } from '../PageHeader/PageHeader'; +import { OldNavOnly } from './OldNavOnly'; import { PageContents } from './PageContents'; export interface PageProps extends HTMLAttributes { @@ -28,5 +29,6 @@ export enum PageLayoutType { export interface PageType extends FC { Header: typeof PageHeader; + OldNavOnly: typeof OldNavOnly; Contents: typeof PageContents; } diff --git a/public/app/core/components/PageNew/Page.tsx b/public/app/core/components/PageNew/Page.tsx index 19966eacd3d..2634adc9ec1 100644 --- a/public/app/core/components/PageNew/Page.tsx +++ b/public/app/core/components/PageNew/Page.tsx @@ -76,6 +76,7 @@ export const Page: PageType = ({ Page.Header = PageHeader; Page.Contents = PageContents; +Page.OldNavOnly = () => null; const getStyles = (theme: GrafanaTheme2) => { const shadow = theme.isDark diff --git a/public/app/features/org/UserInviteForm.tsx b/public/app/features/org/UserInviteForm.tsx index e94c6c9e9cf..40ba570823c 100644 --- a/public/app/features/org/UserInviteForm.tsx +++ b/public/app/features/org/UserInviteForm.tsx @@ -1,18 +1,9 @@ import React from 'react'; import { locationUtil } from '@grafana/data'; +import { Stack } from '@grafana/experimental'; import { locationService } from '@grafana/runtime'; -import { - HorizontalGroup, - Button, - LinkButton, - Input, - Switch, - RadioButtonGroup, - Form, - Field, - InputControl, -} from '@grafana/ui'; +import { Button, LinkButton, Input, Switch, RadioButtonGroup, Form, Field, InputControl, FieldSet } from '@grafana/ui'; import { getConfig } from 'app/core/config'; import { OrgRole, useDispatch } from 'app/types'; @@ -52,32 +43,34 @@ export const UserInviteForm = () => { {({ register, control, errors }) => { return ( <> - - - - - - - - } - control={control} - name="role" - /> - - - - - +
+ + + + + + + + } + control={control} + name="role" + /> + + + + +
+ Back -
+ ); }} diff --git a/public/app/features/org/UserInvitePage.tsx b/public/app/features/org/UserInvitePage.tsx index 097ead15a32..375065a6392 100644 --- a/public/app/features/org/UserInvitePage.tsx +++ b/public/app/features/org/UserInvitePage.tsx @@ -1,35 +1,29 @@ -import React, { FC } from 'react'; -import { connect } from 'react-redux'; +import React from 'react'; -import { NavModel } from '@grafana/data'; import { Page } from 'app/core/components/Page/Page'; import { contextSrv } from 'app/core/core'; -import { getNavModel } from 'app/core/selectors/navModel'; -import { StoreState } from 'app/types/store'; import UserInviteForm from './UserInviteForm'; -interface Props { - navModel: NavModel; -} +export function UserInvitePage() { + const subTitle = ( + <> + Send invitation or add existing Grafana user to the organization. + {contextSrv.user.orgName} + + ); -export const UserInvitePage: FC = ({ navModel }) => { return ( - + -

Invite user

-
- Send invitation or add existing Grafana user to the organization. - {contextSrv.user.orgName} -
+ +

Invite user

+
{subTitle}
+
); -}; +} -const mapStateToProps = (state: StoreState) => ({ - navModel: getNavModel(state.navIndex, 'users'), -}); - -export default connect(mapStateToProps)(UserInvitePage); +export default UserInvitePage; diff --git a/public/app/features/profile/ChangePasswordPage.tsx b/public/app/features/profile/ChangePasswordPage.tsx index f6900e56e82..b1c98e274db 100644 --- a/public/app/features/profile/ChangePasswordPage.tsx +++ b/public/app/features/profile/ChangePasswordPage.tsx @@ -36,7 +36,9 @@ export function ChangePasswordPage({ loadUser, isUpdating, user, changePassword {user ? ( <> -

Change Your Password

+ +

Change Your Password

+
) : null} diff --git a/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx b/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx index a2d3427990b..3773d9508cc 100644 --- a/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx +++ b/public/app/features/serviceaccounts/ServiceAccountCreatePage.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { getBackendSrv } from '@grafana/runtime'; -import { Form, Button, Input, Field } from '@grafana/ui'; +import { Form, Button, Input, Field, FieldSet } from '@grafana/ui'; import { Page } from 'app/core/components/Page/Page'; import { UserRolePicker } from 'app/core/components/RolePicker/UserRolePicker'; import { fetchBuiltinRoles, fetchRoleOptions, updateUserRoles } from 'app/core/components/RolePicker/api'; @@ -110,39 +110,43 @@ export const ServiceAccountCreatePage = ({}: Props): JSX.Element => { }; return ( - + -

Create service account

+ +

Create service account

+
{({ register, errors }) => { return ( <> - - - - - {contextSrv.licensedAccessControlEnabled() ? ( - - ) : ( - - )} - +
+ + + + + {contextSrv.licensedAccessControlEnabled() ? ( + + ) : ( + + )} + +
); diff --git a/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx b/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx index 945069f1801..c569f4d79c3 100644 --- a/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx +++ b/public/app/features/serviceaccounts/ServiceAccountsListPage.tsx @@ -4,7 +4,6 @@ import React, { useEffect, useState } from 'react'; import { connect, ConnectedProps } from 'react-redux'; import { GrafanaTheme2, OrgRole } from '@grafana/data'; -import { config } from '@grafana/runtime'; import { Alert, ConfirmModal, FilterInput, Icon, LinkButton, RadioButtonGroup, Tooltip, useStyles2 } from '@grafana/ui'; import EmptyListCTA from 'app/core/components/EmptyListCTA/EmptyListCTA'; import { Page } from 'app/core/components/Page/Page'; @@ -193,7 +192,7 @@ export const ServiceAccountsListPageUnconnected = ({ onRemove={onMigrationInfoClose} > )} - {!config.featureToggles.topnav && ( +

Service accounts

@@ -207,7 +206,7 @@ export const ServiceAccountsListPageUnconnected = ({ Looking for API keys?
- )} +