From 868b3cea1957286a6ea6073bda1eaea4f43b7b94 Mon Sep 17 00:00:00 2001 From: Eric Harmeling Date: Fri, 17 Feb 2023 16:14:45 -0500 Subject: [PATCH] ui: fixed insights table bug on insights #96440 introduced a bug to the Insights Table on the Schema Insights page. This commit fixes that bug. Release note: None Epic: None --- .../statementInsightDetailsOverviewTab.tsx | 2 +- .../src/insightsTable/insightsTable.tsx | 25 +++++++++++-------- .../planDetails/planDetails.tsx | 2 +- .../src/statementDetails/statementDetails.tsx | 3 ++- .../transactionDetails/transactionDetails.tsx | 3 ++- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx index 30bb4f67e8ea..7e1db250ee31 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insights/workloadInsightDetails/statementInsightDetailsOverviewTab.tsx @@ -56,7 +56,7 @@ export const StatementInsightDetailsOverviewTab: React.FC< const isCockroachCloud = useContext(CockroachCloudContext); const insightsColumns = useMemo( - () => makeInsightsColumns(isCockroachCloud, hasAdminRole, true), + () => makeInsightsColumns(isCockroachCloud, hasAdminRole), [isCockroachCloud, hasAdminRole], ); diff --git a/pkg/ui/workspaces/cluster-ui/src/insightsTable/insightsTable.tsx b/pkg/ui/workspaces/cluster-ui/src/insightsTable/insightsTable.tsx index 673a37d17e04..d800ad82db4a 100644 --- a/pkg/ui/workspaces/cluster-ui/src/insightsTable/insightsTable.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/insightsTable/insightsTable.tsx @@ -131,11 +131,15 @@ const StatementExecution = ({ function descriptionCell( insightRec: InsightRecommendation, - isExecution: boolean, + disableStmtLink: boolean, isCockroachCloud: boolean, + isFingerprint: boolean, ): React.ReactElement { const stmtLink = isIndexRec(insightRec) ? ( - + ) : null; const clusterSettingsLink = ( @@ -201,7 +205,7 @@ function descriptionCell( case "HighContention": return ( <> - {isExecution && ( + {!isFingerprint && (
Time Spent Waiting: {" "} {Duration(insightRec.details.duration * 1e6)} @@ -209,7 +213,7 @@ function descriptionCell( )} {stmtLink}
- {isExecution && ( + {!isFingerprint && ( Description: )} {insightRec.details.description} {clusterSettingsLink} @@ -272,7 +276,7 @@ function descriptionCell( case "Unknown": return ( <> - {isExecution && ( + {!isFingerprint && (
Elapsed Time: {Duration(insightRec.details.duration * 1e6)} @@ -280,7 +284,7 @@ function descriptionCell( )} {stmtLink}
- {isExecution && ( + {!isFingerprint && ( Description: )} {insightRec.details.description} {clusterSettingsLink} @@ -390,7 +394,8 @@ const isIndexRec = (rec: InsightRecommendation) => { export function makeInsightsColumns( isCockroachCloud: boolean, hasAdminRole: boolean, - isExecution?: boolean, + disableStmtLink?: boolean, + isFingerprint?: boolean, ): ColumnDescriptor[] { const columns: ColumnDescriptor[] = [ { @@ -403,17 +408,17 @@ export function makeInsightsColumns( name: "details", title: insightsTableTitles.details(), cell: (item: InsightRecommendation) => - descriptionCell(item, isExecution, isCockroachCloud), + descriptionCell(item, disableStmtLink, isCockroachCloud, isFingerprint), sort: (item: InsightRecommendation) => item.type, }, { name: "action", title: insightsTableTitles.actions(), cell: (item: InsightRecommendation) => - actionCell(item, isCockroachCloud || !hasAdminRole || !isExecution), + actionCell(item, isCockroachCloud || !hasAdminRole || isFingerprint), }, ]; - if (!isExecution) { + if (isFingerprint) { columns.push({ name: "latestExecution", title: insightsTableTitles.latestExecution(), 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 3d56b12424a2..699eafd1c117 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/planDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/planDetails.tsx @@ -295,7 +295,7 @@ export function Insights({ hasAdminRole, }: InsightsProps): React.ReactElement { const hideAction = useContext(CockroachCloudContext) || database?.length == 0; - const insightsColumns = makeInsightsColumns(hideAction, hasAdminRole, false); + const insightsColumns = makeInsightsColumns(hideAction, hasAdminRole, true); const data = formatIdxRecommendations( idxRecommendations, database, diff --git a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx index 436843f55381..29413afb5570 100644 --- a/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx @@ -665,7 +665,8 @@ export class StatementDetails extends React.Component< const insightsColumns = makeInsightsColumns( isCockroachCloud, this.props.hasAdminRole, - false, + true, + true, ); const tableData: InsightRecommendation[] = []; if (statementFingerprintInsights) { diff --git a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx index c334bb33989c..5c2982033a45 100644 --- a/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx +++ b/pkg/ui/workspaces/cluster-ui/src/transactionDetails/transactionDetails.tsx @@ -456,7 +456,8 @@ export class TransactionDetails extends React.Component< const insightsColumns = makeInsightsColumns( isCockroachCloud, this.props.hasAdminRole, - false, + true, + true, ); const tableData: InsightRecommendation[] = []; if (transactionInsights) {