-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Populate database filter dropdown in stmts page with `SHOW DATABA…
…SES` sql-over-http call Fixes: #70461. Previously, the databases filter dropdown was populated by the `StatementsResponse` API call. This would result in some databases for which we do not receive any stmts to be ignored. According to above issue, the database filter-drop down should always be populated with cluster databases even when there are no statements or transactions for them. This commit populates the database filter dropdown using the `getDatabasesList()` API call which itself executes the `SHOW DATABASES` SQL query. Release note (ui change): The databases filter dropdown in the stmts page now uses the `getDatabasesList()` API call, resulting in all cluster databases showing up.
- Loading branch information
Showing
10 changed files
with
150 additions
and
30 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
47 changes: 47 additions & 0 deletions
47
pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.reducers.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,47 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
import { DatabasesListResponse } from "src/api"; | ||
import { DOMAIN_NAME } from "../utils"; | ||
|
||
import { SqlExecutionRequest } from "../../api/sqlApi"; | ||
|
||
export type DatabasesListState = { | ||
data: DatabasesListResponse; | ||
lastError: Error; | ||
valid: boolean; | ||
}; | ||
|
||
const initialState: DatabasesListState = { | ||
data: null, | ||
lastError: null, | ||
valid: true, | ||
}; | ||
|
||
const databasesListSlice = createSlice({ | ||
name: `${DOMAIN_NAME}/databasesList`, | ||
initialState, | ||
reducers: { | ||
received: (state, action: PayloadAction<DatabasesListResponse>) => { | ||
state.data = action.payload; | ||
state.valid = true; | ||
state.lastError = null; | ||
}, | ||
failed: (state, action: PayloadAction<Error>) => { | ||
state.valid = false; | ||
state.lastError = action.payload; | ||
}, | ||
refresh: (_, action: PayloadAction<SqlExecutionRequest>) => {}, | ||
request: (_, action: PayloadAction<SqlExecutionRequest>) => {}, | ||
}, | ||
}); | ||
|
||
export const { reducer, actions } = databasesListSlice; |
34 changes: 34 additions & 0 deletions
34
pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.saga.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,34 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import { all, call, put, takeLatest } from "redux-saga/effects"; | ||
|
||
import { actions } from "./databasesList.reducers"; | ||
import { getDatabasesList } from "src/api"; | ||
|
||
export function* refreshDatabasesListSaga() { | ||
yield put(actions.request()); | ||
} | ||
|
||
export function* requestDatabasesListSaga(): any { | ||
try { | ||
const result = yield call(getDatabasesList); | ||
yield put(actions.received(result)); | ||
} catch (e) { | ||
yield put(actions.failed(e)); | ||
} | ||
} | ||
|
||
export function* databasesListSaga() { | ||
yield all([ | ||
takeLatest(actions.refresh, refreshDatabasesListSaga), | ||
takeLatest(actions.request, requestDatabasesListSaga), | ||
]); | ||
} |
17 changes: 17 additions & 0 deletions
17
pkg/ui/workspaces/cluster-ui/src/store/databasesList/databasesList.selectors.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,17 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
import { createSelector } from "reselect"; | ||
import { adminUISelector } from "../utils/selectors"; | ||
|
||
export const databasesListSelector = createSelector( | ||
adminUISelector, | ||
adminUiState => adminUiState.databasesList, | ||
); |
12 changes: 12 additions & 0 deletions
12
pkg/ui/workspaces/cluster-ui/src/store/databasesList/index.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,12 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
export * from "./databasesList.reducers"; | ||
export * from "./databasesList.saga"; |
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