GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Hide share button in TreeViewBase if user does not have permissions t… by taoerman · Pull Request #5550 · learningequality/studio

Conversation

@taoerman

@taoerman taoerman commented Nov 12, 2025

Copy link
Copy Markdown
Contributor

…o see any option

Summary

Fixes issue by hiding the Share button in TreeViewBase when the user cannot use any share options.

Added canShareChannel (returns true if canManage or isPublished) to control button visibility.

Added CanSubmitToCommunityLibrary to control the "Submit to community library" menu item.

The Share button now renders only when at least one option is available (invite collaborators, share token, or submit to community library), and each menu item is conditionally shown based on permissions.

Added tests covering computed properties, button visibility, and menu item visibility across permission and channel state combinations.

References

Fixed #5453

Reviewer guidance

Run unit tests or Test manually.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
taoerman and others added 3 commits November 11, 2025 16:09
@taoerman
Hide share button in TreeViewBase if user does not have permissions t…
82a0c1b
…o see any option
@pre-commit-ci-lite
[pre-commit.ci lite] apply automatic fixes
90c40e8
@taoerman
fix linting
21852a9
AlexVelezLl
AlexVelezLl requested changes Nov 12, 2025
View reviewed changes

@AlexVelezLl AlexVelezLl left a comment

Copy link
Copy Markdown
Member

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.

Everything looks good with the production code! Just one little comment to make tests a little bit easier to read, and to prevent ourselves from having to make a lot of updates on these tests when we update this component to KDS.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread ...tcuration/contentcuration/frontend/channelEdit/views/TreeView/__tests__/TreeViewBase.spec.js
Comment on lines +123 to +182
stubs: {
ToolBar: {
template: '<div><slot /><slot name="extension" /></div>',
},
MainNavigationDrawer: true,
PublishSidePanel: true,
SubmitToCommunityLibrarySidePanel: true,
ProgressModal: true,
ChannelTokenModal: true,
SyncResourcesModal: true,
Clipboard: true,
OfflineText: true,
ContentNodeIcon: true,
DraggablePlaceholder: true,
MessageDialog: true,
SavingIndicator: true,
QuickEditModal: true,
BaseMenu: {
name: 'BaseMenu',
template:
'<div><slot name="activator" :on="{}" /><div class="menu-content"><slot /></div></div>',
},
KButton: {
template: '<button class="share-button"><slot /></button>',
},
VList: {
template: '<div class="v-list"><slot /></div>',
},
VListTile: {
template: '<div class="v-list-tile"><slot /></div>',
},
VListTileTitle: {
template: '<div class="v-list-tile-title"><slot /></div>',
},
},
});
};

const getShareButton = wrapper => {
const allBaseMenus = wrapper.findAllComponents({ name: 'BaseMenu' });
for (let i = 0; i < allBaseMenus.length; i++) {
const baseMenu = allBaseMenus.at(i);
const shareButton = baseMenu.find('.share-button');
if (shareButton.exists()) {
return shareButton;
}
}
return { exists: () => false };
};
const getShareMenuItems = wrapper => {
const allBaseMenus = wrapper.findAllComponents({ name: 'BaseMenu' });
for (let i = 0; i < allBaseMenus.length; i++) {
const baseMenu = allBaseMenus.at(i);
const shareButton = baseMenu.find('.share-button');
if (shareButton.exists()) {
return baseMenu.findAll('.v-list-tile');
}
}
return { length: 0, wrappers: [] };
};

@AlexVelezLl AlexVelezLl Nov 12, 2025

Copy link
Copy Markdown
Member

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.

Although stubbing these components may make the tests run faster, I don't think we need to stub every child/descendant component. For example, I don't think we may need to stub presentational components like the VList, VListTile, VListTileTitle, etc. And components like KButton neither. I think we can perhaps just stub some components for which setting up the environment for them to work properly is not worth it, e.g. the QuickEditModal component.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@taoerman taoerman Nov 12, 2025

Copy link
Copy Markdown
Contributor Author

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.

Thanks Alex, I've fixed the code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@taoerman
fix test file
a7287be
AlexVelezLl
AlexVelezLl approved these changes Nov 12, 2025
View reviewed changes

@AlexVelezLl AlexVelezLl left a comment

Copy link
Copy Markdown
Member

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.

Lgtm!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@AlexVelezLl
AlexVelezLl merged commit d9f08c3 into learningequality:unstable Nov 12, 2025
AllanOXDi pushed a commit to AllanOXDi/studio that referenced this pull request Nov 20, 2025
@taoerman @pre-commit-ci-lite @AllanOXDi
Hide share button in TreeViewBase if user does not have permissions t… (
6174c7e
learningequality#5550)

* Hide share button in TreeViewBase if user does not have permissions to see any option

* [pre-commit.ci lite] apply automatic fixes

* fix linting

* fix test file

---------

Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AlexVelezLl AlexVelezLl AlexVelezLl approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Hide share button in TreeViewBase if user does not have permissions to see any option

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@taoerman @AlexVelezLl
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.