diff --git a/components/frontend/src/metric/MetricConfigurationParameters.jsx b/components/frontend/src/metric/MetricConfigurationParameters.jsx index beb6303b4f..1ca00efc6c 100644 --- a/components/frontend/src/metric/MetricConfigurationParameters.jsx +++ b/components/frontend/src/metric/MetricConfigurationParameters.jsx @@ -12,6 +12,7 @@ import { metricPropType, reportPropType, subjectPropType } from "../sharedPropTy import { formatMetricScale, getMetricDirection, + getMetricName, getMetricScale, getMetricTags, getMetricUnit, @@ -52,7 +53,7 @@ function MetricName({ metric, metricUuid, reload }) { label="Metric name" placeholder={metricType.name} onChange={(value) => setMetricAttribute(metricUuid, "name", value, reload)} - value={metric.name || metricType.name} + value={getMetricName(metric, dataModel)} /> ) } @@ -252,12 +253,7 @@ export function MetricConfigurationParameters({ metric, metricUuid, reload, repo return ( - + diff --git a/components/frontend/src/metric/MetricType.jsx b/components/frontend/src/metric/MetricType.jsx index 8cc8287a30..7237d4cb91 100644 --- a/components/frontend/src/metric/MetricType.jsx +++ b/components/frontend/src/metric/MetricType.jsx @@ -6,7 +6,8 @@ import { setMetricAttribute } from "../api/metric" import { DataModelContext } from "../context/DataModel" import { accessGranted, EDIT_REPORT_PERMISSION, PermissionsContext } from "../context/Permissions" import { TextField } from "../fields/TextField" -import { getSubjectTypeMetrics, referenceDocumentationURL } from "../utils" +import { metricPropType } from "../sharedPropTypes" +import { getMetricTypeName, getSubjectTypeMetrics, referenceDocumentationURL } from "../utils" import { ReadTheDocsLink } from "../widgets/ReadTheDocsLink" export function metricTypeOption(key, metricType) { @@ -54,11 +55,12 @@ export function usedMetricTypesInReport(report) { return Array.from(metricTypes) } -export function MetricType({ subjectType, metricType, metricUuid, reload }) { +export function MetricType({ metric, metricUuid, reload, subjectType }) { const dataModel = useContext(DataModelContext) const permissions = useContext(PermissionsContext) const disabled = !accessGranted(permissions, [EDIT_REPORT_PERMISSION]) const options = metricTypeOptions(dataModel, subjectType) + const metricType = metric.type const metricTypes = options.map((option) => option.key) if (!metricTypes.includes(metricType)) { options.push(metricTypeOption(metricType, dataModel.metrics[metricType])) @@ -70,7 +72,7 @@ export function MetricType({ subjectType, metricType, metricUuid, reload }) { disabled={disabled} helperText={ <> - + {howToConfigure} } @@ -88,8 +90,8 @@ export function MetricType({ subjectType, metricType, metricUuid, reload }) { ) } MetricType.propTypes = { - subjectType: string, - metricType: string, + metric: metricPropType, metricUuid: string, reload: func, + subjectType: string, } diff --git a/components/frontend/src/metric/MetricType.test.jsx b/components/frontend/src/metric/MetricType.test.jsx index 9138c011b1..032e2cc74d 100644 --- a/components/frontend/src/metric/MetricType.test.jsx +++ b/components/frontend/src/metric/MetricType.test.jsx @@ -46,7 +46,7 @@ function renderMetricType(metricType) { diff --git a/components/frontend/src/report/ReportSources.jsx b/components/frontend/src/report/ReportSources.jsx index 694575ed99..c3fe9a1a5e 100644 --- a/components/frontend/src/report/ReportSources.jsx +++ b/components/frontend/src/report/ReportSources.jsx @@ -13,7 +13,7 @@ import { SourceParameter } from "../source/SourceParameter" import { reloadAfterMassEditSource } from "../source/Sources" import { SourceTypeRichDescription } from "../source/SourceType" import { theme } from "../theme" -import { getSourceName, referenceDocumentationURL } from "../utils" +import { getSourceName, getSourceTypeName, referenceDocumentationURL } from "../utils" import { UnsortableTableHeaderCell } from "../widgets/TableHeaderCell" import { TableRowWithDetails } from "../widgets/TableRowWithDetails" import { Tabs } from "../widgets/Tabs" @@ -215,7 +215,7 @@ export function ReportSources({ reload, report, settings }) { onExpand={() => settings.expandedItems.toggle(source.uuid)} firstCellContent={getSourceName(source, dataModel)} > - {dataModel.sources[source.type].name} + {getSourceTypeName(source, dataModel)} {source.parameters?.url ?? ""} {source.nrMetrics} diff --git a/components/frontend/src/source/Source.jsx b/components/frontend/src/source/Source.jsx index 607e3193a2..2fb63e6209 100644 --- a/components/frontend/src/source/Source.jsx +++ b/components/frontend/src/source/Source.jsx @@ -17,7 +17,7 @@ import { sourcePropType, stringsPropType, } from "../sharedPropTypes" -import { getMetricName, getSourceName, referenceDocumentationURL } from "../utils" +import { getMetricName, getMetricTypeName, getSourceName, getSourceTypeName, referenceDocumentationURL } from "../utils" import { ButtonRow } from "../widgets/ButtonRow" import { DeleteButton } from "../widgets/buttons/DeleteButton" import { ReorderButtonGroup } from "../widgets/buttons/ReorderButtonGroup" @@ -122,7 +122,7 @@ function Parameters({ label="Source name" placeholder={sourceType.name} onChange={(value) => setSourceAttribute(sourceUuid, "name", value, reload)} - value={source.name || sourceType.name} + value={getSourceName(source, dataModel)} /> @@ -179,14 +179,14 @@ export function Source({