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

[App Search] Credentials: implement working flyout form #81541

Merged
merged 9 commits into from
Oct 26, 2020

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Oct 22, 2020

PR sequence

This PR is part of a set of 3 PRs that implements the Credentials flyout form + functionality. It's broken up into PRs in the 400-800 line range so as not to open a 1700~ line PR.

List of all PRs (may be helpful for obtaining more context / QAing the entire final feature)

Summary

This PR achieves:

  • Adding all Credentials form fields as sub-components
  • Entire form working and submitting - users should be able to create and edit keys from the flyout

Screencaps

Creating, updating, and deleting a key:

screencap

Example errors returned by API:

^ Note - I don't super love how the errors are "off screen" and sometimes not visible on smaller screens. I wish there was a way to address this, but it's probably out of scope for the migration. We also have the same issue on some scrolling modals so it's potentially something to address all at once later.

QA

  • Creating a key
    • Confirm that creating a key works (success message, credentials table is updated)
    • Admin keys
      • Confirm that when creating an admin key, you only see the Name and Type fields
    • Private keys
      • Confirm that when creating a private key, you see all fields (Name, Type, Read/Write access, Engine access)
    • Search keys
      • Confirm that when creating a search key, you see the engine access field but not the read/write access field
  • Updating a key
    • Confirm that when you click the pencil icon to edit an existing key, the Name and Type form fields are disabled / cannot be modified
    • Confirm that you can edit a private key's read/write access levels. Confirm that on refreshing the page, your updated settings are 'remembered'
    • Confirm that you can edit a search key's engine access. Confirm that on refreshing the page, your updated settings are 'remembered'
  • Deleting a key
    • Confirm that deleting a key works and shows a flash message
  • Expected errors
    • Confirm that trying to create a key with no name generates an understandable error
    • Confirm that trying to save a private key with neither read nor write access generates an understandable error
    • Confirm that trying to save a search key without access to any engines generates an understandable error

Checklist

Comment on lines +7 to +11
export { FormKeyName } from './key_name';
export { FormKeyType } from './key_type';
export { FormKeyReadWriteAccess } from './key_read_write_access';
export { FormKeyEngineAccess } from './key_engine_access';
export { FormKeyUpdateWarning } from './key_update_warning';
Copy link
Contributor Author

@cee-chen cee-chen Oct 22, 2020

Choose a reason for hiding this comment

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

Super quick note about the naming schema I went with - I'm not in love with it or anything so definitely happy to take suggestions. One thing that drives me slightly nuts (but no idea how to fix lol) is the alternating terminology we use:

  1. "Credentials" in the routing/file/folder names
  2. "Tokens" in our actual code vars
  3. "API Keys" in our user-facing copy (and now I guess these file names)

Anyway, don't mind me, I'm just dead inside over here

Comment on lines 34 to 44
<p>
{tokenDescription && <strong>{tokenDescription}</strong>}{' '}
<EuiLink href={DOCS_HREF}>
{i18n.translate('xpack.enterpriseSearch.appSearch.tokens.documentationLink1', {
defaultMessage: 'Visit the documentation',
})}
</EuiLink>{' '}
{i18n.translate('xpack.enterpriseSearch.appSearch.tokens.documentationLink2', {
defaultMessage: 'to learn more about keys.',
})}
</p>
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'm not sure if there's a better way of i18n'ing sentences broken up by JSX/HTML (a link in this case). Hoping our amazing i18n folks are ok handling this 😬

@cee-chen cee-chen force-pushed the credentials-flyout-3 branch from 005f93d to 05b1625 Compare October 22, 2020 22:10
Copy link
Member

@JasonStoltz JasonStoltz left a comment

Choose a reason for hiding this comment

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

The way you broke these down into independent form components makes the code, and this PR, way more manageable. Thank you for doing that.

I don't have any blocking feedback, but I did make some comments to consider.

Great work on this.

);
};

