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

CSV panel actions for SavedSearch embedabbles #33709

Merged
merged 9 commits into from
Mar 29, 2019
Merged

CSV panel actions for SavedSearch embedabbles #33709

merged 9 commits into from
Mar 29, 2019

Conversation

joelgriffith
Copy link
Contributor

Retry of #32522 since this PR wasn't showing the appropriate deltas.


public isVisible = (panelActionAPI: PanelActionAPI): boolean => {
const { embeddable } = panelActionAPI;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to go with duck-type-typing here since it was proving to be impossible to import the SavedSearchEmbedable component :/

Copy link
Member

Choose a reason for hiding this comment

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

Ok, so the actual class we want is from src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable.ts, which is an extension of the Embeddable class. That's why we have to check for the savedSearch property to make sure it's valid?

In that case, I think this could use a comment to marker where we might be able to improve things down the road.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@@ -28,7 +28,9 @@ class PanelActionsStore {
*/
public initializeFromRegistry(panelActionsRegistry: ContextMenuAction[]) {
panelActionsRegistry.forEach(panelAction => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some reason panel actions are duped everytime you re-enter a page when client-side routing occurs. This fixes that.


await kfetch({ method: 'POST', pathname: `${API_BASE_URL}${id}`, body }, { parseJson: false })
.then(r => r.text())
.then(csv => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kind of a nasty client-side mechanism to do CSV downloads browser-side. Might want to consolidate this into some sort of util elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like typical JS to me 😁

import { kfetch } from 'ui/kfetch';
import { toastNotifications } from 'ui/notify';

const API_BASE_URL = '/api/reporting/v1/generate/immediate/csv/saved-object/';
Copy link
Member

Choose a reason for hiding this comment

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

I think it'd be worthwhile to import the base URL path (API_BASE_URL_V1) from '../../common/constants'

const state = await this.generateJobParams({ searchEmbeddable });

const id = `search:${embeddable.savedSearch.id}`;
const filename = embeddable.savedSearch.title;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe next, we should work on exposing the SearchEmbeddable interface here, because .savedSearch and .$rootScope are typed as private in src/legacy/core_plugins/kibana/public/discover/embeddable/search_embeddable

Copy link
Member

Choose a reason for hiding this comment

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

In addition to the other headaches with the SearchEmbeddable interface (😁) it seems too limited for the definition to be in /discover. The Discover app is used for creating a saved search... but having the defined structure of a saved search is important all over the Kibana codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think I'm going to add another issue where we do some cleanup/migration of this component so we can better use it in our x-pack code.

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

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

I left a couple of comments, which are really more for discussion. The only things I'm really interested to see changed are the thing about using the constants file, and adding that minor comment.

};

private onGenerationFail(error: Error) {
toastNotifications.addDanger({
Copy link
Member

Choose a reason for hiding this comment

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

💚

@tsullivan tsullivan changed the title Feature/reporting/csv export panel action ui CSV panel actions for SavedSearch embedabbles Mar 26, 2019
}

const searchEmbeddable = embeddable;
const state = await this.generateJobParams({ searchEmbeddable });
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be wrapped in _.pick to whitelist fields that we care about. For example, we don't care about highlight, size, and script_fields (since they can't create script fields on-the-fly)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, this is just a comment of something we can figure out later, because I'm not sure what we need at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

Another thing (that doesn't need to be figured out right now) - this object doesn't seem to contain the columns.

  1. Create a saved search
  2. Add it to a dashboard
  3. Change the columns in the panel of the dashboard
  4. We need to figure out how to get the columns to show, it's not in this state (but it could be)

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!

@tsullivan
Copy link
Member

Will it be possible to not have the download link show up when the dashboard is in edit mode?

image

@elasticmachine
Copy link
Contributor

💔 Build Failed

@tsullivan tsullivan self-assigned this Mar 28, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@rayafratkina rayafratkina added the (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead label Mar 28, 2019
@joelgriffith joelgriffith force-pushed the feature/reporting/csv-export-panel-action branch from f43ad9f to 34677f2 Compare March 28, 2019 20:10
@tsullivan
Copy link
Member

There's a valid test failure of some of our code being wrong after the master merge:

09:22:46 ERROR x-pack/test failed
09:22:46       /var/lib/jenkins/workspace/elastic+kibana+pull-request/JOB/kibana-intake/node/immutable/kibana/x-pack/test/reporting/api/generate/csv_saved_search.ts
09:22:46       ERROR: 7:20  module-migration  Imported module "expect.js" should be "@kbn/expect"

@elasticmachine
Copy link
Contributor

💔 Build Failed

@joelgriffith
Copy link
Contributor Author

I've thrown down some TODO's as well as hidden the export in edit mode. I think that resolves most of the comments here @tsullivan if you want to give it a final glance.

After that we can begin the PR from our feature branch back into master. I don't mind taking ownership of that.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

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

LGTM

@joelgriffith joelgriffith merged commit fb3776c into elastic:feature/reporting/csv-export-panel-action Mar 29, 2019
@AlonaNadler
Copy link

Congrats on the merge! great job :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants