Add front component widget (#17440)
Modified the data model and introduced a seed to introduce front components widgets.
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql';
|
||||
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
@ObjectType('FrontComponentCode')
|
||||
export class FrontComponentCodeDTO {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@Field()
|
||||
sourceCode: string;
|
||||
}
|
||||
+13
@@ -10,6 +10,7 @@ import { NoPermissionGuard } from 'src/engine/guards/no-permission.guard';
|
||||
import { SettingsPermissionGuard } from 'src/engine/guards/settings-permission.guard';
|
||||
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
|
||||
import { CreateFrontComponentInput } from 'src/engine/metadata-modules/front-component/dtos/create-front-component.input';
|
||||
import { FrontComponentCodeDTO } from 'src/engine/metadata-modules/front-component/dtos/front-component-code.dto';
|
||||
import { FrontComponentDTO } from 'src/engine/metadata-modules/front-component/dtos/front-component.dto';
|
||||
import { UpdateFrontComponentInput } from 'src/engine/metadata-modules/front-component/dtos/update-front-component.input';
|
||||
import { FrontComponentService } from 'src/engine/metadata-modules/front-component/front-component.service';
|
||||
@@ -42,6 +43,18 @@ export class FrontComponentResolver {
|
||||
return await this.frontComponentService.findById(id, workspace.id);
|
||||
}
|
||||
|
||||
@Query(() => FrontComponentCodeDTO)
|
||||
@UseGuards(NoPermissionGuard)
|
||||
async getFrontComponentCode(
|
||||
@Args('id', { type: () => UUIDScalarType }) id: string,
|
||||
@AuthWorkspace() workspace: WorkspaceEntity,
|
||||
): Promise<FrontComponentCodeDTO> {
|
||||
return await this.frontComponentService.getFrontComponentCode(
|
||||
id,
|
||||
workspace.id,
|
||||
);
|
||||
}
|
||||
|
||||
@Mutation(() => FrontComponentDTO)
|
||||
@UseGuards(SettingsPermissionGuard(PermissionFlagType.APPLICATIONS))
|
||||
async createFrontComponent(
|
||||
|
||||
+11
@@ -11,6 +11,7 @@ import { fromDeleteFrontComponentInputToFlatFrontComponentOrThrow } from 'src/en
|
||||
import { fromFlatFrontComponentToFrontComponentDto } from 'src/engine/metadata-modules/flat-front-component/utils/from-flat-front-component-to-front-component-dto.util';
|
||||
import { fromUpdateFrontComponentInputToFlatFrontComponentToUpdateOrThrow } from 'src/engine/metadata-modules/flat-front-component/utils/from-update-front-component-input-to-flat-front-component-to-update-or-throw.util';
|
||||
import { type CreateFrontComponentInput } from 'src/engine/metadata-modules/front-component/dtos/create-front-component.input';
|
||||
import { type FrontComponentCodeDTO } from 'src/engine/metadata-modules/front-component/dtos/front-component-code.dto';
|
||||
import { type FrontComponentDTO } from 'src/engine/metadata-modules/front-component/dtos/front-component.dto';
|
||||
import { type UpdateFrontComponentInput } from 'src/engine/metadata-modules/front-component/dtos/update-front-component.input';
|
||||
import {
|
||||
@@ -234,4 +235,14 @@ export class FrontComponentService {
|
||||
|
||||
return frontComponent;
|
||||
}
|
||||
|
||||
async getFrontComponentCode(
|
||||
_id: string,
|
||||
_workspaceId: string,
|
||||
): Promise<FrontComponentCodeDTO> {
|
||||
// TODO: get the source code from the front component here, we will implement a mock version for now
|
||||
const sourceCode = '';
|
||||
|
||||
return { sourceCode };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user