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

[Services map] Update redirection/Focus field rework #2264

Merged
merged 30 commits into from
Dec 10, 2024

Conversation

TackAdam
Copy link
Collaborator

@TackAdam TackAdam commented Nov 27, 2024

Demo:

ServiceMap.mp4

Description

Updated the focus field to no longer apply a filter, it now just renders the connected services and allows the user to investigate using the focus window. The drop down now reflects the connected viewable services to switch to. The reset icon now clears the existing filter if it matches the focus field and is currently applied. The focus field is now disabled while a filter of an existing service is active.

Screen.Recording.2024-12-02.at.9.46.22.AM.mov

Clicking a service currently causes the title clicked to be set as a filter.

Screen.Recording.2024-11-27.at.10.53.01.AM.mov

Updated behavior now re-directs the user to the corresponding service view page

Screen.Recording.2024-11-27.at.10.54.14.AM.mov

Issues Resolved

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@TackAdam TackAdam added backport 2.x enhancement New feature or request labels Nov 27, 2024
@TackAdam TackAdam marked this pull request as ready for review December 2, 2024 17:48
@TackAdam TackAdam changed the title Services update redirection [Services map] Update redirection/Focus field rework Dec 2, 2024
Comment on lines 80 to 88
let serviceId: string | null = null;

try {
const location = useLocation();
const params = new URLSearchParams(location?.search || '');
serviceId = params.get('serviceId');
} catch (error) {
serviceId = null;
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we use hooks and state here to make it cleaner?

  const location = useLocation();

  useEffect(() => {
    try {
      const params = new URLSearchParams(location.search);
      const id = params.get('serviceId');
      setServiceId(id);
    } catch (error) {
      setServiceId(null);
    }
  }, [location]);

Copy link
Collaborator Author

@TackAdam TackAdam Dec 3, 2024

Choose a reason for hiding this comment

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

Location is causing the service view page to not render as it is not defined, so it needs to be within the "Try".
And the useLocation component cannot be called inside a React Hook.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Josh helped find the issue


Fly-out was not inside the HashRouter.

Adam Tackett added 2 commits December 2, 2024 16:37
Signed-off-by: Adam Tackett <[email protected]>
filters: FilterType[];
setFilters:
| React.Dispatch<React.SetStateAction<FilterType[]>>
| ((filters: FilterType[]) => void);
Copy link
Member

Choose a reason for hiding this comment

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

curious why are both needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thought i needed to cover other conditions, removed it and seems to work fine.
Thanks

ticks,
service,
serviceMap[service]?.relatedServices,
true // Enable filtering to focus on connected nodes
Copy link
Member

Choose a reason for hiding this comment

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

i didn't look into getServiceMapGraph, but seems service and serviceMap[service]?.relatedServices are used for filtering, and they will be absent if we don't want filtering. Then is this boolean required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The focus functionality is not applying a filter so for the new experience these are required to change the options that show up using the focus functionality.

Without:

Screen.Recording.2024-12-04.at.11.13.22.AM.mov

With:

Screen.Recording.2024-12-04.at.11.14.01.AM.mov

serviceMap[currService!]?.relatedServices,
filterByCurrService
showRelatedServices
)
);
}, [serviceMap, idSelected]);
Copy link
Member

Choose a reason for hiding this comment

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

do we need focusedService and filterByCurrService in dependency array?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't believe so

Screen.Recording.2024-12-04.at.11.17.18.AM.mov

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should include every dependency in the dependency array even if it seems to pointlessly re-render as to avoid 'stale' states that might lead to bugs that would be difficult to fix.
React useEffect doc: https://react.dev/reference/react/useEffect

let serviceId: string | null = null;

