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

Add comments and inline docs for visualization saving and editing process. #8208

Merged

Conversation

cjcenizal
Copy link
Contributor

@cjcenizal cjcenizal commented Sep 9, 2016

Supersedes #7968

The goal is to clarify where URL state is coming from, when working with visualizations. Some of the classes touched upon are: SavedVis, PersistedState, AppState, and base classes.

Explored files:

  • src/core_plugins/kibana/public/visualize/editor/editor.js
  • src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js
  • src/ui/public/courier/data_source/_doc_send_to_es.js
  • src/ui/public/courier/data_source/doc_source.js
  • src/ui/public/courier/saved_object/saved_object.js
  • src/ui/public/es.js
  • src/ui/public/events.js
  • src/ui/public/persisted_state/persisted_state.js
  • src/ui/public/state_management/app_state.js
  • src/ui/public/state_management/state.js
  • src/ui/public/vis/agg_config.js
  • src/ui/public/vis/agg_configs.js
  • src/ui/public/vis/vis.js

@epixa
Copy link
Contributor

epixa commented Oct 8, 2016

@cjcenizal What's the status of this?

@cjcenizal
Copy link
Contributor Author

@epixa I'll get this merged this week.

@cjcenizal cjcenizal force-pushed the improvement/document-url-state-files branch 2 times, most recently from b7285f5 to fcd9615 Compare October 10, 2016 23:47
Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

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

Just found one nitpick, but other than that it was a very informative PR.

@@ -2,6 +2,12 @@ import 'elasticsearch-browser';
import _ from 'lodash';
import uiModules from 'ui/modules';