export const EngineSelection: React.FC = () => {
Copy link
Member

Choose a reason for hiding this comment

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

Are you OK with the fact that we're exporting two components from a single file? Seems counter to common practice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely my opinion, but I don't think there's a standard/best practice for this. I generally prefer taking advantage of multiple exports (the same way we export multiple string consts, utility fns, etc.) and I don't 100% see why components are significantly different.

In this case EngineSelection is a subcomponent and primarily exported to make unit testing easier - but I think that's a feature, not a bug, of unit testing, because it helps us break code down into substantially more readable blocks. I also don't think exporting for the sake of a test file is a major faux pas or anything - conceptually it's not any different from mocks or other const's exported to make tests easier.

@@ -21,7 +21,7 @@ import { IMeta } from '../../../../../common/types';
import { IEngine } from '../../types';
import { IApiToken, ICredentialsDetails, ITokenReadWrite } from './types';

const defaultApiToken: IApiToken = {
export const defaultApiToken: IApiToken = {
Copy link
Member

Choose a reason for hiding this comment

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

Nice way to clean up tests 👍

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

@kbn/optimizer bundle module count

id before after diff
enterpriseSearch 429 435 +6

async chunks size

id before after diff
enterpriseSearch 657.3KB 670.1KB +12.8KB

History

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

@cee-chen cee-chen merged commit 7508321 into elastic:master Oct 26, 2020
cee-chen pushed a commit to cee-chen/kibana that referenced this pull request Oct 26, 2020
* Add key name field

* Add key type field

* Add key read/write fields

* Add key engine access / selection

* Add key update warning callout

* Update flyout body with form components

* [PR feedback] i18n - change appSearch.tokens to appSearch.credentials

* [PR feedback] Remove unnecessary conditional
@cee-chen cee-chen deleted the credentials-flyout-3 branch October 26, 2020 18:31
cee-chen pushed a commit that referenced this pull request Oct 26, 2020
)

* Add key name field

* Add key type field

* Add key read/write fields

* Add key engine access / selection

* Add key update warning callout

* Update flyout body with form components

* [PR feedback] i18n - change appSearch.tokens to appSearch.credentials

* [PR feedback] Remove unnecessary conditional

Co-authored-by: Kibana Machine <[email protected]>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Oct 27, 2020
* master: (37 commits)
  [ILM] Migrate Warm phase to Form Lib (elastic#81323)
  [Security Solutions][Detection Engine] Fixes critical bug with error reporting that was doing a throw (elastic#81549)
  [Detection Rules] Add 7.10 rules (elastic#81676)
  [kbn/optimizer] ignore missing metrics when updating limits with --focus (elastic#81696)
  [SECURITY SOLUTIONS] Bugs overview page + investigate eql in timeline (elastic#81550)
  [Maps] fix unable to edit cluster vector styles styled by count when switching to super fine grid resolution (elastic#81525)
  Fixed migration issue for case specific actions, by extending email action migrator checks (elastic#81673)
  [CI] Preparation for APM tracking on CI (elastic#80399)
  [Home] Fixes Kibana app description order on home page and updates Canvas copy (elastic#80057)
  Make sure `to` is 'now' and not the same as `from` (elastic#81524)
  Nitpicking the 8.0 Breaking Change issue template (elastic#81678)
  [SECURITY_SOLUTION] Fix text on onboarding screen (elastic#81672)
  [data.search] Skip async search tests in build candidates and production builds (elastic#81547)
  Fix previousStartedAt by not changing when execution fails (elastic#81388)
  [Monitoring] Fix a couple of issues with the cpu usage alert (elastic#80737)
  Telemetry collection xpack to ts project references (elastic#81269)
  Elasticsearch: don't use url authentication for new client (elastic#81564)
  [App Search] Credentials: implement working flyout form (elastic#81541)
  Properly encode links to edit user page (elastic#81562)
  [Alerting UI] Don't wait for health check before showing Create Alert flyout (elastic#80996)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants