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

[Ingest] Edit datasource UI #64727

Merged
merged 11 commits into from
Apr 30, 2020
Merged

[Ingest] Edit datasource UI #64727

merged 11 commits into from
Apr 30, 2020

Conversation

jen-huang
Copy link
Contributor

@jen-huang jen-huang commented Apr 29, 2020

Resolves #57957

Summary

This PR adds edit data source UI by importing the existing create data source UI components. A few other cleanups were also done, including: removal of existing code, type clean up, remove delete agent config functionality from list page (will be moved to config Settings tab), and fixes of small data source validation bugs.

Screenshots

image

image

image

@jen-huang jen-huang added v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.8.0 Team:Fleet Team label for Observability Data Collection Fleet team labels Apr 29, 2020
@jen-huang jen-huang requested a review from a team April 29, 2020 01:06
@jen-huang jen-huang self-assigned this Apr 29, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

Copy link
Contributor

@jfsiii jfsiii left a comment

Choose a reason for hiding this comment

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

I haven't checked this out and run it, but I think the code is clear.

I left some comments but nothing to hold up a merge.

if (agentConfigData?.item) {
setAgentConfig(agentConfigData.item);
}
const { data: datasourceData } = await sendGetOneDatasource(datasourceId);
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we can use Promise.all here and do these two requests in parallel.

@@ -56,6 +56,7 @@ export const DatasourcesTable: React.FunctionComponent<Props> = ({
}) => {
const hasWriteCapabilities = useCapabilities().write;
const addDatasourceLink = useAgentConfigLink('add-datasource', { configId: config.id });
const editDatasourceLink = useLink(`/configs/${config.id}/edit-datasource/{datasourceId}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to avoid doing this in a view and have in some other function/service. Can useAgentConfigLink be updated or copied to do this?

...restOfInput,
streams: streams.map(stream => {
const { agent_stream, ...restOfStream } = stream;
return { ...restOfStream };
Copy link
Contributor

Choose a reason for hiding this comment

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

Can just return the restOfStream object, right?

setDatasource(newDatasource);

// eslint-disable-next-line no-console
console.debug('Datasource updated', newDatasource);
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to ship this do we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intentional for alpha/beta as this area is higher risk for issues occurring. Having these logs can help us debug customer issues faster. The same lines are set in create flow too. Note that it's .debug and not .log so isn't displayed when using the default console output level

};

// Cancel url
const CONFIG_URL = useLink(`${AGENT_CONFIG_DETAILS_PATH}${configId}`);
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 we have a way to get this but either way, I would like to avoid views having knowledge of the route specifics and having to assemble them.

}
const { error } = await saveDatasource();
if (!error) {
history.push(`${AGENT_CONFIG_DETAILS_PATH}${configId}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about creating routes in a view

icon="pencil"
onClick={() => {}}
href={editDatasourceLink.replace(
encodeURIComponent('{datasourceId}'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I was not able to get Edit Datasource to display when I ran this PR locally - kept getting API error about Datasource not found. The issue seems to be here - the editDatasourceLink actually does not have the {datasourceid} url encoded. I changed it locally to this and was able to get the Edit form to show up:

Suggested change
encodeURIComponent('{datasourceId}'),
'{datasourceId}',

But, given @jfsiii 's comments above, perhaps you will get the URL using the other hook (which would imply you might need to create a HOC for this EuiContextMenuItem)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is weird, on mine it does't work without encodeURIComponent. I changed it to get the base url without {datasourceId} and just append the ID after

@paul-tavares
Copy link
Contributor

Aside from the one issue I found (comment provided), I ran it locally and it seems to work fine on the Endpoint datasource (which does not have data to be displayed in section 2 of the UI) - 👍

@jen-huang
Copy link
Contributor Author

Re: routing

I agree with the sentiments about not having views building URIs. Our routing isn't consistent, we have views that use hooks/services for onClick (history) and hrefs, and views that build the URIs manually. Ideally I would like to have all routing functionality in hooks, but it would mean that we will need to pull out some components into smaller ones as hooks can only be used at the top level of functional components. Given the existing inconsistencies and other priorities, I'll defer this tech debt for now.

@jen-huang
Copy link
Contributor Author

@elasticmachine merge upstream

@jen-huang
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jen-huang jen-huang merged commit fba5128 into elastic:master Apr 30, 2020
@jen-huang jen-huang deleted the ingest/edit-ds branch April 30, 2020 01:03
jen-huang added a commit to jen-huang/kibana that referenced this pull request Apr 30, 2020
* Adjust NewDatasource type to exclude stream `agent_stream` property, add additional datasource hooks

* Initial pass at edit datasource UI

* Clean up dupe code, fix submit button not enabled after re-selecting a package

* Remove delete config functionality from list page

* Show validation errors for data source name and description fields

* Fix types

* Add success toasts

* Review fixes, clean up i18n

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jen-huang added a commit that referenced this pull request Apr 30, 2020
* Adjust NewDatasource type to exclude stream `agent_stream` property, add additional datasource hooks

* Initial pass at edit datasource UI

* Clean up dupe code, fix submit button not enabled after re-selecting a package

* Remove delete config functionality from list page

* Show validation errors for data source name and description fields

* Fix types

* Add success toasts

* Review fixes, clean up i18n

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Apr 30, 2020
* master: (42 commits)
  [Ingest] Allow aggent to send metadata compliant with ECS (elastic#64452)
  [Endpoint] Remove todos, urls to issues (elastic#64833)
  [Uptime] Remove hard coded value for monitor states histograms (elastic#64396)
  Feature/send feedback link (elastic#64845)
  [ML] Moving get filters capability to admin (elastic#64879)
  Remove edit alert button from alerts list (elastic#64643)
  [EPM] Handle constant_keyword type in KB index patterns and ES index templates (elastic#64876)
  [ML] Disable data frame anaylics clone button based on permission (elastic#64830)
  Dashboard url generator to preserve saved filters from destination dashboard (elastic#64767)
  add generic typings for SavedObjectMigrationFn (elastic#63943)
  Allow to define and update a defaultPath for applications (elastic#64498)
  [Event Log] add rel=primary to saved objects for query targets (elastic#64615)
  [Lens] Use a size of 5 for first string field in visualization (elastic#64726)
  [SIEM][Lists] Removes plugin dependencies, adds more unit tests, fixes more TypeScript types
  [Ingest] Edit datasource UI (elastic#64727)
  [Lens] Bind all time fields to the time picker (elastic#63874)
  [Lens] Use suggestion system in chart switcher for subtypes (elastic#64613)
  Improve alpha messaging (elastic#64692)
  [Ingest] Allow to enable monitoring of elastic agent (elastic#63598)
  [Metrics UI] Fix alerting when a filter query is present (elastic#64575)
  ...
jloleysens added a commit to jloleysens/kibana that referenced this pull request May 4, 2020
…bana into pipeline-editor-part-mvp-2

* 'feature/ingest-node-pipelines' of github.com:elastic/kibana: (90 commits)
  remove unused import
  address review feedback
  [Ingest pipelines] Cleanup (elastic#64794)
  [Ingest] Edit datasource UI (elastic#64727)
  [Lens] Bind all time fields to the time picker (elastic#63874)
  [Lens] Use suggestion system in chart switcher for subtypes (elastic#64613)
  Improve alpha messaging (elastic#64692)
  [Ingest] Allow to enable monitoring of elastic agent (elastic#63598)
  [Metrics UI] Fix alerting when a filter query is present (elastic#64575)
  skip flaky suite (elastic#64812) (elastic#64723)
  [Maps] do not display EMS or kibana layer wizards when not configured (elastic#64554)
  [Reporting/Test] Convert functional test code to Typescript (elastic#64601)
  make inserting timestamp with navigate methods optional with default true (elastic#64655)
  [EPM] Update UI to handle package versions and updates (elastic#64689)
  Minimize dependencies required by our telemetry middleware (elastic#64665)
  [Telemetry] oss api tests (elastic#64602)
  [ML] Adding endpoint capability checks (elastic#64662)
  Update jest config for coverage (elastic#64648)
  [SIEM][NP] Fixes bug in ML signals promotion (elastic#64720)
  share single data plugin bundle (elastic#64549)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Ingest] Agent configuration - edit data source UI
5 participants