mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Page: Update profile page components to use new navId (#51664)
This commit is contained in:
parent
94175a801a
commit
4d4ab87bb6
@ -10436,4 +10436,4 @@ exports[`no undocumented stories`] = {
|
|||||||
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
[0, 0, 0, "No undocumented stories are allowed, please add an .mdx file with some documentation", "5381"]
|
||||||
]
|
]
|
||||||
}`
|
}`
|
||||||
};
|
};
|
@ -36,17 +36,17 @@ func (hs *HTTPServer) getProfileNode(c *models.ReqContext) *dtos.NavLink {
|
|||||||
|
|
||||||
children := []*dtos.NavLink{
|
children := []*dtos.NavLink{
|
||||||
{
|
{
|
||||||
Text: "Preferences", Id: "profile-settings", Url: hs.Cfg.AppSubURL + "/profile", Icon: "sliders-v-alt",
|
Text: "Preferences", Id: "profile/settings", Url: hs.Cfg.AppSubURL + "/profile", Icon: "sliders-v-alt",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
children = append(children, &dtos.NavLink{
|
children = append(children, &dtos.NavLink{
|
||||||
Text: "Notification history", Id: "notifications", Url: hs.Cfg.AppSubURL + "/notifications", Icon: "bell",
|
Text: "Notification history", Id: "profile/notifications", Url: hs.Cfg.AppSubURL + "profile/notifications", Icon: "bell",
|
||||||
})
|
})
|
||||||
|
|
||||||
if setting.AddChangePasswordLink() {
|
if setting.AddChangePasswordLink() {
|
||||||
children = append(children, &dtos.NavLink{
|
children = append(children, &dtos.NavLink{
|
||||||
Text: "Change password", Id: "change-password", Url: hs.Cfg.AppSubURL + "/profile/password",
|
Text: "Change password", Id: "profile/password", Url: hs.Cfg.AppSubURL + "/profile/password",
|
||||||
Icon: "lock",
|
Icon: "lock",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ const TRANSLATED_MENU_ITEMS: Record<string, MessageDescriptor> = {
|
|||||||
|
|
||||||
help: defineMessage({ id: 'nav.help', message: 'Help' }),
|
help: defineMessage({ id: 'nav.help', message: 'Help' }),
|
||||||
|
|
||||||
'profile-settings': defineMessage({ id: 'nav.profile-settings', message: 'Preferences' }),
|
'profile-settings': defineMessage({ id: 'nav.profile/settings', message: 'Preferences' }),
|
||||||
'change-password': defineMessage({ id: 'nav.change-password', message: 'Change password' }),
|
'change-password': defineMessage({ id: 'nav.profile/password', message: 'Change password' }),
|
||||||
'sign-out': defineMessage({ id: 'nav.sign-out', message: 'Sign out' }),
|
'sign-out': defineMessage({ id: 'nav.sign-out', message: 'Sign out' }),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ export function SectionNav(props: Props) {
|
|||||||
<nav className={styles.nav}>
|
<nav className={styles.nav}>
|
||||||
<h2 className={styles.sectionName}>
|
<h2 className={styles.sectionName}>
|
||||||
{main.icon && <Icon name={main.icon as IconName} size="lg" />}
|
{main.icon && <Icon name={main.icon as IconName} size="lg" />}
|
||||||
{main.img && <img className="page-header__img" src={main.img} alt={`logo of ${main.text}`} />}
|
{main.img && <img className={styles.sectionImg} src={main.img} alt={`logo of ${main.text}`} />}
|
||||||
{props.model.main.text}
|
{props.model.main.text}
|
||||||
</h2>
|
</h2>
|
||||||
<div className={styles.items}>
|
<div className={styles.items}>
|
||||||
@ -75,6 +75,7 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
}),
|
}),
|
||||||
sectionName: css({
|
sectionName: css({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
gap: theme.spacing(1),
|
gap: theme.spacing(1),
|
||||||
padding: theme.spacing(0.5, 0, 3, 0.25),
|
padding: theme.spacing(0.5, 0, 3, 0.25),
|
||||||
fontSize: theme.typography.h4.fontSize,
|
fontSize: theme.typography.h4.fontSize,
|
||||||
@ -83,6 +84,9 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
items: css({
|
items: css({
|
||||||
// paddingLeft: '9px',
|
// paddingLeft: '9px',
|
||||||
}),
|
}),
|
||||||
|
sectionImg: css({
|
||||||
|
height: 48,
|
||||||
|
}),
|
||||||
subSection: css({
|
subSection: css({
|
||||||
padding: theme.spacing(3, 0, 1, 1),
|
padding: theme.spacing(3, 0, 1, 1),
|
||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
|
@ -1,27 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { connect, ConnectedProps } from 'react-redux';
|
|
||||||
|
|
||||||
import { Page } from 'app/core/components/Page/Page';
|
import { Page } from 'app/core/components/Page/Page';
|
||||||
|
|
||||||
import { GrafanaRouteComponentProps } from '../../core/navigation/types';
|
|
||||||
import { getNavModel } from '../../core/selectors/navModel';
|
|
||||||
import { StoreState } from '../../types';
|
|
||||||
|
|
||||||
import { StoredNotifications } from './StoredNotifications';
|
import { StoredNotifications } from './StoredNotifications';
|
||||||
|
|
||||||
const mapStateToProps = (state: StoreState) => ({
|
export const NotificationsPage = () => {
|
||||||
navModel: getNavModel(state.navIndex, 'notifications'),
|
|
||||||
});
|
|
||||||
|
|
||||||
const connector = connect(mapStateToProps, undefined);
|
|
||||||
|
|
||||||
interface OwnProps extends GrafanaRouteComponentProps {}
|
|
||||||
|
|
||||||
type Props = OwnProps & ConnectedProps<typeof connector>;
|
|
||||||
|
|
||||||
export const NotificationsPage = ({ navModel }: Props) => {
|
|
||||||
return (
|
return (
|
||||||
<Page navModel={navModel}>
|
<Page navId="profile/notifications">
|
||||||
<Page.Contents>
|
<Page.Contents>
|
||||||
<StoredNotifications />
|
<StoredNotifications />
|
||||||
</Page.Contents>
|
</Page.Contents>
|
||||||
@ -29,4 +14,4 @@ export const NotificationsPage = ({ navModel }: Props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps)(NotificationsPage);
|
export default NotificationsPage;
|
||||||
|
@ -4,7 +4,6 @@ import React from 'react';
|
|||||||
|
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
|
|
||||||
import { getNavModel } from '../../core/selectors/navModel';
|
|
||||||
import { backendSrv } from '../../core/services/backend_srv';
|
import { backendSrv } from '../../core/services/backend_srv';
|
||||||
|
|
||||||
import { Props, ChangePasswordPage } from './ChangePasswordPage';
|
import { Props, ChangePasswordPage } from './ChangePasswordPage';
|
||||||
@ -22,23 +21,6 @@ const defaultProps: Props = {
|
|||||||
orgId: 0,
|
orgId: 0,
|
||||||
authLabels: ['github'],
|
authLabels: ['github'],
|
||||||
},
|
},
|
||||||
navModel: getNavModel(
|
|
||||||
{
|
|
||||||
'profile-settings': {
|
|
||||||
icon: 'sliders-v-alt',
|
|
||||||
id: 'profile-settings',
|
|
||||||
parentItem: {
|
|
||||||
id: 'profile',
|
|
||||||
text: 'Test User',
|
|
||||||
img: '/avatar/46d229b033af06a191ff2267bca9ae56',
|
|
||||||
url: '/profile',
|
|
||||||
},
|
|
||||||
text: 'Preferences',
|
|
||||||
url: '/profile',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'profile-settings'
|
|
||||||
),
|
|
||||||
loadUser: jest.fn(),
|
loadUser: jest.fn(),
|
||||||
changePassword: jest.fn(),
|
changePassword: jest.fn(),
|
||||||
};
|
};
|
||||||
|
@ -2,23 +2,18 @@ import React from 'react';
|
|||||||
import { connect, ConnectedProps } from 'react-redux';
|
import { connect, ConnectedProps } from 'react-redux';
|
||||||
import { useMount } from 'react-use';
|
import { useMount } from 'react-use';
|
||||||
|
|
||||||
import { NavModel } from '@grafana/data';
|
|
||||||
import { Page } from 'app/core/components/Page/Page';
|
import { Page } from 'app/core/components/Page/Page';
|
||||||
import { getNavModel } from 'app/core/selectors/navModel';
|
|
||||||
import { StoreState } from 'app/types';
|
import { StoreState } from 'app/types';
|
||||||
|
|
||||||
import { ChangePasswordForm } from './ChangePasswordForm';
|
import { ChangePasswordForm } from './ChangePasswordForm';
|
||||||
import { changePassword, loadUser } from './state/actions';
|
import { changePassword, loadUser } from './state/actions';
|
||||||
|
|
||||||
export interface OwnProps {
|
export interface OwnProps {}
|
||||||
navModel: NavModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapStateToProps(state: StoreState) {
|
function mapStateToProps(state: StoreState) {
|
||||||
const userState = state.user;
|
const userState = state.user;
|
||||||
const { isUpdating, user } = userState;
|
const { isUpdating, user } = userState;
|
||||||
return {
|
return {
|
||||||
navModel: getNavModel(state.navIndex, `change-password`),
|
|
||||||
isUpdating,
|
isUpdating,
|
||||||
user,
|
user,
|
||||||
};
|
};
|
||||||
@ -33,11 +28,11 @@ const connector = connect(mapStateToProps, mapDispatchToProps);
|
|||||||
|
|
||||||
export type Props = OwnProps & ConnectedProps<typeof connector>;
|
export type Props = OwnProps & ConnectedProps<typeof connector>;
|
||||||
|
|
||||||
export function ChangePasswordPage({ navModel, loadUser, isUpdating, user, changePassword }: Props) {
|
export function ChangePasswordPage({ loadUser, isUpdating, user, changePassword }: Props) {
|
||||||
useMount(() => loadUser());
|
useMount(() => loadUser());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page navModel={navModel}>
|
<Page navId="profile/password">
|
||||||
<Page.Contents isLoading={!Boolean(user)}>
|
<Page.Contents isLoading={!Boolean(user)}>
|
||||||
{user ? (
|
{user ? (
|
||||||
<>
|
<>
|
||||||
|
@ -7,7 +7,6 @@ import { OrgRole } from '@grafana/data';
|
|||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
|
|
||||||
import TestProvider from '../../../test/helpers/TestProvider';
|
import TestProvider from '../../../test/helpers/TestProvider';
|
||||||
import { getNavModel } from '../../core/selectors/navModel';
|
|
||||||
import { backendSrv } from '../../core/services/backend_srv';
|
import { backendSrv } from '../../core/services/backend_srv';
|
||||||
import { TeamPermissionLevel } from '../../types';
|
import { TeamPermissionLevel } from '../../types';
|
||||||
|
|
||||||
@ -66,23 +65,6 @@ const defaultProps: Props = {
|
|||||||
seenAt: new Date().toUTCString(),
|
seenAt: new Date().toUTCString(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
navModel: getNavModel(
|
|
||||||
{
|
|
||||||
'profile-settings': {
|
|
||||||
icon: 'sliders-v-alt',
|
|
||||||
id: 'profile-settings',
|
|
||||||
parentItem: {
|
|
||||||
id: 'profile',
|
|
||||||
text: 'Test User',
|
|
||||||
img: '/avatar/46d229b033af06a191ff2267bca9ae56',
|
|
||||||
url: '/profile',
|
|
||||||
},
|
|
||||||
text: 'Preferences',
|
|
||||||
url: '/profile',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'profile-settings'
|
|
||||||
),
|
|
||||||
initUserProfilePage: jest.fn().mockResolvedValue(undefined),
|
initUserProfilePage: jest.fn().mockResolvedValue(undefined),
|
||||||
revokeUserSession: jest.fn().mockResolvedValue(undefined),
|
revokeUserSession: jest.fn().mockResolvedValue(undefined),
|
||||||
changeUserOrg: jest.fn().mockResolvedValue(undefined),
|
changeUserOrg: jest.fn().mockResolvedValue(undefined),
|
||||||
|
@ -2,11 +2,9 @@ import React from 'react';
|
|||||||
import { connect, ConnectedProps } from 'react-redux';
|
import { connect, ConnectedProps } from 'react-redux';
|
||||||
import { useMount } from 'react-use';
|
import { useMount } from 'react-use';
|
||||||
|
|
||||||
import { NavModel } from '@grafana/data';
|
|
||||||
import { VerticalGroup } from '@grafana/ui';
|
import { VerticalGroup } from '@grafana/ui';
|
||||||
import { Page } from 'app/core/components/Page/Page';
|
import { Page } from 'app/core/components/Page/Page';
|
||||||
import SharedPreferences from 'app/core/components/SharedPreferences/SharedPreferences';
|
import SharedPreferences from 'app/core/components/SharedPreferences/SharedPreferences';
|
||||||
import { getNavModel } from 'app/core/selectors/navModel';
|
|
||||||
import { StoreState } from 'app/types';
|
import { StoreState } from 'app/types';
|
||||||
|
|
||||||
import UserOrganizations from './UserOrganizations';
|
import UserOrganizations from './UserOrganizations';
|
||||||
@ -15,15 +13,12 @@ import UserSessions from './UserSessions';
|
|||||||
import { UserTeams } from './UserTeams';
|
import { UserTeams } from './UserTeams';
|
||||||
import { changeUserOrg, initUserProfilePage, revokeUserSession, updateUserProfile } from './state/actions';
|
import { changeUserOrg, initUserProfilePage, revokeUserSession, updateUserProfile } from './state/actions';
|
||||||
|
|
||||||
export interface OwnProps {
|
export interface OwnProps {}
|
||||||
navModel: NavModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapStateToProps(state: StoreState) {
|
function mapStateToProps(state: StoreState) {
|
||||||
const userState = state.user;
|
const userState = state.user;
|
||||||
const { user, teams, orgs, sessions, teamsAreLoading, orgsAreLoading, sessionsAreLoading, isUpdating } = userState;
|
const { user, teams, orgs, sessions, teamsAreLoading, orgsAreLoading, sessionsAreLoading, isUpdating } = userState;
|
||||||
return {
|
return {
|
||||||
navModel: getNavModel(state.navIndex, 'profile-settings'),
|
|
||||||
orgsAreLoading,
|
orgsAreLoading,
|
||||||
sessionsAreLoading,
|
sessionsAreLoading,
|
||||||
teamsAreLoading,
|
teamsAreLoading,
|
||||||
@ -47,7 +42,6 @@ const connector = connect(mapStateToProps, mapDispatchToProps);
|
|||||||
export type Props = OwnProps & ConnectedProps<typeof connector>;
|
export type Props = OwnProps & ConnectedProps<typeof connector>;
|
||||||
|
|
||||||
export function UserProfileEditPage({
|
export function UserProfileEditPage({
|
||||||
navModel,
|
|
||||||
orgsAreLoading,
|
orgsAreLoading,
|
||||||
sessionsAreLoading,
|
sessionsAreLoading,
|
||||||
teamsAreLoading,
|
teamsAreLoading,
|
||||||
@ -64,7 +58,7 @@ export function UserProfileEditPage({
|
|||||||
useMount(() => initUserProfilePage());
|
useMount(() => initUserProfilePage());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page navModel={navModel}>
|
<Page navId="profile/settings">
|
||||||
<Page.Contents isLoading={!user}>
|
<Page.Contents isLoading={!user}>
|
||||||
<VerticalGroup spacing="md">
|
<VerticalGroup spacing="md">
|
||||||
<UserProfileEditForm updateProfile={updateUserProfile} isSavingUser={isUpdating} user={user} />
|
<UserProfileEditForm updateProfile={updateUserProfile} isSavingUser={isUpdating} user={user} />
|
||||||
|
@ -23,6 +23,12 @@ const profileRoutes: RouteDescriptor[] = [
|
|||||||
() => import(/* webpackChunkName: "SelectOrgPage" */ 'app/features/org/SelectOrgPage')
|
() => import(/* webpackChunkName: "SelectOrgPage" */ 'app/features/org/SelectOrgPage')
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/profile/notifications',
|
||||||
|
component: SafeDynamicImport(
|
||||||
|
() => import(/* webpackChunkName: "NotificationsPage"*/ 'app/features/notifications/NotificationsPage')
|
||||||
|
),
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function getProfileRoutes(cfg = config): RouteDescriptor[] {
|
export function getProfileRoutes(cfg = config): RouteDescriptor[] {
|
||||||
|
Loading…
Reference in New Issue
Block a user