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

[Enterprise Search][tech debt] Add Kea logic paths for easier debugging/defaults #77698

Merged
merged 3 commits into from
Sep 17, 2020

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Sep 17, 2020

Summary

Promise I'm not trying to steal your thunder @JasonStoltz - just want to keep commits as modular as possible, + this way it makes it easier for us to have a convo about this separately from the credentials logic :)

Per Jason's explanation on what Kea paths accomplish, these changes should:

  1. Make debugging w/ Redux DevTools: See https://kea.js.org/docs/guide/debugging/#logic-path

  1. Make initializing values via resetContext easier: https://kea.js.org/docs/api/context/#resetcontext

resetContext({
// the enterprise_search.app_search.credentials namespace is set in `path` in credentials_logic
defaults: {
enterprise_search: {
app_search: {
credentials: {
...defaults,
},
},
},
},
});
}

Checklist

  • All tests pass as before

@cee-chen cee-chen added Feature:Plugins release_note:skip Skip the PR/issue when compiling release notes v7.10.0 labels Sep 17, 2020
@@ -16,6 +16,7 @@ export interface IAppActions {
}

export const AppLogic = kea<MakeLogicType<IAppValues, IAppActions>>({
path: ['enterpriseSearch', 'appSearch', 'app'],
Copy link
Member Author

@cee-chen cee-chen Sep 17, 2020

Choose a reason for hiding this comment

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

@JasonStoltz changed from snake_case to camelCase, hope that's cool 🤔

Also... do we have any strong thoughts about using our common/constants.ts strings here? In theory this could be:

path: [ENTERPRISE_SEARCH_PLUGIN.ID, APP_SEARCH_PLUGIN.ID, 'app']

instead... but I don't know if that's necessarily better/easier to read lol? (I'm pretty lazy about constant strings when it comes to dev-only strings tbh though, it's one of my many failings)

Copy link
Contributor

Choose a reason for hiding this comment

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

tbh I like camel case because it matches the directory/file structure. If I saw enterprise_search -> app_search -> app_logic I know exactly what I need to type into the file jumper in vscode to get there. Otherwise if we use camelcase these should be names of the components and Logics [EnterpriseSearch, AppSearchConfigured, AppLogic]. If this is meant to ease debugging it should give me something I can easily search our codebase for to get to.

Copy link
Member

@JasonStoltz JasonStoltz Sep 17, 2020

Choose a reason for hiding this comment

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

Doesn't matter to me which we go with, I just want to get this merged

Copy link
Member Author

@cee-chen cee-chen Sep 17, 2020

Choose a reason for hiding this comment

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

tbh I like camel case

assuming you mean snake case, just to confirm?

re: names lining up with directory / file names:

I think if we want to guarantee that, we should just install babel-plugin-kea to automatically handle that for us. Otherwise, there's absolutely no guarantee that someone will name all logic files correctly in the future (for example, this line in question is app, not even appLogic).

I can definitely switch this PR over to just being yarn install if we're cool with it. Yay/nay?

Copy link
Contributor

Choose a reason for hiding this comment

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

assuming you mean snake case, just to confirm?

yeah sorry, I'm a idiot lmao

10000% for using this babel plugin

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome possum. Imma do it here shortly

Copy link
Member Author

Choose a reason for hiding this comment

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

After a bit more digging: sadly it's not that straightforward 😞 Since Kibana maintains it's own babel package/settings, we'll have to open an issue and get approval from the ops team after they evaluate the plugin.

Additionally, after looking at the plugin source code, it camelCases file names so it actually wouldn't achieve what Byron wants in any case (doh).

@byronhulcher it sounds like you have the strongest feelings here re: path names, so I'll go ahead and rename to snake_case as well as matching file names exactly. I'm also going to update our documentation/README to note our use of Kea and path names, and why we're specifically using snake_case for those lines.

Copy link
Contributor

@scottybollinger scottybollinger left a comment

Choose a reason for hiding this comment

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

LGTM. I personally lean against the constants in path, since this is dev-only

@@ -32,6 +32,7 @@ const convertToArray = (messages: IFlashMessage | IFlashMessage[]) =>
!Array.isArray(messages) ? [messages] : messages;

export const FlashMessagesLogic = kea<MakeLogicType<IFlashMessagesValues, IFlashMessagesActions>>({
path: ['enterprise_search', 'flash_messages_logic'],
Copy link
Member Author

Choose a reason for hiding this comment

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

@byronhulcher just wanted to highlight that this still doesn't "exactly" follow the file path (i.e. enterprise_search/public/applications/shared/flash_messages/flash_messages/logic), but hopefully the important part is the last key for file finding purposes 🤷

@cee-chen
Copy link
Member Author

cee-chen commented Sep 17, 2020

Re-requesting reviews from everyone (particularly on the docs!) 📖

@cee-chen
Copy link
Member Author

Final output:

Screen Shot 2020-09-17 at 10 14 06 AM

Screen Shot 2020-09-17 at 10 14 16 AM

BTW, I don't know if it's just me, but the Redux Devtools only works for me in Chrome and not Firefox. sad trombone noises

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.

Thank you.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
enterpriseSearch 434.0KB +353.0B 433.7KB

History

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

@cee-chen cee-chen merged commit 0a21d70 into elastic:master Sep 17, 2020
@cee-chen cee-chen deleted the kea-paths branch September 17, 2020 20:04
cee-chen pushed a commit that referenced this pull request Sep 17, 2020
…ng/defaults (#77698) (#77820)

* Add Kea logic paths for easier debugging/defaults

* PR feedback: prefer snake_case to match file names, use exact file name for last path key

* Document Kea + casing logic
gmmorris added a commit to gmmorris/kibana that referenced this pull request Sep 22, 2020
* master: (92 commits)
  [ILM] Data tiers for 7.10 (elastic#76126)
  [ML] Transforms: Fixes styling of preview grid pagination in summary step (elastic#77789)
  [Drilldowns] Beta badge support. Mark URL Drilldown as Beta (elastic#75654)
  Re-enable session lifespan, idle timeout api integration tests and use unique names for the security test reports. (elastic#77746)
  [Alerting] renames code in alerting RBAC exemption to make it easier to maintain (elastic#77598)
  [Alerting & Actions] Overwrite SOs when updating instead of partially updating (elastic#73688)
  fixed react warning in Suspense in alert flyout (elastic#77777)
  [APM] Track usage of Gold+ features (elastic#77630)
  Visualize: Bad request when working with histogram aggregation (elastic#77684)
  remove legacy ES plugin (elastic#77703)
  [Lens] change name of custom query to filters (elastic#77725)
  skip flaky suite (elastic#76239)
  remove visual aspects of baseline job (elastic#77815)
  skip flaky suite (elastic#77835)
  Fixes typo in data recognizer text (elastic#77691)
  management/update trusted_apps jest snapshot
  [build] Use Elastic hosted UBI minimal base image (elastic#77776)
  [APM] Add transaction error rate alert (elastic#76933)
  [Security Solution] [Detections] Remove file validation on import route (elastic#77770)
  [Enterprise Search][tech debt] Add Kea logic paths for easier debugging/defaults (elastic#77698)
  ...
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.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants