diff --git a/.betterer.results b/.betterer.results index 9c867b86097..a52202f2626 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1641,15 +1641,6 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "5"], [0, 0, 0, "Unexpected any. Specify a different type.", "6"] ], - "public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.tsx:5381": [ - [0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "0"], - [0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "1"], - [0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "2"], - [0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "3"], - [0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "4"], - [0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "5"], - [0, 0, 0, "Add noMargin prop to Field components to remove built-in margins. Use layout components like Stack or Grid with the gap prop instead for consistent spacing.", "6"] - ], "public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], diff --git a/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.test.tsx b/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.test.tsx index 12540d371c9..eec8d44b8d8 100644 --- a/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.test.tsx +++ b/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.test.tsx @@ -390,8 +390,9 @@ describe('SaveProvisionedDashboardForm', () => { expect(screen.getByRole('button', { name: /save/i })).toBeDisabled(); }); - it('should show read-only alert when repository has no workflows', () => { + it('should properly handle read-only state for a repository without workflows', () => { setup({ + isNew: false, repository: { name: 'repo-abc', type: 'github', @@ -401,6 +402,20 @@ describe('SaveProvisionedDashboardForm', () => { }, }); - expect(screen.getByText('This repository is read only')).toBeInTheDocument(); + // Alert is shown + expect(screen.getByRole('alert', { name: 'This repository is read only' })).toBeInTheDocument(); + + // Save button is disabled + const saveButton = screen.getByRole('button', { name: /save/i }); + expect(saveButton).toBeDisabled(); + + // Common options are not shown for existing dashboards + expect(screen.queryByTestId('common-options')).not.toBeInTheDocument(); + + // Workflow options are not shown + expect(screen.queryByRole('radiogroup')).not.toBeInTheDocument(); + + // Branch field is not shown + expect(screen.queryByRole('textbox', { name: /branch/i })).not.toBeInTheDocument(); }); }); diff --git a/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.tsx b/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.tsx index 907a8031ef2..a177964f7e2 100644 --- a/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.tsx +++ b/public/app/features/dashboard-scene/saving/provisioned/SaveProvisionedDashboardForm.tsx @@ -159,11 +159,11 @@ export function SaveProvisionedDashboardForm({ }; const workflowOptions = getWorkflowOptions(repository, loadedFromRef); - + const readOnly = !repository?.workflows?.length; return (