try {
const location = useLocation();
Copy link
Member

Choose a reason for hiding this comment

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

Location is causing the service view page to not render as it is not defined, so it needs to be within the "Try".

do you have more details on what the error is? is it happening when calling useLocation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved with moving the flyout component into router.

@@ -76,6 +77,18 @@ export function ServiceView(props: ServiceViewProps) {
const [redirect, setRedirect] = useState(false);
const [actionsMenuPopover, setActionsMenuPopover] = useState(false);

let serviceId: string | null = null;
Copy link
Member

Choose a reason for hiding this comment

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

should this be a state?

Copy link
Member

@ps48 ps48 Dec 4, 2024

Choose a reason for hiding this comment

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

➕1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to a state.

jest.mock('../../../../../../test/__mocks__/coreMocks', () => ({
coreStartMock: {
chrome: { setBreadcrumbs: jest.fn() },
http: { post: jest.fn() },
Copy link
Member

Choose a reason for hiding this comment

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

Can we please add mocks with some actual data (both empty and non-empty response)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cypress added for service map
Tests focus functionality in Service map
Testing the re-renders and filtering

Added
import toJson from 'enzyme-to-json';
To service map test

@TackAdam
Copy link
Collaborator Author

TackAdam commented Dec 6, 2024

Updated applications to no longer filter on name click. Instead it opens the fly-out for details. Also removed the actions column when in the applications page.

Screen.Recording.2024-12-06.at.11.25.15.AM.mov

@ps48
Copy link
Member

ps48 commented Dec 6, 2024

Updated applications to no longer filter on name click. Instead it opens the fly-out for details. Also removed the actions column when in the applications page.
Screen.Recording.2024-12-06.at.11.25.15.AM.mov

Does the Applications trace navigation work as expected?

@TackAdam
Copy link
Collaborator Author

TackAdam commented Dec 6, 2024

Updated applications to no longer filter on name click. Instead it opens the fly-out for details. Also removed the actions column when in the applications page.
Screen.Recording.2024-12-06.at.11.25.15.AM.mov

Does the Applications trace navigation work as expected?

Clicking Trace applies the filter and switches to the Traces and Spans tab.

Screen.Recording.2024-12-06.at.1.30.04.PM.mov

const wrapper = mount(<ServiceMap {...defaultProps} />);
expect(wrapper).toMatchSnapshot();
wrapper.update();

Copy link
Member

Choose a reason for hiding this comment

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

Should we wait for the canvas to appear, so that map renders in the snapshot?

@ps48
Copy link
Member

ps48 commented Dec 6, 2024

Also, looks like this test 1) "before each" hook for "Verifies tree view expand arrow functionality" is flaky we should solve this preferably now or in a follow up PR.

@ps48
Copy link
Member

ps48 commented Dec 7, 2024

I see one failure in test because the nodes changes position. We do have a set seed which makes sure the graph has nodes on the position. Need to check what's causing the change cc: @TackAdam

Adam Tackett added 2 commits December 7, 2024 12:33
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
@TackAdam
Copy link
Collaborator Author

TackAdam commented Dec 7, 2024

I see one failure in test because the nodes changes position. We do have a set seed which makes sure the graph has nodes on the position. Need to check what's causing the change cc: @TackAdam

The position is consistent but it seems cypress environment used here might be causing the physics to behave slightly different than we see testing locally on original layout. As the point of this test is to ensure the canvas is rendering the nodes my solution is to first focus on a node to cause less to be rendered and ensure that it matches the layout we see locally. This still ensures the nodes are displayed and are intractable. Ran multiple times and seems to be working with my fix.

Adam Tackett added 2 commits December 7, 2024 16:20
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
@TackAdam TackAdam merged commit c22c69d into opensearch-project:main Dec 10, 2024
14 of 18 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 10, 2024
* Change service table click to page redirection

Signed-off-by: Adam Tackett <[email protected]>

* remove focus on filtering, bug fixes

Signed-off-by: Adam Tackett <[email protected]>

* add jest test for url redirection on click

Signed-off-by: Adam Tackett <[email protected]>

* remove filter on focus, update focus functionality, add testing

Signed-off-by: Adam Tackett <[email protected]>

* add query filtering back

Signed-off-by: Adam Tackett <[email protected]>

* change url check to use hook state

Signed-off-by: Adam Tackett <[email protected]>

* fix location error

Signed-off-by: Adam Tackett <[email protected]>

* move flyout into hashrouter, remove extra filter

Signed-off-by: Adam Tackett <[email protected]>

* fix applications, address comments

Signed-off-by: Adam Tackett <[email protected]>

* fix flaky application test

Signed-off-by: Adam Tackett <[email protected]>

* make service map snapshop deep

Signed-off-by: Adam Tackett <[email protected]>

* add service map focus cypress testing

Signed-off-by: Adam Tackett <[email protected]>

* add more tests to cover service map load and click

Signed-off-by: Shenoy Pratik <[email protected]>

* add comments to cypress

Signed-off-by: Shenoy Pratik <[email protected]>

* remove only from cypress tests

Signed-off-by: Shenoy Pratik <[email protected]>

* update snapshots

Signed-off-by: Shenoy Pratik <[email protected]>

* adjust cypress test

Signed-off-by: Adam Tackett <[email protected]>

* adjust cypress testw

Signed-off-by: Adam Tackett <[email protected]>

* remove only and comment

Signed-off-by: Adam Tackett <[email protected]>

* switch test back

Signed-off-by: Adam Tackett <[email protected]>

* add dependancy to use effect

Signed-off-by: Adam Tackett <[email protected]>

---------

Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Co-authored-by: Adam Tackett <[email protected]>
Co-authored-by: Shenoy Pratik <[email protected]>
(cherry picked from commit c22c69d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
TackAdam pushed a commit that referenced this pull request Dec 10, 2024
* Change service table click to page redirection



* remove focus on filtering, bug fixes



* add jest test for url redirection on click



* remove filter on focus, update focus functionality, add testing



* add query filtering back



* change url check to use hook state



* fix location error



* move flyout into hashrouter, remove extra filter



* fix applications, address comments



* fix flaky application test



* make service map snapshop deep



* add service map focus cypress testing



* add more tests to cover service map load and click



* add comments to cypress



* remove only from cypress tests



* update snapshots



* adjust cypress test



* adjust cypress testw



* remove only and comment



* switch test back



* add dependancy to use effect



---------





(cherry picked from commit c22c69d)

Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Adam Tackett <[email protected]>
Co-authored-by: Shenoy Pratik <[email protected]>
@TackAdam TackAdam mentioned this pull request Dec 17, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants