-
Notifications
You must be signed in to change notification settings - Fork 40
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
base: staging
Are you sure you want to change the base?
Conversation
…nto ISSUE_5326
…nto ISSUE_5326
@@ -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), |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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], }
.../middleware/dataConverter/inputs/teamspaces/projects/models/commons/tickets.comments.test.js
Outdated
Show resolved
Hide resolved
.../middleware/dataConverter/inputs/teamspaces/projects/models/commons/tickets.comments.test.js
Outdated
Show resolved
Hide resolved
backend/src/v5/routes/teamspaces/projects/models/common/tickets.comments.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
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 }); |
There was a problem hiding this comment.
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?
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.