mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: hook up admin / owner data to UI (#8300)
This PR hooks up the owners and admins of Unleash to the UI. They'll only be visible in cases where you have no projects. In addition, it adds Orval schemas for the new payload properties and updates the generating schemas to fix some minor typing issues.
This commit is contained in:
parent
e4cec6629d
commit
50c5af8632
@ -1,7 +1,8 @@
|
||||
import { Grid, Typography, styled } from '@mui/material';
|
||||
import { AvatarGroupFromOwners } from 'component/common/AvatarGroupFromOwners/AvatarGroupFromOwners';
|
||||
import { UserAvatar } from 'component/common/UserAvatar/UserAvatar';
|
||||
import type { ProjectSchemaOwners } from 'openapi';
|
||||
import type { PersonalDashboardSchemaAdminsItem } from 'openapi/models/personalDashboardSchemaAdminsItem';
|
||||
import type { PersonalDashboardSchemaProjectOwnersItem } from 'openapi/models/personalDashboardSchemaProjectOwnersItem';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
const ContentGrid = styled(Grid)(({ theme }) => ({
|
||||
@ -61,8 +62,8 @@ const AdminListItem = styled('li')(({ theme }) => ({
|
||||
}));
|
||||
|
||||
type Props = {
|
||||
owners: ProjectSchemaOwners;
|
||||
admins: { name: string; imageUrl?: string }[];
|
||||
owners: PersonalDashboardSchemaProjectOwnersItem[];
|
||||
admins: PersonalDashboardSchemaAdminsItem[];
|
||||
};
|
||||
|
||||
export const ContentGridNoProjects: React.FC<Props> = ({ owners, admins }) => {
|
||||
@ -97,23 +98,37 @@ export const ContentGridNoProjects: React.FC<Props> = ({ owners, admins }) => {
|
||||
Contact Unleash admin
|
||||
</TitleContainer>
|
||||
<BoxMainContent>
|
||||
<p>
|
||||
Your Unleash administrator
|
||||
{admins.length > 1 ? 's are' : ' is'}:
|
||||
</p>
|
||||
<AdminList>
|
||||
{admins.map((admin) => (
|
||||
<AdminListItem key={admin.name}>
|
||||
<UserAvatar
|
||||
sx={{
|
||||
margin: 0,
|
||||
}}
|
||||
user={admin}
|
||||
/>
|
||||
<Typography>{admin.name}</Typography>
|
||||
</AdminListItem>
|
||||
))}
|
||||
</AdminList>
|
||||
{admins.length ? (
|
||||
<>
|
||||
<p>
|
||||
Your Unleash administrator
|
||||
{admins.length > 1 ? 's are' : ' is'}:
|
||||
</p>
|
||||
<AdminList>
|
||||
{admins.map((admin) => {
|
||||
return (
|
||||
<AdminListItem key={admin.id}>
|
||||
<UserAvatar
|
||||
sx={{
|
||||
margin: 0,
|
||||
}}
|
||||
user={admin}
|
||||
/>
|
||||
<Typography>
|
||||
{admin.name ||
|
||||
admin.username ||
|
||||
admin.email}
|
||||
</Typography>
|
||||
</AdminListItem>
|
||||
);
|
||||
})}
|
||||
</AdminList>
|
||||
</>
|
||||
) : (
|
||||
<p>
|
||||
You have no Unleash administrators to contact.
|
||||
</p>
|
||||
)}
|
||||
</BoxMainContent>
|
||||
</GridContent>
|
||||
</SpacedGridItem>
|
||||
@ -124,8 +139,20 @@ export const ContentGridNoProjects: React.FC<Props> = ({ owners, admins }) => {
|
||||
Ask a project owner to add you to their project
|
||||
</TitleContainer>
|
||||
<BoxMainContent>
|
||||
<p>Project owners in Unleash:</p>
|
||||
<AvatarGroupFromOwners users={owners} avatarLimit={9} />
|
||||
{owners.length ? (
|
||||
<>
|
||||
<p>Project owners in Unleash:</p>
|
||||
<AvatarGroupFromOwners
|
||||
users={owners}
|
||||
avatarLimit={9}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<p>
|
||||
There are no project owners in Unleash to ask
|
||||
for access.
|
||||
</p>
|
||||
)}
|
||||
</BoxMainContent>
|
||||
</GridContent>
|
||||
</SpacedGridItem>
|
||||
|
@ -227,17 +227,10 @@ export const PersonalDashboard = () => {
|
||||
) : null}
|
||||
</ScreenExplanation>
|
||||
|
||||
{noProjects ? (
|
||||
{noProjects && personalDashboard ? (
|
||||
<ContentGridNoProjects
|
||||
owners={[{ ownerType: 'system' }]}
|
||||
admins={[
|
||||
{ name: 'admin' },
|
||||
{
|
||||
name: 'Christopher Tompkins',
|
||||
imageUrl:
|
||||
'https://avatars.githubusercontent.com/u/1010371?v=4',
|
||||
},
|
||||
]}
|
||||
owners={personalDashboard.projectOwners}
|
||||
admins={personalDashboard.admins}
|
||||
/>
|
||||
) : (
|
||||
<ContentGrid container columns={{ lg: 12, md: 1 }}>
|
||||
|
@ -13,11 +13,11 @@ import type { PersonalDashboardSchemaProjectsItem } from './personalDashboardSch
|
||||
*/
|
||||
export interface PersonalDashboardSchema {
|
||||
/** Users with the admin role in Unleash. */
|
||||
admins?: PersonalDashboardSchemaAdminsItem[];
|
||||
admins: PersonalDashboardSchemaAdminsItem[];
|
||||
/** A list of flags a user created or favorited */
|
||||
flags: PersonalDashboardSchemaFlagsItem[];
|
||||
/** Users with the project owner role in Unleash. Only contains owners of projects that are visible to the user. */
|
||||
projectOwners?: PersonalDashboardSchemaProjectOwnersItem[];
|
||||
projectOwners: PersonalDashboardSchemaProjectOwnersItem[];
|
||||
/** A list of projects that a user participates in with any role e.g. member or owner or any custom role */
|
||||
projects: PersonalDashboardSchemaProjectsItem[];
|
||||
}
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
export type PersonalDashboardSchemaAdminsItem = {
|
||||
/** @nullable */
|
||||
email?: string | null;
|
||||
email?: string;
|
||||
/** The user ID. */
|
||||
id: number;
|
||||
/** @nullable */
|
||||
imageUrl?: string | null;
|
||||
imageUrl?: string;
|
||||
/** The user's name. */
|
||||
name?: string;
|
||||
/** The user's username. */
|
||||
|
@ -5,7 +5,7 @@ export const personalDashboardSchema = {
|
||||
type: 'object',
|
||||
description: 'Project and flags relevant to the user',
|
||||
additionalProperties: false,
|
||||
required: ['projects', 'flags'],
|
||||
required: ['projects', 'flags', 'admins', 'projectOwners'],
|
||||
properties: {
|
||||
admins: {
|
||||
type: 'array',
|
||||
@ -31,12 +31,10 @@ export const personalDashboardSchema = {
|
||||
},
|
||||
imageUrl: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
example: 'https://example.com/peek-at-you.jpg',
|
||||
},
|
||||
email: {
|
||||
type: 'string',
|
||||
nullable: true,
|
||||
example: 'user@example.com',
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user