Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions web/src/components/dashboards/perses/variable-dropdowns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
useVariableDefinitions,
} from '@perses-dev/dashboards';
import { useListVariablePluginValues, VariableOption } from '@perses-dev/plugin-system';
import ErrorBoundary from '../../console/console-shared/error/error-boundary';

/**
* This file is approximately the equal of `perses/ui/dashboards/src/components/Variables/Variable`
Expand Down Expand Up @@ -108,8 +109,8 @@ function ListVariable({ name, id }: VariableDropdownProps) {
children: string;
}
>(viewOptions, (option: VariableOption) => ({
value: option.label,
children: option.label,
value: option?.label,
children: option?.label,
}));

const title = definition?.spec.display?.name ?? name;
Expand Down Expand Up @@ -154,12 +155,19 @@ export const AllVariableDropdowns: React.FC = () => {
export function VariableComponent({ name }: VariableProps) {
const ctx = useVariableDefinitionAndState(name);
const kind = ctx.definition?.kind;

let variableComponent = null;

switch (kind) {
// Openshift doesn't support this, so ignore for now
// case 'TextVariable':
// return <TextVariable name={name} source={source} />;
case 'ListVariable':
return <ListVariable id={name} name={name} />;
variableComponent = <ListVariable id={name} name={name} />;
}

if (variableComponent) {
return <ErrorBoundary>{variableComponent}</ErrorBoundary>;
}

return <div>Unsupported Variable Kind: ${kind}</div>;
Expand Down