Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 5326 - Add view support for comments #5383

Open
wants to merge 20 commits into
base: staging
Choose a base branch
from
Open

Conversation

Bogdan-Crn
Copy link
Contributor

This fixes #5326

Description

This PR adds the capability of users to add a viewpoint to comments.
The viewpoint is not mandatory and is similar to the view property type, however it does not accept screenshots since you can add an image.
Added check to ensure the ticket allows comments - if not it will throw a 400 Invalid Arguments
On update comment path added middleware to ensure the comment updated exists.

Test cases

Updated unit and e2e tests to reflect the changes.

@Bogdan-Crn Bogdan-Crn marked this pull request as ready for review February 6, 2025 16:15
@ChristosTsiotsias
Copy link
Contributor

ChristosTsiotsias commented Feb 14, 2025

I think updateComment and deleteComment methods should also be updated to unset view if its not provided and also include it in the event

image

@@ -40,7 +42,9 @@ const generateCommentSchema = (existingComment, isImport = false) => {
.test('Image ref test', 'One or more image refs do not correspond to a current comment image ref',
(value, { originalValue }) => !isUUIDString(originalValue)
|| acceptableRefs.includes(originalValue)),
) };
),
views: Validators.propTypesToValidator(propTypes.VIEW, !isNewComment, true, true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

views implies that there may be more than one (as it happens with images) I would probably name it view or viewpoint

Copy link
Contributor

@ChristosTsiotsias ChristosTsiotsias Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you make sure you update swagger in backend\src\v5\routes\teamspaces\projects\models\common\tickets.js ?

@@ -252,7 +252,7 @@ const testGetCommentsList = () => {
const testCreateComment = () => {
describe('Create comment', () => {
const { users, teamspace, project, con, fed } = generateBasicData();
const template = ServiceHelper.generateTemplate();
const template = ServiceHelper.generateTemplate(false, false, { comments: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could add a test to make sure we cant create comments on tickets that dont allow it (good catch btw)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. this comment is unresolved, is it still outstanding?

},
clippingPlanes: [],
};
const invalidViewComment = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just do { ... viewComment, screenshot: [existingRef2], }

Copy link
Contributor

@ChristosTsiotsias ChristosTsiotsias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just a couple of comments that werent addressed

Copy link
Member

@carmenfan carmenfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tagging this here as it's the most relevant place, but it's not actually a change for this file.

You need to update the processor to process the groups within the view. Take a look at how the ticket side handling groups in views, we have to save them into groups separated to the comment (otherwise we risk overloading the bson), and a reference to the group is stored in the view instead.

@@ -200,6 +200,204 @@ const establishRoutes = (isFed) => {
* format: uuid
* description: The Id of the comment image
* example: ef0855b6-4cc7-4be1-b2d6-c032dce7806a
* view:
* description: Spacial coordinates for the comment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not an accurate description, as that would probably better describe a pin in 3D Space

It's more like storing the state of the viewer representing what the commenter was seeing

* type: object
* properties:
* camera:
* description: Details about the position and type of view
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also would reword... this describe the 3D camera's position, orientation and projection

* properties:
* position:
* type: array
* description: Contains the X, Y, Z coordinates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone who's doing this via API should know waht a camera is in 3D graphics, anyone who don't would be pretty clueless as to what you're describing here.

So either we can skip these details, or we need to be more speific.

position is the coordinates of the camera and up/forward are the directional vectors.

type can only be orthographic or perspectiive.

* type: string
* description: The type of camera view
* clippingPlanes:
* description: Some text
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some text is probably a bit too unclear 😆

* type: array
* items:
* type: string
* transformed:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this one

It's not something we want to encourage users to actively use.

@@ -337,6 +535,204 @@ const establishRoutes = (isFed) => {
* format: uuid
* description: The Id of the comment image
* example: ef0855b6-4cc7-4be1-b2d6-c032dce7806a
* view:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider the amount of copy and paste it's probably better to move it to the schema file and reference it https://github.com/3drepo/3drepo.io/blob/master/backend/src/v5/services/swagger/swagger.schemas.js

@@ -428,6 +428,204 @@ const establishRoutes = (isFed) => {
* items:
* type: string
* description: Image in a Base64 format or an ID of an image currently used in the comment
* view:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here

@@ -769,6 +967,204 @@ const establishRoutes = (isFed) => {
* items:
* type: string
* description: Image in a Base64 format or an ID of an image currently used in the comment
* view:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

state,
camera: !isUpdate && required ? camera.required() : camera,
clippingPlanes,
}).default(undefined);

if (!isComment) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it's clearer if we do this before we turn it into a yup object

i.e.

Suggested change
if (!isComment) {
const schema = {
//...
state,
camera: !isUpdate && required ? camera.required() : camera,
clippingPlanes,
}
if(!isComment) {
schema.screenshot = types.embeddedImage(isUpdate)
}
return imposeNullableRule(Yup.object(schema).default(undefined));

@@ -252,7 +252,7 @@ const testGetCommentsList = () => {
const testCreateComment = () => {
describe('Create comment', () => {
const { users, teamspace, project, con, fed } = generateBasicData();
const template = ServiceHelper.generateTemplate();
const template = ServiceHelper.generateTemplate(false, false, { comments: true });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. this comment is unresolved, is it still outstanding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants