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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.

actions: {
initializeAppData: (props) => props,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const convertToArray = (messages: IFlashMessage | IFlashMessage[]) =>
!Array.isArray(messages) ? [messages] : messages;

export const FlashMessagesLogic = kea<MakeLogicType<IFlashMessagesValues, IFlashMessagesActions>>({
path: ['enterpriseSearch', 'flashMessages'],
actions: {
setFlashMessages: (messages) => ({ messages: convertToArray(messages) }),
clearFlashMessages: () => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface IHttpActions {
}

export const HttpLogic = kea<MakeLogicType<IHttpValues, IHttpActions>>({
path: ['enterpriseSearch', 'http'],
actions: {
initializeHttp: ({ http, errorConnecting }) => ({ http, errorConnecting }),
initializeHttpInterceptors: () => null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface IAppActions {
}

export const AppLogic = kea<MakeLogicType<IAppValues, IAppActions>>({
path: ['enterpriseSearch', 'workplaceSearch', 'app'],
actions: {
initializeAppData: ({ workplaceSearch, isFederatedAuth }) => ({
workplaceSearch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface IOverviewValues extends IOverviewServerData {
}

export const OverviewLogic = kea<MakeLogicType<IOverviewValues, IOverviewActions>>({
path: ['enterpriseSearch', 'workplaceSearch', 'overview'],
actions: {
setServerData: (serverData) => serverData,
initializeOverview: () => null,
Expand Down