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

feat(annotations): update mode if necessary for experiences #1375

Merged
merged 8 commits into from May 13, 2021
Merged

feat(annotations): update mode if necessary for experiences #1375

merged 8 commits into from May 13, 2021

Conversation

ghost
Copy link

@ghost ghost commented May 11, 2021

For Images in Preview, we noticed that the Region is default Selected.

  • We want to set the default selected to None, if this tooltip experience can show
    We also want the tooltip to close when you click on the mode button

Screen Shot 2021-05-11 at 9 26 12 AM

@ghost ghost self-requested a review as a code owner May 11, 2021 16:24
Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

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

I think we'll need to tie this into the "discoverability" conditions in both image and document annotators. Otherwise, the app could wind up in an inconsistent state. I'll reach out directly, as well.

Copy link
Collaborator

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

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

Do we need a change for DocBaseViewer, as well? Or any other viewers?

[true, false],
[false, true],
[false, false],
].forEach(([canShow, enableAnnotationsImageDiscoverability]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use test.each for this, instead?

src/lib/viewers/image/ImageViewer.js Show resolved Hide resolved
const { experiences = {} } = this.options;
const canShow = Object.values(experiences).some(experience => experience.canShow);

return !canShow && !!this.options[discoverabilityType];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're inside ImageViewer, can we bake the check for this.options.enableAnnotationsImageDiscoverability inside this method to avoid having to pass in a string?

};
image.options.enableAnnotationsImageDiscoverability = enableAnnotationsImageDiscoverability;

expect(image.isDiscoverabilityEnabled('enableAnnotationsImageDiscoverability')).toBe(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove the string parameter here?

Copy link
Author

Choose a reason for hiding this comment

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

oops, fixed!

jstoffan
jstoffan previously approved these changes May 12, 2021
* @return {boolean} value of whether discoverability is enabled for given type
*/
isDiscoverabilityEnabled() {
const { experiences = {} } = this.options;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could destructure enableAnnotationsImageDiscoverability here as well

*/
isDiscoverabilityEnabled() {
const { experiences = {} } = this.options;
const canShow = Object.values(experiences).some(experience => experience.canShow);
Copy link
Contributor

Choose a reason for hiding this comment

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

iirc, annotations is the only experience we're passing through right now, but should this be so generic? What happens if there is a new preview thumbnails siderail experience (which doesn't apply to images) would that prevent image discoverability?

Copy link
Author

Choose a reason for hiding this comment

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

@ConradJChan - That is a good point. I think it's most likely if any experience can show we would want to disable discoverability. I also think it would be more likely to forget to add than remember to add it, if we created some sort of eligible experiences list. I think it would make sense to address this, when the time comes, but open to make the suggested change. Let me know what you think!

Copy link
Author

Choose a reason for hiding this comment

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

I'll go ahead and merge this PR and we can make updates in a separate PR if needed!

};
image.options.enableAnnotationsImageDiscoverability = enableAnnotationsImageDiscoverability;

expect(image.isDiscoverabilityEnabled()).toBe(!canShow && !!enableAnnotationsImageDiscoverability);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of computing the expected result and embedding logic in the test, could it be passed in as a parameter?

@ghost ghost added the ready-to-merge label May 13, 2021
@mergify mergify bot merged commit a3eb40c into box:master May 13, 2021
@ghost ghost deleted the annotation-experience-updates branch May 14, 2021 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants