Skip to content

Streamline adding a visualization to a dashboard#9400

Merged
stacey-gammon merged 4 commits intoelastic:masterfrom
stacey-gammon:streamline-add-vis-dashboard
Jan 3, 2017
Merged

Streamline adding a visualization to a dashboard#9400
stacey-gammon merged 4 commits intoelastic:masterfrom
stacey-gammon:streamline-add-vis-dashboard

Conversation

@stacey-gammon
Copy link
Copy Markdown

@stacey-gammon stacey-gammon commented Dec 7, 2016

Implements #9554.

@tbragin tbragin added Feature:Dashboard Dashboard related features :Sharing labels Dec 16, 2016
@stacey-gammon stacey-gammon force-pushed the streamline-add-vis-dashboard branch 4 times, most recently from c50294f to a781c31 Compare December 30, 2016 19:57
@stacey-gammon stacey-gammon changed the title Streamline add vis dashboard (WIP/POC) Streamline adding a visualization to a dashboard Dec 30, 2016
@stacey-gammon stacey-gammon force-pushed the streamline-add-vis-dashboard branch from a781c31 to 530346c Compare December 30, 2016 20:07
@kobelb kobelb self-requested a review January 2, 2017 14:59
@kobelb kobelb self-assigned this Jan 2, 2017
Copy link
Copy Markdown
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

I really like this new workflow, just a few minor comments/suggestions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Using $location.search here is creating an entry in the history, which is going to cause the back-button to behave weirdly.

It looks like there's https://code.angularjs.org/1.4.7/docs/api/ng/service/$location#replace we can use, but it applies to all changes during the current digest cycle, which might not be what we want.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think replace does the right thing, nothing else is updating the url like I am so it'll just reset on the next url change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same history issue as mentioned before.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated (good catch on this)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it'd help readability to move this to right before we replace the parameter in the URL.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason we aren't using the kbnUrl.change here instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added a comment, it's because the dashboard url is a full url. Thought it was safer to just redirect there, rather than add something to detect the right suffix to use, which would be fragile to any url prefix changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same $location.search issue as above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

Stacey Gammon added 2 commits January 2, 2017 13:53
… add again and again

Move the link into the saved object finder

and get rid of the management link
fix crash in tests
lint fixes
@stacey-gammon stacey-gammon force-pushed the streamline-add-vis-dashboard branch 2 times, most recently from b8dd23c to e2134ac Compare January 2, 2017 19:36
make the function simpler and reduce the need to pass null everywhere
@stacey-gammon stacey-gammon force-pushed the streamline-add-vis-dashboard branch from e2134ac to 0dd98e7 Compare January 2, 2017 19:37
Copy link
Copy Markdown
Contributor

@kobelb kobelb left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

Functionally, this looks awesome! I just have a few suggestions.

kbnUrl.removeParam(DashboardConsts.ADD_VIS_PARAM);
}

$scope.addNewVis = function () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might as well make this a named function so it's easier to identify in the call stack:

$scope.addNewVis = function addNewVis() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And does this need to be on the $scope? It doesn't seem like it does.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

++ done

// Not using kbnUrl.change here because the dashboardBaseUrl is a full path, not a url suffix.
// Rather than guess the right substring, we'll just navigate there directly, just as if the user
// clicked the dashboard link in the UI.
window.location.href = `${dashboardBaseUrl.lastSubUrl}&${DashboardConsts.ADD_VIS_PARAM}=${savedVis.id}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we want to use $window instead of window, so we can mock it in unit tests.

module.controller('VisualizeWizardStep1', function ($scope, $route, kbnUrl, timefilter, Private) {
timefilter.enabled = false;

$scope.addToDashMode = $route.current.params[DashboardConsts.ADD_TO_DASH_PARAM];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the template doesn't need access to addToDashMode then this should just be a const instead of a scope variable.

module.controller('VisualizeWizardStep2', function ($route, $scope, $location, timefilter, kbnUrl) {
module.controller('VisualizeWizardStep2', function ($route, $scope, timefilter, kbnUrl) {
const type = $route.current.params.type;
$scope.addToDashMode = $route.current.params[DashboardConsts.ADD_TO_DASH_PARAM];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the template doesn't need access to addToDashMode then this should just be a const instead of a scope variable.

class="btn btn-primary"
>
Save
{{ opts.isAddToDashMode() ? 'Save and Return' : 'Save'}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we make this a little more explicit by changing it to 'Save and Add to Dashboard'?


export const DashboardConsts = {
ADD_TO_DASH_PARAM: 'addToDashboard',
ADD_VIS_PARAM: 'addVisualization'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm having a hard time telling these two apart because the names are so similar.

I think these would be a little clearer if they were ADD_VISUALIZATION_TO_DASHBOARD_MODE_PARAM and NEW_VISUALIZATION_ID_PARAM. I know this seems verbose, but that's only because our nouns happen to have lots of letters in them -- in terms of using as few words as possible to communicate the maximum amount of information, I think they're pretty efficient!

import indexTemplate from 'plugins/kibana/dashboard/index.html';
import { savedDashboardRegister } from 'plugins/kibana/dashboard/services/saved_dashboard_register';
import { createPanelState } from 'plugins/kibana/dashboard/components/panel/lib/panel_state';
import { DashboardConsts } from './dashboard_consts';
Copy link
Copy Markdown
Contributor

@cjcenizal cjcenizal Jan 2, 2017

Choose a reason for hiding this comment

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

Can we name the file and variable without abbreviating "constants"? e.g. DashboardConstants and ./dashboard_constants. There's not much gained by abbreviating them and "const" is a keyword that I think is worth differentiating from the concept of "constants".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

++ done

$scope.addToDashMode = $route.current.params[DashboardConsts.ADD_TO_DASH_PARAM];
kbnUrl.removeParam(DashboardConsts.ADD_TO_DASH_PARAM);

$scope.isAddToDashMode = () => { return $scope.addToDashMode; };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can be simplified:

$scope.isAddToDashMode = () => $scope.addToDashMode;

*/
self.removeParam = function (param) {
$location.search(param, null).replace();
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add unit tests for this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

@stacey-gammon
Copy link
Copy Markdown
Author

@cjcenizal thanks for the comments and feedback, should be all addressed!

Copy link
Copy Markdown
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

LGTM!

@kobelb
Copy link
Copy Markdown
Contributor

kobelb commented Jan 3, 2017

FWIW, the changes look good to me as well

@stacey-gammon stacey-gammon merged commit 344945d into elastic:master Jan 3, 2017
elastic-jasper added a commit that referenced this pull request Jan 5, 2017
Backports PR #9400

**Commit 1:**
Fix bug with param sticking around in the url causing multiple vis to add again and again

Move the link into the saved object finder

and get rid of the management link
fix crash in tests
lint fixes

* Original sha: 4ff6030
* Authored by Stacey Gammon <gammon@elastic.co> on 2016-12-07T17:46:05Z

**Commit 2:**
rebase with master

* Original sha: df8142d
* Authored by Stacey Gammon <gammon@elastic.co> on 2016-12-15T19:02:05Z

**Commit 3:**
code review comments

make the function simpler and reduce the need to pass null everywhere

* Original sha: 0dd98e7
* Authored by Stacey Gammon <gammon@elastic.co> on 2017-01-02T19:31:37Z

**Commit 4:**
address comments and cleanup

* Original sha: d18f14c
* Authored by Stacey Gammon <gammon@elastic.co> on 2017-01-03T15:58:19Z
stacey-gammon pushed a commit to stacey-gammon/kibana that referenced this pull request Jan 5, 2017
* Fix bug with param sticking around in the url causing multiple vis to add again and again

Move the link into the saved object finder

and get rid of the management link
fix crash in tests
lint fixes

* rebase with master

* code review comments

make the function simpler and reduce the need to pass null everywhere

* address comments and cleanup
stacey-gammon pushed a commit that referenced this pull request Jan 6, 2017
* Fix bug with param sticking around in the url causing multiple vis to add again and again

Move the link into the saved object finder

and get rid of the management link
fix crash in tests
lint fixes

* rebase with master

* code review comments

make the function simpler and reduce the need to pass null everywhere

* address comments and cleanup
@stacey-gammon stacey-gammon deleted the streamline-add-vis-dashboard branch February 7, 2017 14:37
acstll added a commit that referenced this pull request Feb 25, 2026
## Dependency updates

- `@elastic/eui` - v113.0.0 ⏩ v113.1.0
- `@elastic/eui-theme-borealis` - v6.0.0 ⏩ v6.1.0

---

## Changes

| Commit | Change | Teams (Code Owner) |
| :--- | :--- | :--- |
| 18ef117 | Update snapshots, new Assistance color tokens
([#9383](elastic/eui#9383)) |
@elastic/kibana-security |
| 3fad87f | Update snapshots, new `aria-expanded` attribute added to
button triggers of `EuiPopover`
([#9381](elastic/eui#9381)) |
@elastic/appex-sharedux, @elastic/kibana-visualizations,
@elastic/kibana-data-discovery |
| cc9e096 | Update snapshots, remove
`aria-controls` now handled by `EuiPopover` directly
([#9381](elastic/eui#9381)) |
@elastic/kibana-security |

## Package updates

### `@elastic/eui`
[v113.1.0](https://github.com/elastic/eui/releases/tag/v113.1.0)

- Added `data-test-subj` attributes to `EuiFlyoutMenu` elements: back
button, history dropdown, and history items.
([#9400](elastic/eui#9400))
- Added new assistance tokens:
([#9383](elastic/eui#9383))
    - `euiTheme.colors.backgroundFilledAssistance`
    - `euiTheme.colors.backgroundLightAssistance`
    - `euiTheme.colors.backgroundBaseAssistance`
    - `euiTheme.components.buttons.backgroundAssistanceHover`,
    - `euiTheme.components.buttons.backgroundFilledAssistanceHover`
    - `euiTheme.colors.backgroundBaseInteractiveHoverAssistance`
    - `euiTheme.colors.borderStrongAssistance`
    - `euiTheme.colors.borderBaseAssistance`
    - `euiTheme.colors.textAssistance`
    - `euiTheme.colors.vis.euiColorVisAssistance`
    - `euiTheme.colors.severity.assistance`
    - `euiTheme.colors.vis.euiColorVis10`
    - `euiTheme.colors.vis.euiColorVis11`
    - `euiTheme.colors.vis.euiColorVisText10`
    - `euiTheme.colors.vis.euiColorVisText11`
- Updated purple color palette shades 30-60 to slightly lighter values
([#9383](elastic/eui#9383))

**Accessibility**

- Adds `aria-expanded` and `aria-controls` to the `EuiPopover` trigger
button to improve screen reader context
([#9381](elastic/eui#9381))

### `@elastic/eui-theme-borealis` v6.1.0

- Added new assistance tokens:
([#9383](elastic/eui#9383))
    - `euiTheme.colors.backgroundFilledAssistance`
    - `euiTheme.colors.backgroundLightAssistance`
    - `euiTheme.colors.backgroundBaseAssistance`
    - `euiTheme.components.buttons.backgroundAssistanceHover`,
    - `euiTheme.components.buttons.backgroundFilledAssistanceHover`
    - `euiTheme.colors.backgroundBaseInteractiveHoverAssistance`
    - `euiTheme.colors.borderStrongAssistance`
    - `euiTheme.colors.borderBaseAssistance`
    - `euiTheme.colors.textAssistance`
    - `euiTheme.colors.vis.euiColorVisAssistance`
    - `euiTheme.colors.severity.assistance`
    - `euiTheme.colors.vis.euiColorVis10`
    - `euiTheme.colors.vis.euiColorVis11`
    - `euiTheme.colors.vis.euiColorVisText10`
    - `euiTheme.colors.vis.euiColorVisText11`
- Updated purple color palette shades 30-60 to slightly lighter values
([#9383](elastic/eui#9383))
qn895 pushed a commit to qn895/kibana that referenced this pull request Mar 11, 2026
## Dependency updates

- `@elastic/eui` - v113.0.0 ⏩ v113.1.0
- `@elastic/eui-theme-borealis` - v6.0.0 ⏩ v6.1.0

---

## Changes

| Commit | Change | Teams (Code Owner) |
| :--- | :--- | :--- |
| 18ef117 | Update snapshots, new Assistance color tokens
([elastic#9383](elastic/eui#9383)) |
@elastic/kibana-security |
| 3fad87f | Update snapshots, new `aria-expanded` attribute added to
button triggers of `EuiPopover`
([elastic#9381](elastic/eui#9381)) |
@elastic/appex-sharedux, @elastic/kibana-visualizations,
@elastic/kibana-data-discovery |
| cc9e096 | Update snapshots, remove
`aria-controls` now handled by `EuiPopover` directly
([elastic#9381](elastic/eui#9381)) |
@elastic/kibana-security |

## Package updates

### `@elastic/eui`
[v113.1.0](https://github.com/elastic/eui/releases/tag/v113.1.0)

- Added `data-test-subj` attributes to `EuiFlyoutMenu` elements: back
button, history dropdown, and history items.
([elastic#9400](elastic/eui#9400))
- Added new assistance tokens:
([elastic#9383](elastic/eui#9383))
    - `euiTheme.colors.backgroundFilledAssistance`
    - `euiTheme.colors.backgroundLightAssistance`
    - `euiTheme.colors.backgroundBaseAssistance`
    - `euiTheme.components.buttons.backgroundAssistanceHover`,
    - `euiTheme.components.buttons.backgroundFilledAssistanceHover`
    - `euiTheme.colors.backgroundBaseInteractiveHoverAssistance`
    - `euiTheme.colors.borderStrongAssistance`
    - `euiTheme.colors.borderBaseAssistance`
    - `euiTheme.colors.textAssistance`
    - `euiTheme.colors.vis.euiColorVisAssistance`
    - `euiTheme.colors.severity.assistance`
    - `euiTheme.colors.vis.euiColorVis10`
    - `euiTheme.colors.vis.euiColorVis11`
    - `euiTheme.colors.vis.euiColorVisText10`
    - `euiTheme.colors.vis.euiColorVisText11`
- Updated purple color palette shades 30-60 to slightly lighter values
([elastic#9383](elastic/eui#9383))

**Accessibility**

- Adds `aria-expanded` and `aria-controls` to the `EuiPopover` trigger
button to improve screen reader context
([elastic#9381](elastic/eui#9381))

### `@elastic/eui-theme-borealis` v6.1.0

- Added new assistance tokens:
([elastic#9383](elastic/eui#9383))
    - `euiTheme.colors.backgroundFilledAssistance`
    - `euiTheme.colors.backgroundLightAssistance`
    - `euiTheme.colors.backgroundBaseAssistance`
    - `euiTheme.components.buttons.backgroundAssistanceHover`,
    - `euiTheme.components.buttons.backgroundFilledAssistanceHover`
    - `euiTheme.colors.backgroundBaseInteractiveHoverAssistance`
    - `euiTheme.colors.borderStrongAssistance`
    - `euiTheme.colors.borderBaseAssistance`
    - `euiTheme.colors.textAssistance`
    - `euiTheme.colors.vis.euiColorVisAssistance`
    - `euiTheme.colors.severity.assistance`
    - `euiTheme.colors.vis.euiColorVis10`
    - `euiTheme.colors.vis.euiColorVis11`
    - `euiTheme.colors.vis.euiColorVisText10`
    - `euiTheme.colors.vis.euiColorVisText11`
- Updated purple color palette shades 30-60 to slightly lighter values
([elastic#9383](elastic/eui#9383))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Dashboard Dashboard related features review v5.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants