diff --git a/src/components/ExplorerResults.tsx b/src/components/ExplorerResults.tsx index 1c7a5f6..1afe143 100644 --- a/src/components/ExplorerResults.tsx +++ b/src/components/ExplorerResults.tsx @@ -20,6 +20,7 @@ import {useSelector} from "react-redux"; import {useSettings} from "../hooks/settings"; import {useTranslation} from "../hooks/translation"; import {selectCurrentQueryItem, selectIsPreviewMode} from "../state/queries"; +import type {QueryResult} from "../utils/structs"; import type {PanelDescriptor, ViewProps} from "../utils/types"; import AddColumnsDrawer from "./DrawerMenu"; import {ExplorerTabs} from "./ExplorerTabs"; @@ -221,16 +222,7 @@ function SuccessResult( cube }); - if (data?.length === 0 && !isLoading && !isError) { - return ( - } - title={t("results.error_emptyresult_title")} - description={t("results.error_emptyresult_detail")} - /> - ); - } + return ( | undefined} table={table} isError={isError} isLoading={isLoading} diff --git a/src/components/TableView.tsx b/src/components/TableView.tsx index e8e3c9e..1dc34ea 100644 --- a/src/components/TableView.tsx +++ b/src/components/TableView.tsx @@ -1073,10 +1073,11 @@ const MultiFilter = ({header}: {header: MRT_Header}) => { }; const NoRecords = React.memo(() => { + const {translate: t} = useTranslation(); return ( -
- - No records to display. +
+ + {t("results.error_emptyresult_detail")}
); diff --git a/src/utils/object.ts b/src/utils/object.ts index 7847b23..bc363fb 100644 --- a/src/utils/object.ts +++ b/src/utils/object.ts @@ -53,28 +53,34 @@ export function describeData( if (!entityResult) return null; const [entity] = entityResult; + let entityType: AnyResultColumn["entityType"]; + if (hasProperty(entity, "aggregator")) { + entityType = "measure"; + } else if (hasProperty(entity, "depth")) { + entityType = "level"; + } else { + entityType = "property"; + } + const typeSet = new Set(result.data.map(item => typeof item[column])); - const valueType = - typeSet.size === 1 - ? typeSet.has("number") - ? "number" - : typeSet.has("boolean") - ? "boolean" - : /* else */ "string" - : typeSet.has("number") - ? "number" - : "string"; + let valueType: AnyResultColumn["valueType"]; + if (entityType === "measure" || typeSet.has("number")) { + valueType = "number"; + } else if (typeSet.size === 1 && typeSet.has("boolean")) { + valueType = "boolean"; + } else { + valueType = "string"; + } + const isId = column !== entity.name; - const entityType = hasProperty(entity, "aggregator") - ? "measure" - : hasProperty(entity, "depth") - ? "level" - : "property"; + const caption = getCaption(entity, locale) || column; + const localeLabel = isId ? `${caption} ID` : caption; + return [ column, { label: column, - localeLabel: getCaption(entity, locale) + (isId ? " ID" : "") || column, + localeLabel, entity, entityType, isId, diff --git a/src/utils/types.ts b/src/utils/types.ts index 789524e..0dbca07 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -41,6 +41,7 @@ export interface ViewProps = Record>; isError?: boolean; isLoading?: boolean; + isFetching?: boolean; data?: Record[]; columns?: MRT_ColumnDef[]; pagination?: MRT_PaginationState;