From 25349152cd791dd298ea9d86b17ffc509f2b7974 Mon Sep 17 00:00:00 2001 From: maryliag Date: Wed, 29 Mar 2023 18:22:52 +0000 Subject: [PATCH] ui: add checks for values Fixes #99655 Fixes #99538 Fixes #99539 Add checks to usages that could cause `Cannot read properties of undefined`. Release note: None --- .../cluster-ui/src/api/schemaInsightsApi.ts | 3 +++ .../cluster-ui/src/api/txnInsightsApi.ts | 2 +- .../databaseDetailsPage/databaseDetailsPage.tsx | 14 ++++++-------- .../cluster-ui/src/databasesPage/databasesPage.tsx | 14 ++++++-------- .../src/highlightedText/highlightedText.tsx | 2 +- .../multiSelectCheckbox/multiSelectCheckbox.tsx | 11 ++++++----- .../src/selectors/recentExecutions.selectors.ts | 2 +- .../src/sessions/sessionsPageConnected.tsx | 6 +++--- .../workspaces/cluster-ui/src/sqlActivity/util.tsx | 8 ++++---- .../statementDetails/planDetails/planDetails.tsx | 3 +++ .../src/statementsPage/statementsPage.selectors.ts | 12 ++++++------ .../src/statementsPage/statementsPage.tsx | 2 +- .../statementInsights.selectors.ts | 2 +- .../cluster-ui/src/store/jobs/jobs.selectors.ts | 2 +- .../src/store/sessions/sessions.selectors.ts | 2 +- .../transactionsPage/transactionsPage.selectors.ts | 2 +- .../cluster-ui/src/transactionsPage/utils.ts | 4 ++-- pkg/ui/workspaces/cluster-ui/src/util/format.ts | 2 +- .../workspaces/cluster-ui/src/util/formatNumber.ts | 2 +- .../redux/indexUsageStats/indexUsageStatsSagas.ts | 3 +++ .../src/selectors/recentExecutionsSelectors.ts | 2 +- .../db-console/src/util/highlightedText.tsx | 2 +- .../src/views/sessions/sessionDetails.tsx | 2 +- .../db-console/src/views/sessions/sessionsPage.tsx | 4 ++-- .../src/views/statements/statementsPage.tsx | 10 +++++----- .../src/views/transactions/transactionsPage.tsx | 2 +- 26 files changed, 63 insertions(+), 57 deletions(-) diff --git a/pkg/ui/workspaces/cluster-ui/src/api/schemaInsightsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/schemaInsightsApi.ts index 64794d20bd33..04b688358c36 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/schemaInsightsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/schemaInsightsApi.ts @@ -95,6 +95,9 @@ function createIndexRecommendationsToSchemaInsight( txn_result.rows.forEach(row => { row.index_recommendations.forEach(rec => { + if (!rec.includes(" : ")) { + return; + } const recSplit = rec.split(" : "); const recType = recSplit[0]; const recQuery = recSplit[1]; diff --git a/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts b/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts index 1e7b99a3c564..61767edd6e2c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts +++ b/pkg/ui/workspaces/cluster-ui/src/api/txnInsightsApi.ts @@ -384,7 +384,7 @@ function formatTxnInsightsRow(row: TxnInsightsResponseRow): TxnInsightEvent { transactionExecutionID: row.txn_id, transactionFingerprintID: row.txn_fingerprint_id, implicitTxn: row.implicit_txn, - query: row.query.split(" ; ").join("\n"), + query: row.query?.split(" ; ").join("\n") || "", startTime, endTime, elapsedTimeMillis: endTime.diff(startTime, "milliseconds"), diff --git a/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx index de00c45ade4b..a18f026a036c 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/databaseDetailsPage/databaseDetailsPage.tsx @@ -378,9 +378,9 @@ export class DatabaseDetailsPage extends React.Component< const { search, tables, filters, nodeRegions } = this.props; const regionsSelected = - filters.regions.length > 0 ? filters.regions.split(",") : []; + filters.regions?.length > 0 ? filters.regions.split(",") : []; const nodesSelected = - filters.nodes.length > 0 ? filters.nodes.split(",") : []; + filters.nodes?.length > 0 ? filters.nodes.split(",") : []; return tables .filter(table => (search ? filterBySearchQuery(table, search) : true)) @@ -392,13 +392,11 @@ export class DatabaseDetailsPage extends React.Component< let foundNode = nodesSelected.length == 0; table.details.nodes?.forEach(node => { - if ( - foundRegion || - regionsSelected.includes(nodeRegions[node.toString()]) - ) { + const n = node?.toString() || ""; + if (foundRegion || regionsSelected.includes(nodeRegions[n])) { foundRegion = true; } - if (foundNode || nodesSelected.includes("n" + node.toString())) { + if (foundNode || nodesSelected.includes("n" + n)) { foundNode = true; } if (foundNode && foundRegion) return true; @@ -738,7 +736,7 @@ export class DatabaseDetailsPage extends React.Component< hideAppNames={true} regions={regions} hideTimeLabel={true} - nodes={nodes.map(n => "n" + n.toString())} + nodes={nodes.map(n => "n" + n?.toString())} activeFilters={activeFilters} filters={defaultFilters} onSubmitFilters={this.onSubmitFilters} diff --git a/pkg/ui/workspaces/cluster-ui/src/databasesPage/databasesPage.tsx b/pkg/ui/workspaces/cluster-ui/src/databasesPage/databasesPage.tsx index b268e3ae9594..9d965bf6f463 100644 --- a/pkg/ui/workspaces/cluster-ui/src/databasesPage/databasesPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/databasesPage/databasesPage.tsx @@ -424,9 +424,9 @@ export class DatabasesPage extends React.Component< // The regions and nodes selected from the filter dropdown. const regionsSelected = - filters.regions.length > 0 ? filters.regions.split(",") : []; + filters.regions?.length > 0 ? filters.regions.split(",") : []; const nodesSelected = - filters.nodes.length > 0 ? filters.nodes.split(",") : []; + filters.nodes?.length > 0 ? filters.nodes.split(",") : []; return databases .filter(db => (search ? filterBySearchQuery(db, search) : true)) @@ -438,13 +438,11 @@ export class DatabasesPage extends React.Component< let foundNode = nodesSelected.length == 0; db.nodes?.forEach(node => { - if ( - foundRegion || - regionsSelected.includes(nodeRegions[node.toString()]) - ) { + const n = node?.toString() || ""; + if (foundRegion || regionsSelected.includes(nodeRegions[n])) { foundRegion = true; } - if (foundNode || nodesSelected.includes("n" + node.toString())) { + if (foundNode || nodesSelected.includes("n" + n)) { foundNode = true; } if (foundNode && foundRegion) return true; @@ -617,7 +615,7 @@ export class DatabasesPage extends React.Component< hideAppNames={true} regions={regions} hideTimeLabel={true} - nodes={nodes.map(n => "n" + n.toString())} + nodes={nodes.map(n => "n" + n?.toString())} activeFilters={activeFilters} filters={defaultFilters} onSubmitFilters={this.onSubmitFilters} diff --git a/pkg/ui/workspaces/cluster-ui/src/highlightedText/highlightedText.tsx b/pkg/ui/workspaces/cluster-ui/src/highlightedText/highlightedText.tsx index 7858a0ce3abc..6025a275dfa4 100644 --- a/pkg/ui/workspaces/cluster-ui/src/highlightedText/highlightedText.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/highlightedText/highlightedText.tsx @@ -97,7 +97,7 @@ export function getHighlightedText( }) .join("|"); const parts = isOriginalText - ? text.split(new RegExp(`(${search})`, "gi")) + ? text?.split(new RegExp(`(${search})`, "gi")) : rebaseText(text, highlight).split(new RegExp(`(${search})`, "gi")); const highlightClass = hasDarkBkg ? "_text-bold-light" : "_text-bold"; return parts.map((part, i) => { diff --git a/pkg/ui/workspaces/cluster-ui/src/multiSelectCheckbox/multiSelectCheckbox.tsx b/pkg/ui/workspaces/cluster-ui/src/multiSelectCheckbox/multiSelectCheckbox.tsx index 417f9440ba4c..fc8ebce86ecc 100644 --- a/pkg/ui/workspaces/cluster-ui/src/multiSelectCheckbox/multiSelectCheckbox.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/multiSelectCheckbox/multiSelectCheckbox.tsx @@ -102,11 +102,12 @@ export const MultiSelectCheckbox = (props: MultiSelectCheckboxProps) => { field: string, parent: any, ) => { - const selected = selectedOptions - .map(function (option: SelectOption) { - return option.label; - }) - .toString(); + const selected = + selectedOptions + ?.map(function (option: SelectOption) { + return option.label; + }) + .toString() || ""; parent.setState({ filters: { ...parent.state.filters, diff --git a/pkg/ui/workspaces/cluster-ui/src/selectors/recentExecutions.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/selectors/recentExecutions.selectors.ts index e790115fe9d4..75cb2fa25432 100644 --- a/pkg/ui/workspaces/cluster-ui/src/selectors/recentExecutions.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/selectors/recentExecutions.selectors.ts @@ -96,7 +96,7 @@ export const selectContentionDetailsForStatement = createSelector( export const selectAppName = createSelector( (state: AppState) => state.adminUI?.sessions, response => { - if (!response.data) return null; + if (!response?.data) return null; return response.data.internal_app_name_prefix; }, ); diff --git a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx index b6e8732ba1c8..633d6145b42b 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sessions/sessionsPageConnected.tsx @@ -36,7 +36,7 @@ export const selectSessionsData = createSelector( export const selectSessions = createSelector( (state: AppState) => state.adminUI?.sessions, (state: SessionsState) => { - if (!state.data) { + if (!state?.data) { return null; } return state.data.sessions.map(session => { @@ -48,7 +48,7 @@ export const selectSessions = createSelector( export const selectAppName = createSelector( (state: AppState) => state.adminUI?.sessions, (state: SessionsState) => { - if (!state.data) { + if (!state?.data) { return null; } return state.data.internal_app_name_prefix; @@ -64,7 +64,7 @@ export const selectColumns = createSelector( localStorageSelector, localStorage => localStorage["showColumns/SessionsPage"] - ? localStorage["showColumns/SessionsPage"].split(",") + ? localStorage["showColumns/SessionsPage"]?.split(",") : null, ); diff --git a/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx b/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx index 5f0bb539cc4e..d770226c812a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/sqlActivity/util.tsx @@ -22,7 +22,7 @@ export function filteredStatementsData( ): AggregateStatistics[] { const timeValue = getTimeValueInSeconds(filters); const sqlTypes = - filters.sqlType.length > 0 + filters.sqlType?.length > 0 ? filters.sqlType.split(",").map(function (sqlType: string) { // Adding "Type" to match the value on the Statement // Possible values: TypeDDL, TypeDML, TypeDCL and TypeTCL @@ -30,12 +30,12 @@ export function filteredStatementsData( }) : []; const databases = - filters.database.length > 0 ? filters.database.split(",") : []; + filters.database?.length > 0 ? filters.database.split(",") : []; if (databases.includes(unset)) { databases.push(""); } - const regions = filters.regions.length > 0 ? filters.regions.split(",") : []; - const nodes = filters.nodes.length > 0 ? filters.nodes.split(",") : []; + const regions = filters.regions?.length > 0 ? filters.regions.split(",") : []; + const nodes = filters.nodes?.length > 0 ? filters.nodes.split(",") : []; // Return statements filtered by the values selected on the filter and // the search text. A statement must match all selected filters to be diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/planDetails.tsx b/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/planDetails.tsx index 699eafd1c117..6a5c16606b8e 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/planDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/planDetails.tsx @@ -241,6 +241,9 @@ function formatIdxRecommendations( for (let i = 0; i < idxRecs.length; i++) { const rec = idxRecs[i]; let idxType: InsightType; + if (!rec?.includes(" : ")) { + continue; + } const t = rec.split(" : ")[0]; switch (t) { case "creation": diff --git a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts index f0be5e98c63c..1b6b90f1f8e2 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.selectors.ts @@ -57,7 +57,7 @@ export const selectStatementsLastUpdated = createSelector( // selectApps returns the array of all apps with statement statistics present // in the data. export const selectApps = createSelector(sqlStatsSelector, sqlStatsState => { - if (!sqlStatsState.data || !sqlStatsState.valid) { + if (!sqlStatsState?.data || !sqlStatsState?.valid) { return []; } @@ -88,7 +88,7 @@ export const selectApps = createSelector(sqlStatsSelector, sqlStatsState => { // selectDatabases returns the array of all databases in the cluster. export const selectDatabases = createSelector(databasesListSelector, state => { - if (!state.data) { + if (!state?.data) { return []; } @@ -102,7 +102,7 @@ export const selectDatabases = createSelector(databasesListSelector, state => { export const selectTotalFingerprints = createSelector( sqlStatsSelector, state => { - if (!state.data) { + if (!state?.data) { return 0; } const aggregated = aggregateStatementStats(state.data.statements); @@ -113,7 +113,7 @@ export const selectTotalFingerprints = createSelector( // selectLastReset returns a string displaying the last time the statement // statistics were reset. export const selectLastReset = createSelector(sqlStatsSelector, state => { - if (!state.data) { + if (!state?.data) { return ""; } @@ -144,7 +144,7 @@ export const selectStatements = createSelector( diagnosticsReportsPerStatement, ): AggregateStatistics[] => { // State is valid if we successfully fetched data, and the data has not yet been invalidated. - if (!state.data || !state.valid) { + if (!state?.data || !state?.valid) { return null; } let statements = flattenStatementStats(state.data.statements); @@ -229,7 +229,7 @@ export const selectColumns = createSelector( // return array of columns if user have customized it or `null` otherwise localStorage => localStorage["showColumns/StatementsPage"] - ? localStorage["showColumns/StatementsPage"].split(",") + ? localStorage["showColumns/StatementsPage"]?.split(",") : null, ); diff --git a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx index f4904b19d3b7..7c23dda95fe5 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.tsx @@ -561,7 +561,7 @@ export class StatementsPage extends React.Component< // hiding columns that won't be displayed for tenants. const columns = makeStatementsColumns( statements, - filters.app.split(","), + filters.app?.split(","), this.props.stmtsTotalRuntimeSecs, "statement", isTenant, diff --git a/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.selectors.ts index f30b39bf3c68..8a66abaa7d21 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/insights/statementInsights/statementInsights.selectors.ts @@ -46,7 +46,7 @@ export const selectColumns = createSelector( localStorageSelector, localStorage => localStorage["showColumns/StatementInsightsPage"] - ? localStorage["showColumns/StatementInsightsPage"].split(",") + ? localStorage["showColumns/StatementInsightsPage"]?.split(",") : null, ); diff --git a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts index f5aa7de346b8..2d5fc6288f5d 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/jobs/jobs.selectors.ts @@ -42,6 +42,6 @@ export const selectColumns = createSelector( // return array of columns if user have customized it or `null` otherwise localStorage => localStorage["showColumns/JobsPage"] - ? localStorage["showColumns/JobsPage"].split(",") + ? localStorage["showColumns/JobsPage"]?.split(",") : null, ); diff --git a/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.selectors.ts index b9a4c0e2f46c..65ff4ce97e23 100644 --- a/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/store/sessions/sessions.selectors.ts @@ -20,7 +20,7 @@ export const selectSession = createSelector( (state: AppState) => state.adminUI?.sessions, (_state: AppState, props: RouteComponentProps) => props, (state: SessionsState, props: RouteComponentProps) => { - if (!state.data) { + if (!state?.data) { return null; } const sessionID = getMatchParamByName(props.match, sessionAttr); diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.selectors.ts b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.selectors.ts index 3a9fd6b740e4..b5ede47c03ba 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.selectors.ts +++ b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/transactionsPage.selectors.ts @@ -43,7 +43,7 @@ export const selectTxnColumns = createSelector( // return array of columns if user have customized it or `null` otherwise localStorage => localStorage["showColumns/TransactionPage"] - ? localStorage["showColumns/TransactionPage"].split(",") + ? localStorage["showColumns/TransactionPage"]?.split(",") : null, ); diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts index 49459d7e099f..3f4684650866 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts +++ b/pkg/ui/workspaces/cluster-ui/src/transactionsPage/utils.ts @@ -171,8 +171,8 @@ export const filterTransactions = ( activeFilters: 0, }; const timeValue = getTimeValueInSeconds(filters); - const regions = filters.regions.length > 0 ? filters.regions.split(",") : []; - const nodes = filters.nodes.length > 0 ? filters.nodes.split(",") : []; + const regions = filters.regions?.length > 0 ? filters.regions.split(",") : []; + const nodes = filters.nodes?.length > 0 ? filters.nodes.split(",") : []; const activeFilters = calculateActiveFilters(filters); diff --git a/pkg/ui/workspaces/cluster-ui/src/util/format.ts b/pkg/ui/workspaces/cluster-ui/src/util/format.ts index a9c67ca6161f..f06c0458367b 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/format.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/format.ts @@ -282,7 +282,7 @@ function add(a: string, b: string): string { // to an int64 (in string form). export function HexStringToInt64String(s: string): string { let dec = "0"; - s.split("").forEach(function (chr: string) { + s?.split("").forEach(function (chr: string) { const n = parseInt(chr, 16); for (let t = 8; t; t >>= 1) { dec = add(dec, dec); diff --git a/pkg/ui/workspaces/cluster-ui/src/util/formatNumber.ts b/pkg/ui/workspaces/cluster-ui/src/util/formatNumber.ts index 5352f0009e8d..b106895a63d2 100644 --- a/pkg/ui/workspaces/cluster-ui/src/util/formatNumber.ts +++ b/pkg/ui/workspaces/cluster-ui/src/util/formatNumber.ts @@ -11,7 +11,7 @@ import { isNumber } from "lodash"; function numberToString(n: number) { - return n.toString(); + return n?.toString() || ""; } export function formatNumberForDisplay( diff --git a/pkg/ui/workspaces/db-console/src/redux/indexUsageStats/indexUsageStatsSagas.ts b/pkg/ui/workspaces/db-console/src/redux/indexUsageStats/indexUsageStatsSagas.ts index c030a03a8141..be75504e64fc 100644 --- a/pkg/ui/workspaces/db-console/src/redux/indexUsageStats/indexUsageStatsSagas.ts +++ b/pkg/ui/workspaces/db-console/src/redux/indexUsageStats/indexUsageStatsSagas.ts @@ -36,6 +36,9 @@ export const selectIndexStatsKeys = createSelector( ); export const KeyToTableRequest = (key: string): TableIndexStatsRequest => { + if (!key?.includes("/")) { + return new TableIndexStatsRequest({ database: "", table: "" }); + } const s = key.split("/"); const database = s[0]; const table = s[1]; diff --git a/pkg/ui/workspaces/db-console/src/selectors/recentExecutionsSelectors.ts b/pkg/ui/workspaces/db-console/src/selectors/recentExecutionsSelectors.ts index 3012a28c7cc3..1962080c3eef 100644 --- a/pkg/ui/workspaces/db-console/src/selectors/recentExecutionsSelectors.ts +++ b/pkg/ui/workspaces/db-console/src/selectors/recentExecutionsSelectors.ts @@ -61,7 +61,7 @@ export const selectRecentStatement = createSelector( export const selectAppName = createSelector( (state: AdminUIState) => state.cachedData.sessions, (state?: CachedDataReducerState) => { - if (!state.data) { + if (!state?.data) { return null; } return state.data.internal_app_name_prefix; diff --git a/pkg/ui/workspaces/db-console/src/util/highlightedText.tsx b/pkg/ui/workspaces/db-console/src/util/highlightedText.tsx index f9f8cd916885..9c547295253c 100644 --- a/pkg/ui/workspaces/db-console/src/util/highlightedText.tsx +++ b/pkg/ui/workspaces/db-console/src/util/highlightedText.tsx @@ -37,7 +37,7 @@ export default function getHighlightedText( }) .join("|"); const parts = isOriginalText - ? text.split(new RegExp(`(${search})`, "gi")) + ? text?.split(new RegExp(`(${search})`, "gi")) : rebaseText(text, highlight).split(new RegExp(`(${search})`, "gi")); const highlightClass = hasDarkBkg ? "_text-bold-light" : "_text-bold"; return parts.map((part, i) => { diff --git a/pkg/ui/workspaces/db-console/src/views/sessions/sessionDetails.tsx b/pkg/ui/workspaces/db-console/src/views/sessions/sessionDetails.tsx index 5c10b78d1780..8dfe58ab436b 100644 --- a/pkg/ui/workspaces/db-console/src/views/sessions/sessionDetails.tsx +++ b/pkg/ui/workspaces/db-console/src/views/sessions/sessionDetails.tsx @@ -39,7 +39,7 @@ export const selectSession = createSelector( state: CachedDataReducerState, props: RouteComponentProps, ) => { - if (!state.data) { + if (!state?.data) { return null; } const sessionID = getMatchParamByName(props.match, sessionAttr); diff --git a/pkg/ui/workspaces/db-console/src/views/sessions/sessionsPage.tsx b/pkg/ui/workspaces/db-console/src/views/sessions/sessionsPage.tsx index 7f19ce38e2eb..19944c1cbc53 100644 --- a/pkg/ui/workspaces/db-console/src/views/sessions/sessionsPage.tsx +++ b/pkg/ui/workspaces/db-console/src/views/sessions/sessionsPage.tsx @@ -48,7 +48,7 @@ export const selectSessions = createSelector( state: CachedDataReducerState, _: RouteComponentProps, ) => { - if (!state.data) { + if (!state?.data) { return null; } return state.data.sessions.map(session => { @@ -64,7 +64,7 @@ export const selectAppName = createSelector( state: CachedDataReducerState, _: RouteComponentProps, ) => { - if (!state.data) { + if (!state?.data) { return null; } return state.data.internal_app_name_prefix; diff --git a/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx b/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx index 44c0347d480b..34244d26c15b 100644 --- a/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx +++ b/pkg/ui/workspaces/db-console/src/views/statements/statementsPage.tsx @@ -113,7 +113,7 @@ export const selectStatements = createSelector( props: RouteComponentProps, diagnosticsReportsPerStatement, ): AggregateStatistics[] => { - if (!state.data || !state.valid) { + if (!state?.data || !state?.valid) { return null; } let statements = flattenStatementStats(state.data.statements); @@ -193,7 +193,7 @@ export const selectStatements = createSelector( export const selectApps = createSelector( (state: AdminUIState) => state.cachedData.statements, (state: CachedDataReducerState) => { - if (!state.data) { + if (!state?.data) { return []; } @@ -228,7 +228,7 @@ export const selectApps = createSelector( export const selectDatabases = createSelector( (state: AdminUIState) => state.cachedData.databases, (state: CachedDataReducerState) => { - if (!state.data) { + if (!state?.data) { return []; } @@ -243,7 +243,7 @@ export const selectDatabases = createSelector( export const selectTotalFingerprints = createSelector( (state: AdminUIState) => state.cachedData.statements, (state: CachedDataReducerState) => { - if (!state.data) { + if (!state?.data) { return 0; } const aggregated = aggregateStatementStats(state.data.statements); @@ -256,7 +256,7 @@ export const selectTotalFingerprints = createSelector( export const selectLastReset = createSelector( (state: AdminUIState) => state.cachedData.statements, (state: CachedDataReducerState) => { - if (!state.data) { + if (!state?.data) { return "unknown"; } return PrintTime(util.TimestampToMoment(state.data.last_reset)); diff --git a/pkg/ui/workspaces/db-console/src/views/transactions/transactionsPage.tsx b/pkg/ui/workspaces/db-console/src/views/transactions/transactionsPage.tsx index 219428954c48..a577acf7f6af 100644 --- a/pkg/ui/workspaces/db-console/src/views/transactions/transactionsPage.tsx +++ b/pkg/ui/workspaces/db-console/src/views/transactions/transactionsPage.tsx @@ -67,7 +67,7 @@ export const selectData = createSelector( export const selectLastReset = createSelector( (state: AdminUIState) => state.cachedData.transactions, (state: CachedDataReducerState) => { - if (!state.data) { + if (!state?.data) { return "unknown"; }