-
Notifications
You must be signed in to change notification settings - Fork 58
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
Conversation
Signed-off-by: Adam Tackett <[email protected]>
public/components/trace_analytics/components/services/services_table.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
let serviceId: string | null = null; | ||
|
||
try { | ||
const location = useLocation(); | ||
const params = new URLSearchParams(location?.search || ''); | ||
serviceId = params.get('serviceId'); | ||
} catch (error) { | ||
serviceId = null; | ||
} |
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.
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]);
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.
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.
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.
Josh helped find the issue
dashboards-observability/public/components/trace_analytics/home.tsx
Lines 493 to 494 in a1dfaea
</HashRouter> | |
{flyout} |
Fly-out was not inside the HashRouter.
public/components/trace_analytics/components/services/services_table.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
filters: FilterType[]; | ||
setFilters: | ||
| React.Dispatch<React.SetStateAction<FilterType[]>> | ||
| ((filters: FilterType[]) => void); |
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.
curious why are both needed?
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.
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 |
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.
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?
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.
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]); |
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.
do we need focusedService
and filterByCurrService
in dependency array?
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.
I don't believe so
Screen.Recording.2024-12-04.at.11.17.18.AM.mov
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.
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(); |
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.
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
?
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.
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; |
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.
should this be a state?
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.
➕1
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.
Changed to a state.
jest.mock('../../../../../../test/__mocks__/coreMocks', () => ({ | ||
coreStartMock: { | ||
chrome: { setBreadcrumbs: jest.fn() }, | ||
http: { post: jest.fn() }, |
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.
Can we please add mocks with some actual data (both empty and non-empty response)?
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.
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
public/components/trace_analytics/components/common/plots/service_map.tsx
Outdated
Show resolved
Hide resolved
public/components/trace_analytics/components/common/plots/__tests__/service_map.test.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
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(); | ||
|
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.
Should we wait for the canvas to appear, so that map renders in the snapshot?
Also, looks like this test |
Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
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 |
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
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. |
.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js
Outdated
Show resolved
Hide resolved
.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js
Outdated
Show resolved
Hide resolved
.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
* 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>
* 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]>
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
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.