Skip to content

Commit

Permalink
Targeted renaming of SearchSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonStoltz committed Feb 3, 2021
1 parent 716ab23 commit 074190a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { LogicMounter } from '../../../__mocks__';

import { IBoostType } from './types';
import { BoostType } from './types';

import { RelevanceTuningLogic } from './relevance_tuning_logic';

Expand All @@ -15,7 +15,7 @@ describe('RelevanceTuningLogic', () => {
boosts: {
foo: [
{
type: 'value' as IBoostType,
type: 'value' as BoostType,
factor: 5,
},
],
Expand All @@ -24,7 +24,7 @@ describe('RelevanceTuningLogic', () => {
};
const schema = {};
const schemaConflicts = {};
const searchSettingProps = {
const relevanceTuningProps = {
searchSettings,
schema,
schemaConflicts,
Expand Down Expand Up @@ -61,12 +61,12 @@ describe('RelevanceTuningLogic', () => {
});

describe('actions', () => {
describe('onInitializeSearchSettings', () => {
describe('onInitializeRelevanceTuning', () => {
it('should set state', () => {
mount({
dataLoading: true,
});
RelevanceTuningLogic.actions.onInitializeSearchSettings(searchSettingProps);
RelevanceTuningLogic.actions.onInitializeRelevanceTuning(relevanceTuningProps);

expect(RelevanceTuningLogic.values).toEqual({
...DEFAULT_VALUES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import { kea, MakeLogicType } from 'kea';

import { Schema, SchemaConflicts } from '../../../shared/types';
import { ISearchSettings } from './types';

interface ISearchSettingsProps {
searchSettings: ISearchSettings;
import { SearchSettings } from './types';

interface RelevanceTuningProps {
searchSettings: SearchSettings;
schema: Schema;
schemaConflicts: SchemaConflicts;
}

interface ISearchSettingsActions {
onInitializeSearchSettings(props: ISearchSettingsProps): ISearchSettingsProps;
setSearchSettings(searchSettings: ISearchSettings): { searchSettings: ISearchSettings };
interface RelevanceTuningActions {
onInitializeRelevanceTuning(props: RelevanceTuningProps): RelevanceTuningProps;
setSearchSettings(searchSettings: SearchSettings): { searchSettings: SearchSettings };
setFilterValue(value: string): string;
setSearchQuery(value: string): string;
setSearchResults(searchResults: object[]): object[];
Expand All @@ -27,8 +28,8 @@ interface ISearchSettingsActions {
dismissSchemaConflictCallout(): void;
}

interface ISearchSettingsValues {
searchSettings: Partial<ISearchSettings>;
interface RelevanceTuningValues {
searchSettings: Partial<SearchSettings>;
schema: Schema;
dataLoading: boolean;
schemaConflicts: SchemaConflicts;
Expand All @@ -51,11 +52,11 @@ const filterIfTerm = (array: string[], filterTerm: string): string[] => {
};

export const RelevanceTuningLogic = kea<
MakeLogicType<ISearchSettingsValues, ISearchSettingsActions>
MakeLogicType<RelevanceTuningValues, RelevanceTuningActions>
>({
path: ['enterprise_search', 'app_search', 'relevance_tuning_logic'],
actions: () => ({
onInitializeSearchSettings: (props) => props,
onInitializeRelevanceTuning: (props) => props,
setSearchSettings: (searchSettings) => ({ searchSettings }),
setFilterValue: (value) => value,
setSearchQuery: (query) => query,
Expand All @@ -69,27 +70,27 @@ export const RelevanceTuningLogic = kea<
searchSettings: [
{},
{
onInitializeSearchSettings: (_, { searchSettings }) => searchSettings,
onInitializeRelevanceTuning: (_, { searchSettings }) => searchSettings,
setSearchSettings: (_, { searchSettings }) => searchSettings,
},
],
schema: [
{},
{
onInitializeSearchSettings: (_, { schema }) => schema,
onInitializeRelevanceTuning: (_, { schema }) => schema,
},
],
dataLoading: [
true,
{
onInitializeSearchSettings: () => false,
onInitializeRelevanceTuning: () => false,
resetSearchSettingsState: () => true,
},
],
schemaConflicts: [
{},
{
onInitializeSearchSettings: (_, { schemaConflicts }) => schemaConflicts,
onInitializeRelevanceTuning: (_, { schemaConflicts }) => schemaConflicts,
},
],
unsavedChanges: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

export type IBoostType = 'value' | 'functional' | 'proximity';
export type BoostType = 'value' | 'functional' | 'proximity';

export interface IBoost {
type: IBoostType;
type: BoostType;
operation?: string;
function?: string;
newBoost?: boolean;
Expand All @@ -16,11 +16,11 @@ export interface IBoost {
factor: number;
}

export interface IBoostObject {
export interface BoostObject {
[key: string]: IBoost[];
}

export interface ISearchSettings {
boosts: IBoostObject;
export interface SearchSettings {
boosts: BoostObject;
search_fields: object;
}

0 comments on commit 074190a

Please sign in to comment.