mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
feat: remove active/inactive members (#6654)

This commit is contained in:
parent
8080a1d907
commit
c41ec49615
@ -4,15 +4,12 @@ import { ProjectMembers } from './ProjectMembers';
|
|||||||
|
|
||||||
test('Show outdated project members', async () => {
|
test('Show outdated project members', async () => {
|
||||||
const members = {
|
const members = {
|
||||||
active: 10,
|
currentMembers: 10,
|
||||||
totalPreviousMonth: 2,
|
change: 2,
|
||||||
inactive: 5,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render(<ProjectMembers projectId={'default'} members={members} />);
|
render(<ProjectMembers projectId={'default'} members={members} />);
|
||||||
|
|
||||||
await screen.findByText('15');
|
|
||||||
await screen.findByText('+13');
|
|
||||||
await screen.findByText('10');
|
await screen.findByText('10');
|
||||||
await screen.findByText('5');
|
await screen.findByText('+2');
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { Box, styled, Typography, useTheme } from '@mui/material';
|
import { Box, styled, Typography } from '@mui/material';
|
||||||
import { StatusBox } from '../ProjectInsightsStats/StatusBox';
|
import { StatusBox } from '../ProjectInsightsStats/StatusBox';
|
||||||
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
|
import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
@ -23,92 +23,17 @@ export const StyledProjectInfoWidgetContainer = styled('div')(({ theme }) => ({
|
|||||||
gap: theme.spacing(2.5),
|
gap: theme.spacing(2.5),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const BarContainer = styled('div')(({ theme }) => ({
|
|
||||||
width: '100%',
|
|
||||||
height: '20px',
|
|
||||||
display: 'flex',
|
|
||||||
}));
|
|
||||||
|
|
||||||
const ActiveBar = styled('span', {
|
|
||||||
shouldForwardProp: (prop) => prop !== 'percentage',
|
|
||||||
})<{
|
|
||||||
percentage: number;
|
|
||||||
}>(({ theme, percentage }) => ({
|
|
||||||
width: `${percentage - 1}%`,
|
|
||||||
backgroundColor: theme.palette.success.border,
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const InactiveBar = styled('span', {
|
|
||||||
shouldForwardProp: (prop) => prop !== 'percentage',
|
|
||||||
})<{
|
|
||||||
percentage: number;
|
|
||||||
}>(({ theme, percentage }) => ({
|
|
||||||
width: `${percentage - 1}%`,
|
|
||||||
backgroundColor: theme.palette.warning.border,
|
|
||||||
marginLeft: 'auto',
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const CountContainer = styled('div')(({ theme }) => ({
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
gap: theme.spacing(1.5),
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const CountRow = styled(NavigationBar)(({ theme }) => ({
|
|
||||||
display: 'flex',
|
|
||||||
padding: theme.spacing(0.5, 1, 0, 2),
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: theme.spacing(3),
|
|
||||||
alignSelf: 'stretch',
|
|
||||||
borderRadius: theme.shape.borderRadiusMedium,
|
|
||||||
background: '#F7F7FA',
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StatusWithDot = styled(Box)(({ theme }) => ({
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
gap: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const Dot = styled('span', {
|
|
||||||
shouldForwardProp: (prop) => prop !== 'color',
|
|
||||||
})<{
|
|
||||||
color?: string;
|
|
||||||
}>(({ theme, color }) => ({
|
|
||||||
height: '15px',
|
|
||||||
width: '15px',
|
|
||||||
borderRadius: '50%',
|
|
||||||
display: 'inline-block',
|
|
||||||
backgroundColor: color,
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const StyledCount = styled('span')(({ theme }) => ({
|
|
||||||
fontSize: theme.typography.h1.fontSize,
|
|
||||||
fontWeight: theme.typography.fontWeightRegular,
|
|
||||||
color: theme.palette.text.primary,
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const ProjectMembers = ({
|
export const ProjectMembers = ({
|
||||||
members,
|
members,
|
||||||
projectId,
|
projectId,
|
||||||
}: IProjectMembersProps) => {
|
}: IProjectMembersProps) => {
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const theme = useTheme();
|
|
||||||
|
|
||||||
const link = uiConfig?.versionInfo?.current?.enterprise
|
const link = uiConfig?.versionInfo?.current?.enterprise
|
||||||
? `/projects/${projectId}/settings/access`
|
? `/projects/${projectId}/settings/access`
|
||||||
: `/admin/users`;
|
: `/admin/users`;
|
||||||
|
|
||||||
const { active, totalPreviousMonth, inactive } = members;
|
const { currentMembers, change } = members;
|
||||||
|
|
||||||
const currentMembers = active + inactive;
|
|
||||||
const change = currentMembers - (totalPreviousMonth || 0);
|
|
||||||
|
|
||||||
const activePercentage = (active / currentMembers) * 100;
|
|
||||||
const inactivePercentage = (inactive / currentMembers) * 100;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledProjectInfoWidgetContainer>
|
<StyledProjectInfoWidgetContainer>
|
||||||
<NavigationBar to={link}>
|
<NavigationBar to={link}>
|
||||||
@ -122,28 +47,6 @@ export const ProjectMembers = ({
|
|||||||
>
|
>
|
||||||
<StatusBox boxText={`${currentMembers}`} change={change} />
|
<StatusBox boxText={`${currentMembers}`} change={change} />
|
||||||
</Box>
|
</Box>
|
||||||
<BarContainer>
|
|
||||||
<ActiveBar percentage={activePercentage} />
|
|
||||||
<InactiveBar percentage={inactivePercentage} />
|
|
||||||
</BarContainer>
|
|
||||||
<CountContainer>
|
|
||||||
<CountRow to={link}>
|
|
||||||
<StatusWithDot>
|
|
||||||
<Dot color={theme.palette.success.border} />
|
|
||||||
<Box>Active</Box>
|
|
||||||
<StyledCount>{active}</StyledCount>
|
|
||||||
</StatusWithDot>
|
|
||||||
<KeyboardArrowRight />
|
|
||||||
</CountRow>
|
|
||||||
<CountRow to={link}>
|
|
||||||
<StatusWithDot>
|
|
||||||
<Dot color={theme.palette.warning.border} />
|
|
||||||
<Box>Inactive</Box>
|
|
||||||
<StyledCount>{inactive}</StyledCount>
|
|
||||||
</StatusWithDot>
|
|
||||||
<KeyboardArrowRight />
|
|
||||||
</CountRow>
|
|
||||||
</CountContainer>
|
|
||||||
</StyledProjectInfoWidgetContainer>
|
</StyledProjectInfoWidgetContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -46,9 +46,8 @@ const placeholderData: ProjectInsightsSchema = {
|
|||||||
staleCount: 0,
|
staleCount: 0,
|
||||||
},
|
},
|
||||||
members: {
|
members: {
|
||||||
active: 0,
|
currentMembers: 0,
|
||||||
inactive: 0,
|
change: 0,
|
||||||
totalPreviousMonth: 0,
|
|
||||||
},
|
},
|
||||||
changeRequests: {
|
changeRequests: {
|
||||||
total: 0,
|
total: 0,
|
||||||
|
@ -8,10 +8,8 @@
|
|||||||
* Active/inactive users summary
|
* Active/inactive users summary
|
||||||
*/
|
*/
|
||||||
export type ProjectInsightsSchemaMembers = {
|
export type ProjectInsightsSchemaMembers = {
|
||||||
/** The number of active project members who have used Unleash in the past 60 days */
|
/** The change in the number of project members compared to the previous month */
|
||||||
active: number;
|
change: number;
|
||||||
/** The number of inactive project members who have not used Unleash in the past 60 days */
|
/** The number of total project members */
|
||||||
inactive: number;
|
currentMembers: number;
|
||||||
/** The number of total project members in the previous month */
|
|
||||||
totalPreviousMonth?: number;
|
|
||||||
};
|
};
|
||||||
|
@ -104,9 +104,8 @@ export class ProjectInsightsService {
|
|||||||
async getProjectInsights(projectId: string) {
|
async getProjectInsights(projectId: string) {
|
||||||
const result = {
|
const result = {
|
||||||
members: {
|
members: {
|
||||||
active: 20,
|
currentMembers: 20,
|
||||||
inactive: 3,
|
change: 3,
|
||||||
totalPreviousMonth: 15,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,26 +64,19 @@ export const projectInsightsSchema = {
|
|||||||
},
|
},
|
||||||
members: {
|
members: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
required: ['active', 'inactive'],
|
required: ['currentMembers', 'change'],
|
||||||
properties: {
|
properties: {
|
||||||
active: {
|
currentMembers: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description:
|
description: 'The number of total project members',
|
||||||
'The number of active project members who have used Unleash in the past 60 days',
|
|
||||||
example: 10,
|
example: 10,
|
||||||
},
|
},
|
||||||
inactive: {
|
change: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description:
|
description:
|
||||||
'The number of inactive project members who have not used Unleash in the past 60 days',
|
'The change in the number of project members compared to the previous month',
|
||||||
example: 10,
|
example: 10,
|
||||||
},
|
},
|
||||||
totalPreviousMonth: {
|
|
||||||
type: 'number',
|
|
||||||
description:
|
|
||||||
'The number of total project members in the previous month',
|
|
||||||
example: 8,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
description: 'Active/inactive users summary',
|
description: 'Active/inactive users summary',
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user