Skip to content

Commit

Permalink
fix(graph): restore behavior of proximity buttons (#13608)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Fulcher <philip@Philips-MacBook-Pro.local>
  • Loading branch information
philipjfulcher and Philip Fulcher committed Dec 5, 2022
1 parent 91c19f5 commit 76536fd
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 27 deletions.
48 changes: 48 additions & 0 deletions graph/client-e2e/src/e2e/dev-project-graph.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getImageDownloadButton,
getIncludeProjectsInPathButton,
getSearchDepthCheckbox,
getSearchDepthDecrementButton,
getSearchDepthIncrementButton,
getSelectAffectedButton,
getSelectAllButton,
Expand Down Expand Up @@ -113,6 +114,53 @@ describe('dev mode - project graph', () => {
});
});

describe('proximity', () => {
it('should change when increment/decrement button is clicked', () => {
cy.get('[data-cy="depth-value"]').should('contain', '1');
getSearchDepthIncrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '2');
getSearchDepthDecrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '1');
});

it("should reactivate proximity if it's disabled and a button is clicked", () => {
getSearchDepthIncrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '2');
getSearchDepthCheckbox()
.should('be.checked')
.click()
.should('not.be.checked')
.click();
getSearchDepthIncrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '3');
getSearchDepthCheckbox()
.should('be.checked')
.click()
.should('not.be.checked')
.click();
getSearchDepthDecrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '2');
getSearchDepthCheckbox()
.should('be.checked')
.click()
.should('not.be.checked')
.click();
// return to 1 for following tests
getSearchDepthDecrementButton().click();
});

it('should not go below 1', () => {
getSearchDepthIncrementButton().click();
getSearchDepthIncrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '3');
getSearchDepthDecrementButton().click();
getSearchDepthDecrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '1');
getSearchDepthDecrementButton().click();
cy.get('[data-cy="depth-value"]').should('contain', '1');
});
});

describe('select all button', () => {
it('should check all project items', () => {
getSelectAllButton().scrollIntoView().click({ force: true });
Expand Down
50 changes: 23 additions & 27 deletions graph/client/src/app/feature-projects/projects-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,34 +120,30 @@ export function ProjectsSidebar(): JSX.Element {
}

function incrementDepthFilter() {
if (searchDepthInfo.searchDepthEnabled) {
const newSearchDepth = searchDepthInfo.searchDepth + 1;
setSearchParams((currentSearchParams) => {
if (newSearchDepth === 1) {
currentSearchParams.delete('searchDepth');
} else {
currentSearchParams.set('searchDepth', newSearchDepth.toString());
}

return currentSearchParams;
});
}
const newSearchDepth = searchDepthInfo.searchDepth + 1;
setSearchParams((currentSearchParams) => {
if (newSearchDepth === 1) {
currentSearchParams.delete('searchDepth');
} else {
currentSearchParams.set('searchDepth', newSearchDepth.toString());
}

return currentSearchParams;
});
}

function decrementDepthFilter() {
if (searchDepthInfo.searchDepthEnabled) {
const newSearchDepth =
searchDepthInfo.searchDepth === 0 ? 0 : searchDepthInfo.searchDepth - 1;
setSearchParams((currentSearchParams) => {
if (newSearchDepth === 1) {
currentSearchParams.delete('searchDepth');
} else {
currentSearchParams.set('searchDepth', newSearchDepth.toString());
}

return currentSearchParams;
});
}
const newSearchDepth =
searchDepthInfo.searchDepth === 1 ? 1 : searchDepthInfo.searchDepth - 1;
setSearchParams((currentSearchParams) => {
if (newSearchDepth === 1) {
currentSearchParams.delete('searchDepth');
} else {
currentSearchParams.set('searchDepth', newSearchDepth.toString());
}

return currentSearchParams;
});
}

function resetTextFilter() {
Expand Down Expand Up @@ -250,12 +246,12 @@ export function ProjectsSidebar(): JSX.Element {
if (searchParams.has('searchDepth')) {
const parsedValue = parseInt(searchParams.get('searchDepth'), 10);

if (parsedValue === 0) {
if (parsedValue === 0 && searchDepthInfo.searchDepthEnabled !== false) {
projectGraphService.send({
type: 'setSearchDepthEnabled',
searchDepthEnabled: false,
});
} else {
} else if (parsedValue !== 0) {
projectGraphService.send({
type: 'setSearchDepth',
searchDepth: parsedValue,
Expand Down

1 comment on commit 76536fd

@vercel
Copy link

@vercel vercel bot commented on 76536fd Dec 5, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.