Skip to content

Commit

Permalink
update error indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed Oct 1, 2024
1 parent e7165c3 commit 2fbfb33
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export function ColumnOption({
}: ColumnOptionProps) {
const { expression, column_name, type_generic } = column;
const hasExpression = expression && expression !== column_name;
const warningMarkdown = column.warning_markdown || column.warning_text;
const warningMarkdown =
column.warning_markdown || column.warning_text || column.error_text;
const type = hasExpression ? 'expression' : type_generic;
const [tooltipText, setTooltipText] = useState<ReactNode>(column.column_name);
const [columnTypeTooltipText, setcolumnTypeTooltipText] = useState<ReactNode>(
Expand Down Expand Up @@ -103,6 +104,10 @@ export function ColumnOption({
tooltip={<SafeMarkdown source={warningMarkdown} />}
label={`warn-${column.column_name}`}
iconsStyle={{ marginLeft: 0 }}
{...(column.error_text && {
className: 'text-danger',
icon: 'exclamation-circle',
})}
/>
)}
</StyleOverrides>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export function MetricOption({
</span>
);

const warningMarkdown = metric.warning_markdown || metric.warning_text;
const warningMarkdown =
metric.warning_markdown || metric.warning_text || metric.error_text;

const [tooltipText, setTooltipText] = useState<ReactNode>(metric.metric_name);

Expand Down Expand Up @@ -116,6 +117,10 @@ export function MetricOption({
tooltip={<SafeMarkdown source={warningMarkdown} />}
label={`warn-${metric.metric_name}`}
iconsStyle={{ marginLeft: 0 }}
{...(metric.error_text && {
className: 'text-danger',
icon: 'exclamation-circle',
})}
/>
)}
</FlexRowContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface Metric {
verbose_name?: string;
warning_markdown?: Maybe<string>;
warning_text?: Maybe<string>;
error_text?: string;
}

export function isSavedMetric(metric: any): metric is SavedMetric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ function DndColumnSelect(props: DndColumnSelectProps) {
isAdhocColumn(column) && column.datasourceWarning
? t('This column might be incompatible with current dataset')
: undefined;
const withCaret =
isAdhocColumn(column) ||
!(column.warning_markdown || column.warning_text);
const withCaret = isAdhocColumn(column) || !column.error_text;

return (
<ColumnSelectPopoverTrigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ const coerceMetrics = (
) {
return {
metric_name: metric,
warning_text: t(
'This metric might be incompatible with current dataset',
),
error_text: t('This metric might be incompatible with current dataset'),
};
}
if (!isDictionaryForAdhocMetric(metric)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class OptionSelector {
return {
type_generic: 'UNKNOWN',
column_name: value,
warning_text: t(
error_text: t(
'This column might be incompatible with current dataset',
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ class AdhocMetricOption extends PureComponent {
multi,
datasourceWarningMessage,
} = this.props;
const warningMarkdown =
savedMetric.warning_markdown || savedMetric.warning_text;
const withCaret = !savedMetric.error_text;

return (
<AdhocMetricPopoverTrigger
Expand All @@ -88,7 +87,7 @@ class AdhocMetricOption extends PureComponent {
onDropLabel={onDropLabel}
index={index}
type={type ?? DndItemType.AdhocMetricOption}
withCaret={!warningMarkdown}
withCaret={withCaret}
isFunction
multi={multi}
datasourceWarningMessage={datasourceWarningMessage}
Expand Down

0 comments on commit 2fbfb33

Please sign in to comment.