Search(Playground)- Manage Actions: Disable delete button when folder is General (#49021)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Maria Alexandra 2022-05-17 10:31:19 +02:00 committed by GitHub
parent 0ea04ac64d
commit a3233c6ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -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';

View File

@ -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({

View File

@ -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);