mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-17 01:17:29 +02:00
UI adjustments change requests (#2622)
This commit is contained in:
parent
990b708632
commit
fee95475bd
@ -1,38 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { NavLink, useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { Paper, Tab, Tabs, Theme } from '@mui/material';
|
import { Paper, Tab, Tabs } from '@mui/material';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
|
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
|
||||||
import { useTheme } from '@mui/material/styles';
|
import { CenteredNavLink } from './CenteredNavLink';
|
||||||
|
|
||||||
const createNavLinkStyle = (props: {
|
|
||||||
isActive: boolean;
|
|
||||||
theme: Theme;
|
|
||||||
}): React.CSSProperties => {
|
|
||||||
const navLinkStyle = {
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
width: '100%',
|
|
||||||
textDecoration: 'none',
|
|
||||||
color: 'inherit',
|
|
||||||
padding: props.theme.spacing(1.5, 3),
|
|
||||||
};
|
|
||||||
|
|
||||||
const activeNavLinkStyle: React.CSSProperties = {
|
|
||||||
fontWeight: 'bold',
|
|
||||||
borderRadius: '3px',
|
|
||||||
padding: props.theme.spacing(1.5, 3),
|
|
||||||
};
|
|
||||||
|
|
||||||
return props.isActive
|
|
||||||
? { ...navLinkStyle, ...activeNavLinkStyle }
|
|
||||||
: navLinkStyle;
|
|
||||||
};
|
|
||||||
|
|
||||||
function AdminMenu() {
|
function AdminMenu() {
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const theme = useTheme();
|
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
const { isBilling } = useInstanceStatus();
|
const { isBilling } = useInstanceStatus();
|
||||||
const { flags } = uiConfig;
|
const { flags } = uiConfig;
|
||||||
@ -54,28 +28,18 @@ function AdminMenu() {
|
|||||||
<Tab
|
<Tab
|
||||||
value="/admin/users"
|
value="/admin/users"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/users">
|
||||||
to="/admin/users"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span>Users</span>
|
<span>Users</span>
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{flags.UG && (
|
{flags.UG && (
|
||||||
<Tab
|
<Tab
|
||||||
value="/admin/groups"
|
value="/admin/groups"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/groups">
|
||||||
to="/admin/groups"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span>Groups</span>
|
<span>Groups</span>
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -83,83 +47,53 @@ function AdminMenu() {
|
|||||||
<Tab
|
<Tab
|
||||||
value="/admin/roles"
|
value="/admin/roles"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/roles">
|
||||||
to="/admin/roles"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span>Project roles</span>
|
<span>Project roles</span>
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Tab
|
<Tab
|
||||||
value="/admin/api"
|
value="/admin/api"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/api">
|
||||||
to="/admin/api"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
API access
|
API access
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{uiConfig.flags.embedProxyFrontend && (
|
{uiConfig.flags.embedProxyFrontend && (
|
||||||
<Tab
|
<Tab
|
||||||
value="/admin/cors"
|
value="/admin/cors"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/cors">
|
||||||
to="/admin/cors"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
CORS origins
|
CORS origins
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Tab
|
<Tab
|
||||||
value="/admin/auth"
|
value="/admin/auth"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/auth">
|
||||||
to="/admin/auth"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Single sign-on
|
Single sign-on
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Tab
|
<Tab
|
||||||
value="/admin/instance"
|
value="/admin/instance"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/instance">
|
||||||
to="/admin/instance"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Instance stats
|
Instance stats
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{isBilling && (
|
{isBilling && (
|
||||||
<Tab
|
<Tab
|
||||||
value="/admin/billing"
|
value="/admin/billing"
|
||||||
label={
|
label={
|
||||||
<NavLink
|
<CenteredNavLink to="/admin/billing">
|
||||||
to="/admin/billing"
|
|
||||||
style={({ isActive }) =>
|
|
||||||
createNavLinkStyle({ isActive, theme })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Billing
|
Billing
|
||||||
</NavLink>
|
</CenteredNavLink>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
41
frontend/src/component/admin/menu/CenteredNavLink.tsx
Normal file
41
frontend/src/component/admin/menu/CenteredNavLink.tsx
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import { Theme } from '@mui/material';
|
||||||
|
import React, { FC } from 'react';
|
||||||
|
import { NavLink } from 'react-router-dom';
|
||||||
|
import { useTheme } from '@mui/material/styles';
|
||||||
|
|
||||||
|
const createNavLinkStyle = (props: {
|
||||||
|
isActive: boolean;
|
||||||
|
theme: Theme;
|
||||||
|
}): React.CSSProperties => {
|
||||||
|
const navLinkStyle = {
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
width: '100%',
|
||||||
|
textDecoration: 'none',
|
||||||
|
color: 'inherit',
|
||||||
|
padding: props.theme.spacing(1.5, 3),
|
||||||
|
};
|
||||||
|
|
||||||
|
const activeNavLinkStyle: React.CSSProperties = {
|
||||||
|
fontWeight: 'bold',
|
||||||
|
borderRadius: '3px',
|
||||||
|
padding: props.theme.spacing(1.5, 3),
|
||||||
|
};
|
||||||
|
|
||||||
|
return props.isActive
|
||||||
|
? { ...navLinkStyle, ...activeNavLinkStyle }
|
||||||
|
: navLinkStyle;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CenteredNavLink: FC<{ to: string }> = ({ to, children }) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
return (
|
||||||
|
<NavLink
|
||||||
|
to={to}
|
||||||
|
style={({ isActive }) => createNavLinkStyle({ isActive, theme })}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</NavLink>
|
||||||
|
);
|
||||||
|
};
|
@ -2,7 +2,6 @@ import { makeStyles } from 'tss-react/mui';
|
|||||||
|
|
||||||
export const useStyles = makeStyles()(theme => ({
|
export const useStyles = makeStyles()(theme => ({
|
||||||
containerStyles: {
|
containerStyles: {
|
||||||
marginTop: '1.5rem',
|
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
[theme.breakpoints.down('md')]: {
|
[theme.breakpoints.down('md')]: {
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
@ -32,8 +31,13 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
},
|
},
|
||||||
tabButton: {
|
tabButton: {
|
||||||
textTransform: 'none',
|
textTransform: 'none',
|
||||||
width: 'auto',
|
|
||||||
fontSize: '1rem',
|
fontSize: '1rem',
|
||||||
|
flexGrow: 1,
|
||||||
|
flexBasis: 0,
|
||||||
|
[theme.breakpoints.down('md')]: {
|
||||||
|
paddingLeft: theme.spacing(1),
|
||||||
|
paddingRight: theme.spacing(1),
|
||||||
|
},
|
||||||
[theme.breakpoints.up('md')]: {
|
[theme.breakpoints.up('md')]: {
|
||||||
minWidth: 160,
|
minWidth: 160,
|
||||||
},
|
},
|
||||||
|
@ -31,6 +31,7 @@ import { ProjectSettings } from './ProjectSettings/ProjectSettings';
|
|||||||
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
||||||
import { FavoriteIconButton } from '../../common/FavoriteIconButton/FavoriteIconButton';
|
import { FavoriteIconButton } from '../../common/FavoriteIconButton/FavoriteIconButton';
|
||||||
import { useFavoriteProjectsApi } from '../../../hooks/api/actions/useFavoriteProjectsApi/useFavoriteProjectsApi';
|
import { useFavoriteProjectsApi } from '../../../hooks/api/actions/useFavoriteProjectsApi/useFavoriteProjectsApi';
|
||||||
|
import { CenteredNavLink } from '../../admin/menu/CenteredNavLink';
|
||||||
|
|
||||||
const StyledDiv = styled('div')(() => ({
|
const StyledDiv = styled('div')(() => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -241,6 +242,7 @@ const Project = () => {
|
|||||||
indicatorColor="primary"
|
indicatorColor="primary"
|
||||||
textColor="primary"
|
textColor="primary"
|
||||||
variant="scrollable"
|
variant="scrollable"
|
||||||
|
allowScrollButtonsMobile
|
||||||
>
|
>
|
||||||
{tabs.map(tab => (
|
{tabs.map(tab => (
|
||||||
<Tab
|
<Tab
|
||||||
|
@ -25,7 +25,6 @@ const ProjectOverview = () => {
|
|||||||
}, [projectId, setLastViewed]);
|
}, [projectId, setLastViewed]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
|
||||||
<div className={styles.containerStyles}>
|
<div className={styles.containerStyles}>
|
||||||
<ProjectInfo
|
<ProjectInfo
|
||||||
id={projectId}
|
id={projectId}
|
||||||
@ -42,7 +41,6 @@ const ProjectOverview = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user