Skip to content

Commit

Permalink
BACKLOG-23211 Fix repo explorer context action permission (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
r3dm1ke authored Oct 9, 2024
1 parent 353c120 commit fc7e562
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import PropTypes from 'prop-types';

export const OpenInRepositoryExplorerActionComponent = ({path, render: Render, loading: Loading, ...others}) => {
const res = useNodeChecks({path}, {
showOnNodeTypes: ['nt:base'],
showOnNodeTypes: ['nt:base']
});
const rootRes = useNodeChecks({path: '/'}, {
requiredPermission: 'repositoryExplorer'
});
if (res.loading && Loading) {

if ((rootRes.loading || res.loading) && Loading) {
return <Loading {...others}/>;
}

if (!res.node) {
if (!res.node || !rootRes.node) {
return (<Render {...others} isVisible={false}/>);
}

Expand All @@ -20,8 +23,8 @@ export const OpenInRepositoryExplorerActionComponent = ({path, render: Render, l

return (
<Render {...others}
isVisible={res.checksResult}
enabled={res.checksResult}
isVisible={res.checksResult && rootRes.checksResult}
enabled={res.checksResult && rootRes.checksResult}
onClick={() => {
window.open(url);
}}
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/e2e/menuActions/openInRepoExplorer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import gql from 'graphql-tag';
describe('Open in repo explorer tests', () => {
let expectedUrl = null;
before(() => {
cy.loginAndStoreSession(); // Edit in chief
cy.loginAndStoreSession('root', 'root1234');
cy.apollo({
query: gql`
query {
Expand Down

0 comments on commit fc7e562

Please sign in to comment.