mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: personal dashboard project details API stub (#8282)
This commit is contained in:
parent
d161fb49ee
commit
4107e84f43
@ -175,3 +175,15 @@ test('should return projects where users are part of a group', async () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test('should return personal dashboard project details', async () => {
|
||||
await loginUser('new_user@test.com');
|
||||
const { body } = await app.request.get(
|
||||
`/api/admin/personal-dashboard/default`,
|
||||
);
|
||||
|
||||
expect(body).toMatchObject({
|
||||
owners: [{}],
|
||||
roles: [{}],
|
||||
});
|
||||
});
|
||||
|
@ -10,8 +10,10 @@ import Controller from '../../routes/controller';
|
||||
import type { Response } from 'express';
|
||||
import type { IAuthRequest } from '../../routes/unleash-types';
|
||||
import type { PersonalDashboardService } from './personal-dashboard-service';
|
||||
|
||||
const PATH = '';
|
||||
import {
|
||||
personalDashboardProjectDetailsSchema,
|
||||
type PersonalDashboardProjectDetailsSchema,
|
||||
} from '../../openapi/spec/personal-dashboard-project-details-schema';
|
||||
|
||||
export default class PersonalDashboardController extends Controller {
|
||||
private openApiService: OpenApiService;
|
||||
@ -34,7 +36,7 @@ export default class PersonalDashboardController extends Controller {
|
||||
|
||||
this.route({
|
||||
method: 'get',
|
||||
path: PATH,
|
||||
path: '',
|
||||
handler: this.getPersonalDashboard,
|
||||
permission: NONE,
|
||||
middleware: [
|
||||
@ -51,6 +53,28 @@ export default class PersonalDashboardController extends Controller {
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
this.route({
|
||||
method: 'get',
|
||||
path: '/:projectId',
|
||||
handler: this.getPersonalDashboardProjectDetails,
|
||||
permission: NONE,
|
||||
middleware: [
|
||||
openApiService.validPath({
|
||||
tags: ['Unstable'],
|
||||
summary: 'Get personal project details',
|
||||
description:
|
||||
'Return personal dashboard project events, owners, user roles and onboarding status',
|
||||
operationId: 'getPersonalDashboardProjectDetails',
|
||||
responses: {
|
||||
200: createResponseSchema(
|
||||
'personalDashboardProjectDetailsSchema',
|
||||
),
|
||||
...getStandardResponses(401, 403, 404),
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
async getPersonalDashboard(
|
||||
@ -73,4 +97,21 @@ export default class PersonalDashboardController extends Controller {
|
||||
{ projects, flags },
|
||||
);
|
||||
}
|
||||
|
||||
async getPersonalDashboardProjectDetails(
|
||||
req: IAuthRequest<{ projectId: string }>,
|
||||
res: Response<PersonalDashboardProjectDetailsSchema>,
|
||||
): Promise<void> {
|
||||
const user = req.user;
|
||||
|
||||
this.openApiService.respondWithValidation(
|
||||
200,
|
||||
res,
|
||||
personalDashboardProjectDetailsSchema.$id,
|
||||
{
|
||||
owners: [{ ownerType: 'user', name: 'placeholder' }],
|
||||
roles: [{ name: 'placeholder', id: 0, type: 'project' }],
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,7 @@ export * from './patch-schema';
|
||||
export * from './patches-schema';
|
||||
export * from './pats-schema';
|
||||
export * from './permission-schema';
|
||||
export * from './personal-dashboard-project-details-schema';
|
||||
export * from './personal-dashboard-schema';
|
||||
export * from './playground-constraint-schema';
|
||||
export * from './playground-feature-schema';
|
||||
|
@ -0,0 +1,49 @@
|
||||
import type { FromSchema } from 'json-schema-to-ts';
|
||||
import { projectSchema } from './project-schema';
|
||||
|
||||
export const personalDashboardProjectDetailsSchema = {
|
||||
$id: '#/components/schemas/personalDashboardProjectDetailsSchema',
|
||||
type: 'object',
|
||||
description: 'Project details in personal dashboard',
|
||||
additionalProperties: false,
|
||||
required: ['owners', 'roles'],
|
||||
properties: {
|
||||
owners: projectSchema.properties.owners,
|
||||
roles: {
|
||||
type: 'array',
|
||||
description: 'The list of roles that the user has in this project.',
|
||||
minItems: 1,
|
||||
items: {
|
||||
type: 'object',
|
||||
description: 'An Unleash role.',
|
||||
additionalProperties: false,
|
||||
required: ['name', 'id', 'type'],
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
example: 'Owner',
|
||||
description: 'The name of the role',
|
||||
},
|
||||
id: {
|
||||
type: 'integer',
|
||||
example: 4,
|
||||
description: 'The id of the role',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: ['custom', 'project', 'root', 'custom-root'],
|
||||
example: 'project',
|
||||
description: 'The type of the role',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
schemas: {},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export type PersonalDashboardProjectDetailsSchema = FromSchema<
|
||||
typeof personalDashboardProjectDetailsSchema
|
||||
>;
|
@ -1,5 +1,4 @@
|
||||
import type { FromSchema } from 'json-schema-to-ts';
|
||||
import { projectSchema } from './project-schema';
|
||||
|
||||
export const personalDashboardSchema = {
|
||||
$id: '#/components/schemas/personalDashboardSchema',
|
||||
@ -47,42 +46,6 @@ export const personalDashboardSchema = {
|
||||
example: 10,
|
||||
description: 'The number of features this project has',
|
||||
},
|
||||
owners: projectSchema.properties.owners,
|
||||
roles: {
|
||||
type: 'array',
|
||||
description:
|
||||
'The list of roles that the user has in this project.',
|
||||
minItems: 1,
|
||||
items: {
|
||||
type: 'object',
|
||||
description: 'An Unleash role.',
|
||||
additionalProperties: false,
|
||||
required: ['name', 'id', 'type'],
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
example: 'Owner',
|
||||
description: 'The name of the role',
|
||||
},
|
||||
id: {
|
||||
type: 'integer',
|
||||
example: 4,
|
||||
description: 'The id of the role',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: [
|
||||
'custom',
|
||||
'project',
|
||||
'root',
|
||||
'custom-root',
|
||||
],
|
||||
example: 'project',
|
||||
description: 'The type of the role',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
description:
|
||||
|
Loading…
Reference in New Issue
Block a user