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

Add new config option for collections #1107

Merged
merged 7 commits into from
Oct 9, 2024

Conversation

Saira-A
Copy link
Contributor

@Saira-A Saira-A commented Sep 9, 2024

Description of what you did:

Added a new option called "defaultToTreeIfCollection" to the config so that the left panel defaults to Index rather than Thumbnails if the item is a collection, so the tree view of manifests within the collection is visible by default

Copy link

vercel bot commented Sep 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
universalviewer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 9, 2024 10:41am

Copy link
Contributor

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @Saira-A! Once again, I'm not hugely familiar with the code here, but I gave this enough of a look to raise some questions. I hope the suggestions are helpful; please feel free to disregard anything that turns out to be a bad idea. :-)

@@ -817,7 +830,7 @@ export class ContentLeftPanel extends LeftPanel<ContentLeftPanelConfig> {
let nodeFound: boolean = false;

allNodes.map((node) => {
if (node.isCollection() && node.data.index === collectionIndex) {
if (this.config.options.defaultToTreeIfCollection && node.isCollection() && node.data.index === collectionIndex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change necessary? This means that if defaultToTreeIfCollection is not set to true, the below behavior will be bypassed. Is that correct? I would think that regardless of default settings, collection-specific behavior would still apply... but maybe I don't fully understand the context.

this.isCollection() &&
this.config.options.defaultToTreeIfCollection
) {
this.$treeViewOptions.show();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to leverage the defaultToThumbsView method to reduce redundant logic here, or is there a reason that won't work? (I confess that I considered the possibility without digging deep enough into the code to determine whether or not it is a good idea).

If that's not feasible, maybe you could at least use:

if (
    this.isCollection &&
    (this.config.options.defaultToTreeIfCollection || this.extension.helper.treeHasNavDates(treeData))
) {

So you don't need to have two separate if/else clauses for showing the tree view options.

@Saira-A
Copy link
Contributor Author

Saira-A commented Sep 19, 2024

Thanks @demiankatz! I refactored it but I'm not sure about line 286 so let me know if there's a better way :)

@demiankatz
Copy link
Contributor

Thanks, @Saira-A! Regarding line 286, I think it would probably make sense to move the remaining logic inside defaultToThumbsView so the logic is consistent. Maybe you could change lines 622-624 to something like:

    // Default to tree view if the manifest is a collection and either the "default to tree if collection" setting is
    // on, or the tree has nav dates (which always require a tree):
    if (this.isCollection() && (defaultToTreeIfCollection || this.extension.helper.treeHasNavDates(treeData))) {
      return false;
    }

I'm not really familiar with the "nav dates" functionality, though, so I'm basing this suggestion on a logical refactoring of the code more than on direct experience with the intent behind the code... so please take my suggestion with the appropriate grain of salt.

Copy link
Contributor

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @Saira-A! This looks good to me now (though I haven't personally tested it); see below for some suggestions that might help clarify the relationships between the configuration settings. Feel free to accept, modify or ignore as you see fit. :-)

@Saira-A
Copy link
Contributor Author

Saira-A commented Oct 9, 2024

Makes sense, thanks @demiankatz!

Copy link
Contributor

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @Saira-A, I'm approving this so merging won't be blocked and because the logic makes sense to me -- but it would probably be a good idea to get some hands-on testing on this before merging it if anyone has time (assuming @LanieOkorodudu hasn't already done it). :-)

@LanieOkorodudu
Copy link
Collaborator

Thanks, @Saira-A, I'm approving this so merging won't be blocked and because the logic makes sense to me -- but it would probably be a good idea to get some hands-on testing on this before merging it if anyone has time (assuming @LanieOkorodudu hasn't already done it)

I just test it and it should be fine to merge @demiankatz

@demiankatz demiankatz merged commit 8e95f9f into UniversalViewer:dev Oct 9, 2024
2 checks passed
@demiankatz
Copy link
Contributor

Thanks, @LanieOkorodudu!

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