mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
parent
f71384e9f9
commit
677b102f7d
4 changed files with 16 additions and 3 deletions
|
@ -41,6 +41,7 @@ export const repositoryTypeaheadSearchFailed = createAction<string>('REPOSITORY
|
|||
export const saveSearchOptions = createAction<SearchOptions>('SAVE SEARCH OPTIONS');
|
||||
|
||||
export const turnOnDefaultRepoScope = createAction<Repository>('TURN ON DEFAULT REPO SCOPE');
|
||||
export const turnOffDefaultRepoScope = createAction('TURN OFF DEFAULT REPO SCOPE');
|
||||
|
||||
export const searchReposForScope = createAction<RepositorySearchPayload>('SEARCH REPOS FOR SCOPE');
|
||||
export const searchReposForScopeSuccess = createAction<any>('SEARCH REPOS FOR SCOPE SUCCESS');
|
||||
|
|
|
@ -51,8 +51,7 @@ export class SearchOptions extends Component<Props, State> {
|
|||
|
||||
componentDidUpdate(prevProps: Props) {
|
||||
if (
|
||||
this.props.searchOptions.defaultRepoScopeOn &&
|
||||
!prevProps.searchOptions.defaultRepoScopeOn
|
||||
this.props.searchOptions.defaultRepoScopeOn !== prevProps.searchOptions.defaultRepoScopeOn
|
||||
) {
|
||||
this.setState({ defaultRepoScopeOn: this.props.searchOptions.defaultRepoScopeOn });
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import {
|
|||
saveSearchOptions,
|
||||
searchReposForScope,
|
||||
searchReposForScopeSuccess,
|
||||
turnOffDefaultRepoScope,
|
||||
turnOnDefaultRepoScope,
|
||||
} from '../actions';
|
||||
|
||||
|
@ -179,6 +180,11 @@ export const search = handleActions<SearchState, any>(
|
|||
draft.searchOptions.defaultRepoScope = action.payload;
|
||||
draft.searchOptions.defaultRepoScopeOn = true;
|
||||
}),
|
||||
[String(turnOffDefaultRepoScope)]: (state: SearchState, action: Action<any>) =>
|
||||
produce<SearchState>(state, draft => {
|
||||
delete draft.searchOptions.defaultRepoScope;
|
||||
draft.searchOptions.defaultRepoScopeOn = false;
|
||||
}),
|
||||
},
|
||||
initialState
|
||||
);
|
||||
|
|
|
@ -25,8 +25,9 @@ import {
|
|||
searchReposForScope,
|
||||
searchReposForScopeFailed,
|
||||
searchReposForScopeSuccess,
|
||||
turnOffDefaultRepoScope,
|
||||
} from '../actions';
|
||||
import { searchRoutePattern } from './patterns';
|
||||
import { adminRoutePattern, searchRoutePattern } from './patterns';
|
||||
|
||||
function requestDocumentSearch(payload: DocumentSearchPayload) {
|
||||
const { query, page, languages, repositories, repoScope } = payload;
|
||||
|
@ -123,8 +124,14 @@ function* handleSearchRouteChange(action: Action<Match>) {
|
|||
}
|
||||
}
|
||||
|
||||
function* resetDefaultRepoScope() {
|
||||
yield put(turnOffDefaultRepoScope());
|
||||
}
|
||||
|
||||
export function* watchSearchRouteChange() {
|
||||
yield takeLatest(searchRoutePattern, handleSearchRouteChange);
|
||||
// Reset the default search scope if enters the admin page.
|
||||
yield takeLatest(adminRoutePattern, resetDefaultRepoScope);
|
||||
}
|
||||
|
||||
function* handleReposSearchForScope(action: Action<RepositorySearchPayload>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue