fix: Color scheme control crashing when dashboardId present (#28457)

This commit is contained in:
Kamil Gabryjelski 2024-05-13 18:00:29 +02:00 committed by GitHub
parent e1cd0547de
commit 983f809951
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 7 deletions

View File

@ -127,3 +127,11 @@ test('displays color scheme options', async () => {
expect(screen.getByText('Other color palettes')).toBeInTheDocument();
});
});
test('Renders control with dashboard id', () => {
setup({ dashboardId: 1 });
expect(screen.getByText('Dashboard scheme')).toBeInTheDocument();
expect(
screen.getByLabelText('Select color scheme', { selector: 'input' }),
).toBeDisabled();
});

View File

@ -125,13 +125,9 @@ const ColorSchemeControl = ({
const options = useMemo(() => {
if (dashboardId) {
return [
{
value: 'dashboard',
label: t('dashboard'),
customLabel: (
<Tooltip title={DASHBOARD_ALERT}>{t('Dashboard scheme')}</Tooltip>
),
},
<Option value="dashboard" label={t('dashboard')} key="dashboard">
<Tooltip title={DASHBOARD_ALERT}>{t('Dashboard scheme')}</Tooltip>
</Option>,
];
}
const schemesObject = isFunction(schemes) ? schemes() : schemes;