/**
* @name es
* @description This is the result of calling esFactory. Where is esFactory
Copy link
Contributor

Choose a reason for hiding this comment

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

To keep this PR consistent, can we place a line break between name and description?

@cjcenizal cjcenizal force-pushed the improvement/document-url-state-files branch from fcd9615 to b94253a Compare October 10, 2016 23:50
@thomasneirynck thomasneirynck self-assigned this Oct 10, 2016
@thomasneirynck
Copy link
Contributor

LGTM

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Some of the descriptions here feel more like observations, and not descriptions of the functionality they label. I'm all for sharing your observations but I would rather only put full-formed descriptions into the code.

requesting.call(vis);

// The benefit of calling `editableVis.requesting()` isn't clear.
Copy link
Contributor

@spalger spalger Oct 11, 2016

Choose a reason for hiding this comment

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

Is this not explained above?

When a vis is marked as being requested, the bounds of that vis are updated and new data is fetched using the new bounds.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You actually made this comment on the original PR: #7968 (comment)

const savedVis = $route.current.locals.savedVis;

// Instance of vis.js.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that in order for this to be useful the comment should point to the actual file, not just vis.js

@@ -115,6 +127,8 @@ function VisEditor($scope, $route, timefilter, AppState, $location, kbnUrl, $tim
docTitle.change(savedVis.title);
}

// Extract visualization state with filtered aggs.
// Consists of: aggs, params, listeners, title, and type.
Copy link
Contributor

@spalger spalger Oct 11, 2016

Choose a reason for hiding this comment

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

I think this should probably point the reader to where they can find the current state (like the URL) rather than list out it's properties. Otherwise the list will just get out of date and not benefit anyone

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good but not sure what you mean re point out where the reader can find current state. Can you give me an example of the comment you have in mind?

/**
* @name _doc_send_to_es
*
* @description Depends upon the es object to make ES requests, and also
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this comment is useful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not the most insightful comment, but it does give some idea of the relationship with the other actors in our codebase, so I'd like to leave it unless we can come up with a more meaningful description. :)

/**
* @name DocSource
*
* @description This class is tightly coupled with _doc_send_to_es. Its primary
Copy link
Contributor

@spalger spalger Oct 11, 2016

Choose a reason for hiding this comment

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

The relationship between this class and _doc_send_to_es doesn't really describe the class at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you'll need to illuminate me...

/**
* @name es
*
* @description This is the result of calling esFactory. Where is esFactory
Copy link
Contributor

Choose a reason for hiding this comment

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

esFactory is exposed by the elasticsearch.angular.js client

@@ -24,7 +34,6 @@ export default function VisFactory(Notifier, Private) {

this.indexPattern = indexPattern;

// http://aphyr.com/data/posts/317/state.gif
Copy link
Contributor

@spalger spalger Oct 11, 2016

Choose a reason for hiding this comment

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

party pooper

if (!angular.equals($state.vis, savedVisState)) {
// This is used to generate a 'uiState' PersistedState instance, and
// implictly add 'change' and 'fetch_with_changes' event handlers.
const appState = new AppState(stateDefaults);
Copy link
Contributor

@spalger spalger Oct 11, 2016

Choose a reason for hiding this comment

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

I don't see how the change or fetch_with_changes listeners are of any importance here. All that maters is that the properties of the appState are synced with the url, right? In order to save changes call appState.save() any changed from the url will be reflected in the properties of the appState

@@ -258,6 +285,9 @@ function VisEditor($scope, $route, timefilter, AppState, $location, kbnUrl, $tim
kbnUrl.change('/visualize', {});
};

/**
* Called when the user clicks "Save" button.
Copy link
Contributor

@spalger spalger Oct 11, 2016

Choose a reason for hiding this comment

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

This is probably unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would agree if the name of the method was something like onClickSave to indicate that this is part of the interface exposed to the template. But since the role of this method is a little unclear from the name, I'd like to leave this comment until we refactor and clarify naming.

*
* @extends SavedObject.
*
* @description It's a type of SavedObject, but specific to visualizations.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not seeing the value in this description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do. :)

@cjcenizal cjcenizal force-pushed the improvement/document-url-state-files branch 2 times, most recently from f191358 to bd21af2 Compare October 11, 2016 18:04
@cjcenizal cjcenizal force-pushed the improvement/document-url-state-files branch from bd21af2 to 00f532e Compare October 11, 2016 18:21
@cjcenizal
Copy link
Contributor Author

jenkins, test this

…cess.

The goal is to clarify where URL state is coming from, when working with
visualizations. Some of the classes touched upon are: SavedVis,
PersistedState, AppState, and base classes.

Explored files:
- src/core_plugins/kibana/public/visualize/editor/editor.js
- src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js
- src/ui/public/courier/data_source/_doc_send_to_es.js
- src/ui/public/courier/data_source/doc_source.js
- src/ui/public/courier/saved_object/saved_object.js
- src/ui/public/es.js
- src/ui/public/events.js
- src/ui/public/persisted_state/persisted_state.js
- src/ui/public/state_management/app_state.js
- src/ui/public/state_management/state.js
- src/ui/public/vis/agg_config.js
- src/ui/public/vis/agg_configs.js
- src/ui/public/vis/vis.js
@cjcenizal cjcenizal force-pushed the improvement/document-url-state-files branch from 00f532e to 34e3f49 Compare October 11, 2016 19:10
@cjcenizal cjcenizal merged commit 4c45c26 into elastic:master Oct 11, 2016
@cjcenizal cjcenizal deleted the improvement/document-url-state-files branch October 11, 2016 19:11
@epixa
Copy link
Contributor

epixa commented Oct 11, 2016

@cjcenizal To help in our ongoing quest to make backports easier, please backport this to 5.x and 5.0

@cjcenizal cjcenizal removed the review label Oct 11, 2016
elastic-jasper added a commit that referenced this pull request Oct 11, 2016
---------

**Commit 1:**
Add comments and inline docs for visualization saving and editing process.
The goal is to clarify where URL state is coming from, when working with
visualizations. Some of the classes touched upon are: SavedVis,
PersistedState, AppState, and base classes.

Explored files:
- src/core_plugins/kibana/public/visualize/editor/editor.js
- src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js
- src/ui/public/courier/data_source/_doc_send_to_es.js
- src/ui/public/courier/data_source/doc_source.js
- src/ui/public/courier/saved_object/saved_object.js
- src/ui/public/es.js
- src/ui/public/events.js
- src/ui/public/persisted_state/persisted_state.js
- src/ui/public/state_management/app_state.js
- src/ui/public/state_management/state.js
- src/ui/public/vis/agg_config.js
- src/ui/public/vis/agg_configs.js
- src/ui/public/vis/vis.js

* Original sha: 34e3f49
* Authored by CJ Cenizal <[email protected]> on 2016-08-10T00:10:48Z
elastic-jasper added a commit that referenced this pull request Oct 11, 2016
---------

**Commit 1:**
Add comments and inline docs for visualization saving and editing process.
The goal is to clarify where URL state is coming from, when working with
visualizations. Some of the classes touched upon are: SavedVis,
PersistedState, AppState, and base classes.

Explored files:
- src/core_plugins/kibana/public/visualize/editor/editor.js
- src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js
- src/ui/public/courier/data_source/_doc_send_to_es.js
- src/ui/public/courier/data_source/doc_source.js
- src/ui/public/courier/saved_object/saved_object.js
- src/ui/public/es.js
- src/ui/public/events.js
- src/ui/public/persisted_state/persisted_state.js
- src/ui/public/state_management/app_state.js
- src/ui/public/state_management/state.js
- src/ui/public/vis/agg_config.js
- src/ui/public/vis/agg_configs.js
- src/ui/public/vis/vis.js

* Original sha: 34e3f49
* Authored by CJ Cenizal <[email protected]> on 2016-08-10T00:10:48Z
cjcenizal added a commit that referenced this pull request Oct 11, 2016
cjcenizal added a commit that referenced this pull request Oct 11, 2016
[backport] PR #8208 to 5.x - Add comments and inline docs for visualization saving and editing process.
@cjcenizal
Copy link
Contributor Author

Backported to 5.0 and 5.x.

airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
---------

**Commit 1:**
Add comments and inline docs for visualization saving and editing process.
The goal is to clarify where URL state is coming from, when working with
visualizations. Some of the classes touched upon are: SavedVis,
PersistedState, AppState, and base classes.

Explored files:
- src/core_plugins/kibana/public/visualize/editor/editor.js
- src/core_plugins/kibana/public/visualize/saved_visualizations/_saved_vis.js
- src/ui/public/courier/data_source/_doc_send_to_es.js
- src/ui/public/courier/data_source/doc_source.js
- src/ui/public/courier/saved_object/saved_object.js
- src/ui/public/es.js
- src/ui/public/events.js
- src/ui/public/persisted_state/persisted_state.js
- src/ui/public/state_management/app_state.js
- src/ui/public/state_management/state.js
- src/ui/public/vis/agg_config.js
- src/ui/public/vis/agg_configs.js
- src/ui/public/vis/vis.js

* Original sha: 3cf76b6004f98d694cb0d31831035e806f71357c [formerly 34e3f49]
* Authored by CJ Cenizal <[email protected]> on 2016-08-10T00:10:48Z


Former-commit-id: 433c265
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
[backport] PR elastic#8208 to 5.x - Add comments and inline docs for visualization saving and editing process.

Former-commit-id: 8752eea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants