forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Adds app logic file to Workplace Search (elastic#…
…76009) (elastic#76040) * Add new Workplace Search initial data properties * Add app logic * Refactor index to match App Search Adds the easier-to-read ComponentConfigured and ComponentUnconfigured FCs with a ternary in the root compoenent * Remove ‘Logic’ from interface names * Extract initial data from WS into interface This allows for breaking apart the app-specific data and also having an interface to extend in the app_logic file * Destructuring FTW
- Loading branch information
1 parent
deb3559
commit ee66836
Showing
9 changed files
with
165 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
x-pack/plugins/enterprise_search/public/applications/workplace_search/app_logic.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { resetContext } from 'kea'; | ||
|
||
import { DEFAULT_INITIAL_APP_DATA } from '../../../common/__mocks__'; | ||
import { AppLogic } from './app_logic'; | ||
|
||
describe('AppLogic', () => { | ||
beforeEach(() => { | ||
resetContext({}); | ||
AppLogic.mount(); | ||
}); | ||
|
||
const DEFAULT_VALUES = { | ||
hasInitialized: false, | ||
}; | ||
|
||
it('has expected default values', () => { | ||
expect(AppLogic.values).toEqual(DEFAULT_VALUES); | ||
}); | ||
|
||
describe('initializeAppData()', () => { | ||
it('sets values based on passed props', () => { | ||
AppLogic.actions.initializeAppData(DEFAULT_INITIAL_APP_DATA); | ||
|
||
expect(AppLogic.values).toEqual({ | ||
hasInitialized: true, | ||
}); | ||
}); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/enterprise_search/public/applications/workplace_search/app_logic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { kea } from 'kea'; | ||
|
||
import { IInitialAppData } from '../../../common/types'; | ||
import { IWorkplaceSearchInitialData } from '../../../common/types/workplace_search'; | ||
import { IKeaLogic } from '../shared/types'; | ||
|
||
export interface IAppValues extends IWorkplaceSearchInitialData { | ||
hasInitialized: boolean; | ||
} | ||
export interface IAppActions { | ||
initializeAppData(props: IInitialAppData): void; | ||
} | ||
|
||
export const AppLogic = kea({ | ||
actions: (): IAppActions => ({ | ||
initializeAppData: ({ workplaceSearch }) => workplaceSearch, | ||
}), | ||
reducers: () => ({ | ||
hasInitialized: [ | ||
false, | ||
{ | ||
initializeAppData: () => true, | ||
}, | ||
], | ||
}), | ||
}) as IKeaLogic<IAppValues, IAppActions>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters