From a3233c6ac300da86524bdf42b28d2a521cb0c1da Mon Sep 17 00:00:00 2001 From: Maria Alexandra <239999+axelavargas@users.noreply.github.com> Date: Tue, 17 May 2022 10:31:19 +0200 Subject: [PATCH] Search(Playground)- Manage Actions: Disable delete button when folder is General (#49021) Co-authored-by: Ryan McKinley --- public/app/features/search/constants.ts | 2 +- public/app/features/search/page/components/FolderView.tsx | 3 ++- public/app/features/search/page/components/ManageActions.tsx | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/app/features/search/constants.ts b/public/app/features/search/constants.ts index 98f67f71295..1ae5fcc8254 100644 --- a/public/app/features/search/constants.ts +++ b/public/app/features/search/constants.ts @@ -5,6 +5,6 @@ export const SEARCH_ITEM_MARGIN = 8; export const DEFAULT_SORT = { label: 'A\u2013Z', value: 'alpha-asc' }; export const SECTION_STORAGE_KEY = 'search.sections'; export const GENERAL_FOLDER_ID = 0; -export const GENERAL_FOLDER_UID = 'GeneralFolderUID'; +export const GENERAL_FOLDER_UID = 'general'; export const GENERAL_FOLDER_TITLE = 'General'; export const PREVIEWS_LOCAL_STORAGE_KEY = 'grafana.dashboard.previews'; diff --git a/public/app/features/search/page/components/FolderView.tsx b/public/app/features/search/page/components/FolderView.tsx index 7b950428054..54f18b50260 100644 --- a/public/app/features/search/page/components/FolderView.tsx +++ b/public/app/features/search/page/components/FolderView.tsx @@ -6,6 +6,7 @@ import { GrafanaTheme2 } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; import { Spinner, useStyles2 } from '@grafana/ui'; +import { GENERAL_FOLDER_UID } from '../../constants'; import { getGrafanaSearcher } from '../../service'; import { SearchResultsProps } from '../components/SearchResultsTable'; @@ -26,7 +27,7 @@ export const FolderView = ({ const folders: DashboardSection[] = [ { title: 'Recent', icon: 'clock', kind: 'query-recent', uid: '__recent' }, { title: 'Starred', icon: 'star', kind: 'query-star', uid: '__starred' }, - { title: 'General', url: '/dashboards', kind: 'folder', uid: 'general' }, // not sure why this is not in the index + { title: 'General', url: '/dashboards', kind: 'folder', uid: GENERAL_FOLDER_UID }, // not sure why this is not in the index ]; for (const row of rsp.view) { folders.push({ diff --git a/public/app/features/search/page/components/ManageActions.tsx b/public/app/features/search/page/components/ManageActions.tsx index a9e808222f0..eeb2f96bccc 100644 --- a/public/app/features/search/page/components/ManageActions.tsx +++ b/public/app/features/search/page/components/ManageActions.tsx @@ -27,7 +27,7 @@ export function ManageActions({ items, folder, onChange }: Props) { // TODO: check user permissions for delete, should not be able to delete if includes general folder and user don't have permissions // There is not GENERAL_FOLDER_UID configured yet, we need to make sure to add it to the data. - const selectedFolders = Array.from(items.get('folders') ?? []); + const selectedFolders = Array.from(items.get('folder') ?? []); console.log({ selectedFolders }); const includesGeneralFolder = selectedFolders.find((result) => result === GENERAL_FOLDER_UID);