From 7b3a2d8fb6eb911a981005491749a9aa1420da04 Mon Sep 17 00:00:00 2001 From: Roberto Jimenez Sanchez Date: Wed, 3 Dec 2025 08:35:30 +0100 Subject: [PATCH] Fix linting issues --- apps/provisioning/pkg/jobs/validator.go | 5 +---- .../components/BrowseActions/BrowseActions.tsx | 2 +- .../features/browse-dashboards/components/BrowseView.tsx | 3 +-- .../browse-dashboards/components/FolderActionsButton.tsx | 9 +++------ .../sharing/ExportButton/ExportToRepository.tsx | 3 ++- public/locales/en-US/grafana.json | 4 ++-- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/apps/provisioning/pkg/jobs/validator.go b/apps/provisioning/pkg/jobs/validator.go index 399f09f3163..7ce7664e856 100644 --- a/apps/provisioning/pkg/jobs/validator.go +++ b/apps/provisioning/pkg/jobs/validator.go @@ -101,10 +101,7 @@ func validateExportJobOptions(opts *provisioning.ExportJobOptions) field.ErrorLi } // Validate resources if specified - // Only validate Resources when it has items (not nil and not empty). - // When Resources is nil or empty, the old API path (using Folder) is used, so we skip validation. - // Empty and nil slices are treated the same for validation purposes. - if opts.Resources != nil && len(opts.Resources) > 0 { + if len(opts.Resources) > 0 { for i, r := range opts.Resources { resourcePath := field.NewPath("spec", "push", "resources").Index(i) diff --git a/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx b/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx index 60855979411..d881d07f863 100644 --- a/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx +++ b/public/app/features/browse-dashboards/components/BrowseActions/BrowseActions.tsx @@ -228,7 +228,7 @@ export function BrowseActions({ folderDTO }: Props) { title={ // Heading levels should only increase by one (a11y) - {t('browse-dashboards.action.bulk-export-provisioned-resources', 'Bulk Export Resources')} + {t('browse-dashboards.action.export-provisioned-resources', 'Export Resources')} } onClose={() => setShowBulkExportProvisionedResource(false)} diff --git a/public/app/features/browse-dashboards/components/BrowseView.tsx b/public/app/features/browse-dashboards/components/BrowseView.tsx index 7c51b68282d..c8ca14ceda0 100644 --- a/public/app/features/browse-dashboards/components/BrowseView.tsx +++ b/public/app/features/browse-dashboards/components/BrowseView.tsx @@ -13,7 +13,7 @@ import { DashboardViewItem } from 'app/features/search/types'; import { useDispatch, useSelector } from 'app/types/store'; import { PAGE_SIZE } from '../api/services'; -import { fetchNextChildrenPage } from '../state/actions'; +import { fetchNextChildrenPage, selectFolderWithAllDashboards } from '../state/actions'; import { useFlatTreeState, useCheckboxSelectionState, @@ -22,7 +22,6 @@ import { useLoadNextChildrenPage, rootItemsSelector, } from '../state/hooks'; -import { selectFolderWithAllDashboards } from '../state/actions'; import { setFolderOpenState, setItemSelectionState, setAllSelection } from '../state/slice'; import { BrowseDashboardsState, DashboardTreeSelection, SelectionState, BrowseDashboardsPermissions } from '../types'; diff --git a/public/app/features/browse-dashboards/components/FolderActionsButton.tsx b/public/app/features/browse-dashboards/components/FolderActionsButton.tsx index 25f126d7b9f..ddfb1dfc9c2 100644 --- a/public/app/features/browse-dashboards/components/FolderActionsButton.tsx +++ b/public/app/features/browse-dashboards/components/FolderActionsButton.tsx @@ -160,10 +160,7 @@ export function FolderActionsButton({ folder, repoType, isReadOnlyRepo }: Props) const deleteLabel = t('browse-dashboards.folder-actions-button.delete', 'Delete this folder'); const exportLabel = t('browse-dashboards.folder-actions-button.export', 'Export to Repository'); - const provisioningEnabled = config.featureToggles.provisioning; - // isProvisionedFolder means the folder IS managed/provisioned - // So !isProvisionedFolder means the folder is unmanaged (not provisioned) - const isUnmanagedFolder = !isProvisionedFolder; + const canExportToRepository = config.featureToggles.provisioning && !isProvisionedFolder; const menu = ( @@ -183,7 +180,7 @@ export function FolderActionsButton({ folder, repoType, isReadOnlyRepo }: Props) label={deleteLabel} /> )} - {provisioningEnabled && isUnmanagedFolder && } + {canExportToRepository && } ); @@ -192,7 +189,7 @@ export function FolderActionsButton({ folder, repoType, isReadOnlyRepo }: Props) (canViewPermissions && !isProvisionedFolder) || (canMoveFolder && !isReadOnlyRepo) || (canDeleteFolders && !isReadOnlyRepo) || - (provisioningEnabled && isUnmanagedFolder); + canExportToRepository; if (!hasAnyActions) { return null; diff --git a/public/app/features/dashboard-scene/sharing/ExportButton/ExportToRepository.tsx b/public/app/features/dashboard-scene/sharing/ExportButton/ExportToRepository.tsx index 07dce2d30fc..16c6960d6b2 100644 --- a/public/app/features/dashboard-scene/sharing/ExportButton/ExportToRepository.tsx +++ b/public/app/features/dashboard-scene/sharing/ExportButton/ExportToRepository.tsx @@ -1,6 +1,7 @@ -import { SceneComponentProps } from '@grafana/scenes'; import { t } from '@grafana/i18n'; +import { SceneComponentProps } from '@grafana/scenes'; import { BulkExportProvisionedResource } from 'app/features/provisioning/components/BulkActions/BulkExportProvisionedResource'; + import { DashboardScene } from '../../scene/DashboardScene'; import { ShareExportTab } from '../ShareExportTab'; diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 2830415ebaa..d630a41b1dc 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -3551,7 +3551,6 @@ "browse-dashboards": { "action": { "bulk-delete-provisioned-resources": "Bulk Delete Provisioned Resources", - "bulk-export-provisioned-resources": "Bulk Export Resources", "bulk-move-provisioned-resources": "Bulk Move Provisioned Resources", "cancel-button": "Cancel", "confirmation-text": "Delete", @@ -3565,6 +3564,7 @@ "delete-provisioned-folder": "Delete provisioned folder", "deleting": "Deleting...", "export-folder": "Export Folder to Repository", + "export-provisioned-resources": "Export Resources", "export-to-repository-button": "Export to Repository", "manage-permissions-button": "Manage permissions", "move-button": "Move", @@ -14711,4 +14711,4 @@ "label-points": "Points" } } -} \ No newline at end of file +}