Skip to content

Conversation

@KostyaAvtushko
Copy link
Contributor

@KostyaAvtushko KostyaAvtushko commented Sep 24, 2025

https://nda.ya.ru/t/SMdmjkxC7KLvxg

## Summary by Sourcery

Add manual path navigation to the Dashboard2 Navigation widget by integrating a PathEditor input with a confirm button, toggled via a new widget setting, and refactor related API requests to support node icon attributes.

New Features:

  • Display a path input editor in the Dashboard2 Navigation widget for direct path navigation.

Enhancements:

  • Add hasConfirmButton prop to PathEditor for apply button navigation via react-router
  • Extend PathEditor suggestions with node attributes and render icons using MapNodeIcon
  • Introduce attributesForNodeIcon constant and update API queries and map-node actions to fetch relevant node attributes
  • Add show_navigation_input widget setting (default true) and update default dashboard configuration
  • Adjust styling for PathEditor and Navigation content with flex layouts and enable vertical scrolling in lists

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 24, 2025

Reviewer's Guide

This PR introduces direct path navigation to the Dashboard2 navigation widget by embedding a PathEditor with a confirm button, wiring up URL updates via react-router, auto-selecting input on focus, enriching item icon logic with node attributes, and exposing a toggle setting, along with supporting API and styling adjustments.

File-Level Changes

Change Details Files
Embed path navigation input and URL update logic
  • Add DashboardPathEditor component with onApply and onFocus handlers
  • Wrap widget content in a Flex container and conditionally render the path editor
  • Push normalized path to history with current cluster
  • Introduce showNavigationInput flag via hook and widget settings toggle
  • Enable default true setting in dashboard constants
NavigationWidgetContent.tsx
use-navigation-widget.ts
settings/index.tsx
types.ts
constants/dashboard2/index.ts
Extend PathEditor with confirm button and focus behavior
  • Add hasConfirmButton prop and default value
  • Split base input rendering and inject confirm Button with Arrow icon
  • Invoke onApply callback with current path on button click
  • Auto-select input text on focus
PathEditor.tsx
PathEditor.scss
Integrate MapNodeIcon and include node attributes
  • Replace iconName logic with MapNodeIcon using new attributes field
  • Extract attributesForNodeIcon constant and reuse in requests
  • Populate attributes from API and suggestion preparation
PathEditor.tsx
paths.ts
path-editor.js
map-node.js
map-node.ts
Adjust layout and scrolling for navigation list
  • Wrap entire widget in vertical Flex with gap
  • Add overflow-y auto to list container
NavigationWidgetContent.tsx
NavigationWidgetContent.scss

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link
Contributor

Storybook is ready.

@github-actions
Copy link
Contributor

Playwright components report is ready.

@github-actions
Copy link
Contributor

Statoscope report is ready.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

No test reports are available for this run.

@KostyaAvtushko KostyaAvtushko force-pushed the dash_nav_sear branch 3 times, most recently from 0c9a1f4 to 8a1ef5c Compare September 25, 2025 19:42
@KostyaAvtushko KostyaAvtushko marked this pull request as ready for review September 26, 2025 08:17
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Extract the path normalization (trailing slash trimming) into a shared utility (e.g. normalizePath) to improve readability and avoid duplication.
  • Use URLSearchParams (or similar) instead of manual string concatenation to build the navigation URL, ensuring correct encoding of query parameters.
  • Move the inline Button style (height: '100%') into a SCSS class rather than using inline styles to keep styling consistent and maintainable.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Extract the path normalization (trailing slash trimming) into a shared utility (e.g. normalizePath) to improve readability and avoid duplication.
- Use URLSearchParams (or similar) instead of manual string concatenation to build the navigation URL, ensuring correct encoding of query parameters.
- Move the inline Button style (`height: '100%'`) into a SCSS class rather than using inline styles to keep styling consistent and maintainable.

## Individual Comments

### Comment 1
<location> `packages/ui/src/ui/containers/PathEditor/PathEditor.tsx:312-319` </location>
<code_context>
         }
     };

-    renderInput() {
+    renderBaseInput() {
         const {placeholder, autoFocus, hasClear, disabled} = this.props;
</code_context>

<issue_to_address>
**suggestion:** Consider keyboard accessibility for the confirm button.

Support triggering the onApply action via keyboard events, such as the Enter key, when hasConfirmButton is true.

Suggested implementation:

```typescript
    handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
        const {hasConfirmButton, onApply} = this.props;
        const {path} = this.state;
        if (hasConfirmButton && event.key === 'Enter' && typeof onApply === 'function') {
            onApply(path);
        }
    };

    renderInput() {
        const {hasConfirmButton, onApply} = this.props;
        const {path} = this.state;

        if (!hasConfirmButton) {

```

```typescript
    renderBaseInput() {
        const {placeholder, autoFocus, hasClear, disabled, hasConfirmButton} = this.props;
        const {path} = this.state;

        return (
            <input
                type="text"
                value={path}
                placeholder={placeholder}
                autoFocus={autoFocus}
                disabled={disabled}
                onChange={this.handleInputChange}
                onKeyDown={hasConfirmButton ? this.handleInputKeyDown : undefined}
            />
        );
    }

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 309 to +319
);
}

renderInput() {
const {hasConfirmButton, onApply} = this.props;
const {path} = this.state;

if (!hasConfirmButton) {
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider keyboard accessibility for the confirm button.

Support triggering the onApply action via keyboard events, such as the Enter key, when hasConfirmButton is true.

Suggested implementation:

    handleInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
        const {hasConfirmButton, onApply} = this.props;
        const {path} = this.state;
        if (hasConfirmButton && event.key === 'Enter' && typeof onApply === 'function') {
            onApply(path);
        }
    };

    renderInput() {
        const {hasConfirmButton, onApply} = this.props;
        const {path} = this.state;

        if (!hasConfirmButton) {
    renderBaseInput() {
        const {placeholder, autoFocus, hasClear, disabled, hasConfirmButton} = this.props;
        const {path} = this.state;

        return (
            <input
                type="text"
                value={path}
                placeholder={placeholder}
                autoFocus={autoFocus}
                disabled={disabled}
                onChange={this.handleInputChange}
                onKeyDown={hasConfirmButton ? this.handleInputKeyDown : undefined}
            />
        );
    }

@ma-efremoff
Copy link
Collaborator

Some CI actions are failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants