-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: open search indexes table when a search index is created COMPAS…
…S-7247 (#4915) * chore: open search indexes table when a search index is created * chore: fix linting issues * chore: add index list view state to redux * chore: fix linter * chore: revert not necessary changes * chore: add test to open search indexes view when a search index is created * chore: rename the slice to a more clear name * chore: fix linter issues * chore: fix naming * chore: remove unnecessary callback
- Loading branch information
Showing
10 changed files
with
134 additions
and
40 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect } from 'chai'; | ||
|
||
import reducer, { | ||
INITIAL_STATE, | ||
switchToRegularIndexes, | ||
switchToSearchIndexes, | ||
} from './index-view'; | ||
|
||
describe('index-view view module', function () { | ||
describe('#reducer', function () { | ||
context('when an action is not valid', function () { | ||
it('returns the state', function () { | ||
expect(reducer(INITIAL_STATE, { type: 'test' })).to.equal( | ||
INITIAL_STATE | ||
); | ||
}); | ||
}); | ||
|
||
context('when an action is switchToRegularIndexes', function () { | ||
it('state is regular-indexes', function () { | ||
expect(reducer(INITIAL_STATE, switchToRegularIndexes())).to.equal( | ||
'regular-indexes' | ||
); | ||
}); | ||
}); | ||
|
||
context('when an action is switchToSearchIndexes', function () { | ||
it('state is search-indexes', function () { | ||
expect(reducer(INITIAL_STATE, switchToSearchIndexes())).to.equal( | ||
'search-indexes' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
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,31 @@ | ||
import type { AnyAction } from 'redux'; | ||
import { isAction } from '../utils/is-action'; | ||
|
||
export type IndexView = 'regular-indexes' | 'search-indexes'; | ||
|
||
export enum ActionTypes { | ||
ChangeIndexView = 'index-list/ChangeIndexView', | ||
} | ||
|
||
type ChangeIndexViewAction = { | ||
type: ActionTypes.ChangeIndexView; | ||
view: IndexView; | ||
}; | ||
|
||
export const INITIAL_STATE: IndexView = 'regular-indexes'; | ||
|
||
export default function reducer(state = INITIAL_STATE, action: AnyAction) { | ||
if (isAction<ChangeIndexViewAction>(action, ActionTypes.ChangeIndexView)) { | ||
return action.view; | ||
} | ||
|
||
return state; | ||
} | ||
|
||
export const changeIndexView = (view: IndexView): ChangeIndexViewAction => ({ | ||
type: ActionTypes.ChangeIndexView, | ||
view: view, | ||
}); | ||
|
||
export const switchToRegularIndexes = () => changeIndexView('regular-indexes'); | ||
export const switchToSearchIndexes = () => changeIndexView('search-indexes'); |
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