Lucas/t 365 on comment drawer i see a add comment section with severa (#256)
* Added comments and authors on drawer with proper resolving * Fixed generated front graphql from rebase * Fixed comment chip * wip * wip 2 * - Added string typing for DateTime scalar - Refactored user in a recoil state and workspace using it - Added comment creation * Put theme and user state in generic providers * Fix from rebase * Fixed app theme provider removed from storybook * Wip * Fix graphql front * Fixed backend bug * - Added comment fetching in creation mode - Fixed drawer overflows and heights * - Fixed autosize validation button CSS bug * Fixed CSS bug with drawer changing height if overflow * Fixed text input too many event catched and useless error message * Removed console.log * Fixed comment cell chip * Create comment thread on each comment action bar click * Fixed lint * Fixed TopBar height
This commit is contained in:
@ -32,13 +32,48 @@ export class CommentThreadResolver {
|
||||
...{ workspaceId: workspace.id },
|
||||
}))
|
||||
: [];
|
||||
return this.prismaService.commentThread.create({
|
||||
|
||||
const createdCommentThread = await this.prismaService.commentThread.create({
|
||||
data: {
|
||||
...args.data,
|
||||
...{ commentThreadTargets: undefined },
|
||||
...{ comments: { createMany: { data: newCommentData } } },
|
||||
...{ workspace: { connect: { id: workspace.id } } },
|
||||
},
|
||||
});
|
||||
|
||||
if (args.data.commentThreadTargets?.createMany?.data) {
|
||||
await this.prismaService.commentThreadTarget.createMany({
|
||||
data: args.data.commentThreadTargets?.createMany?.data?.map(
|
||||
(target) => ({
|
||||
...target,
|
||||
commentThreadId: args.data.id,
|
||||
}),
|
||||
),
|
||||
skipDuplicates:
|
||||
args.data.commentThreadTargets?.createMany?.skipDuplicates ?? false,
|
||||
});
|
||||
|
||||
return await this.prismaService.commentThread.update({
|
||||
where: { id: args.data.id },
|
||||
data: {
|
||||
commentThreadTargets: {
|
||||
connect: args.data.commentThreadTargets?.connect,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return createdCommentThread;
|
||||
|
||||
// return this.prismaService.commentThread.create({
|
||||
// data: {
|
||||
// ...args.data,
|
||||
// ...{ commentThreadTargets: undefined },
|
||||
// ...{ comments: { createMany: { data: newCommentData } } },
|
||||
// ...{ workspace: { connect: { id: workspace.id } } },
|
||||
// },
|
||||
// });
|
||||
}
|
||||
|
||||
@Query(() => [CommentThread])
|
||||
|
||||
@ -14,12 +14,13 @@ export class CreateOneCommentThreadGuard implements CanActivate {
|
||||
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
const gqlContext = GqlExecutionContext.create(context);
|
||||
// TODO: type request
|
||||
const request = gqlContext.getContext().req;
|
||||
const args = gqlContext.getArgs();
|
||||
|
||||
const targets = args.data?.commentThreadTargets?.createMany?.data;
|
||||
const comments = args.data?.comments?.createMany?.data;
|
||||
const workspaceId = await request.workspace;
|
||||
const workspace = await request.workspace;
|
||||
|
||||
if (!targets || targets.length === 0) {
|
||||
throw new HttpException(
|
||||
@ -52,7 +53,7 @@ export class CreateOneCommentThreadGuard implements CanActivate {
|
||||
where: { id: target.commentableId },
|
||||
});
|
||||
|
||||
if (!targetEntity || targetEntity.workspaceId !== workspaceId) {
|
||||
if (!targetEntity || targetEntity.workspaceId !== workspace.id) {
|
||||
throw new HttpException(
|
||||
{ reason: 'CommentThreadTarget not found' },
|
||||
HttpStatus.NOT_FOUND,
|
||||
@ -90,10 +91,10 @@ export class CreateOneCommentThreadGuard implements CanActivate {
|
||||
|
||||
if (
|
||||
!userWorkspaceMember ||
|
||||
userWorkspaceMember.workspaceId !== workspaceId
|
||||
userWorkspaceMember.workspaceId !== workspace.id
|
||||
) {
|
||||
throw new HttpException(
|
||||
{ reason: 'Comment.authorId not found' },
|
||||
{ reason: 'userWorkspaceMember.workspaceId not found' },
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ export class UpdateOneGuard implements CanActivate {
|
||||
const entity = gqlContext.getArgByIndex(3).returnType?.name;
|
||||
const args = gqlContext.getArgs();
|
||||
|
||||
console.log(args.data);
|
||||
if (!entity || !args.where?.id) {
|
||||
throw new HttpException(
|
||||
{ reason: 'Invalid Request' },
|
||||
|
||||
Reference in New Issue
Block a user