Skip to content

Commit

Permalink
update metric settings badges to reflect custom reporting frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
nichelle-hall committed Nov 21, 2022
1 parent f8dda20 commit f646fe0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions publisher/src/components/MetricConfiguration/MetricBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type MetricBoxProps = {
metricKey: string;
displayName: string;
frequency: ReportFrequency;
customFrequency: ReportFrequency;
description: string;
enabled?: boolean;
};
Expand All @@ -41,12 +42,15 @@ export const MetricBox: React.FC<MetricBoxProps> = observer(
metricKey,
displayName,
frequency,
customFrequency,
description,
enabled,
}): JSX.Element => {
const { metricConfigStore } = useStore();
const { updateActiveMetricKey } = metricConfigStore;

const displayFrequency = customFrequency
? customFrequency.toLowerCase()
: frequency.toLowerCase();
return (
<MetricBoxContainer
onClick={() => updateActiveMetricKey(metricKey)}
Expand All @@ -60,7 +64,7 @@ export const MetricBox: React.FC<MetricBoxProps> = observer(
disabled={!enabled}
noMargin
>
{!enabled ? "Inactive" : frequency.toLowerCase()}
{!enabled ? "Inactive" : displayFrequency}
</Badge>
</MetricNameBadgeWrapper>
</MetricBoxContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const MetricConfiguration: React.FC = observer(() => {
key={key}
metricKey={key}
displayName={metric.label as string}
customFrequency={metric.customFrequency as ReportFrequency}
frequency={metric.frequency as ReportFrequency}
description={metric.description as string}
enabled={metric.enabled}
Expand Down Expand Up @@ -179,7 +180,11 @@ export const MetricConfiguration: React.FC = observer(() => {
{metrics[systemMetricKey]?.label}
</MetricName>
<Badge color="GREEN" noMargin>
{metrics[systemMetricKey]?.frequency?.toLowerCase()}
{metrics[systemMetricKey]?.customFrequency
? metrics[
systemMetricKey
]?.customFrequency?.toLocaleLowerCase()
: metrics[systemMetricKey]?.frequency?.toLowerCase()}
</Badge>
<RightArrowIcon />
</Metric>
Expand Down
5 changes: 5 additions & 0 deletions publisher/src/stores/MetricConfigStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class MetricConfigStore {
label?: string;
description?: Metric["description"];
frequency?: Metric["frequency"];
customFrequency?: Metric["custom_frequency"];
};
};

Expand Down Expand Up @@ -177,6 +178,7 @@ class MetricConfigStore {
label?: string;
description?: Metric["description"];
frequency?: Metric["frequency"];
customFrequency?: Metric["custom_frequency"];
};
}[]
);
Expand Down Expand Up @@ -254,6 +256,7 @@ class MetricConfigStore {
label: metric.label,
description: metric.description,
frequency: metric.frequency || "",
customFrequency: metric.custom_frequency || "",
}
);

Expand Down Expand Up @@ -358,6 +361,8 @@ class MetricConfigStore {
this.metrics[systemMetricKey].description = metadata.description;
this.metrics[systemMetricKey].frequency =
metadata.frequency as ReportFrequency;
this.metrics[systemMetricKey].customFrequency =
metadata.customFrequency as ReportFrequency;
}

/** Update value */
Expand Down

0 comments on commit f646fe0

Please sign in to comment.