NestedFolders: Switch between old and new folder picker components (#72124)

NestedFolders: Create wrapper to switch between old and new folder picker components
This commit is contained in:
Josh Hunt
2023-07-24 10:25:32 +00:00
committed by GitHub
parent 56ae5abf08
commit 1fde7f7f46
2 changed files with 32 additions and 12 deletions

View File

@@ -1,11 +1,9 @@
import React, { useState } from 'react';
import { Space } from '@grafana/experimental';
import { config } from '@grafana/runtime';
import { Alert, Button, Field, Modal } from '@grafana/ui';
import { Text } from '@grafana/ui/src/unstable';
import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker';
import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
import { t, Trans } from 'app/core/internationalization';
import { DashboardTreeSelection } from '../../types';
@@ -24,10 +22,6 @@ export const MoveModal = ({ onConfirm, onDismiss, selectedItems, ...props }: Pro
const [isMoving, setIsMoving] = useState(false);
const selectedFolders = Object.keys(selectedItems.folder).filter((uid) => selectedItems.folder[uid]);
const handleFolderChange = (newFolder: { uid: string; title: string }) => {
setMoveTarget(newFolder.uid);
};
const onMove = async () => {
if (moveTarget !== undefined) {
setIsMoving(true);
@@ -59,11 +53,7 @@ export const MoveModal = ({ onConfirm, onDismiss, selectedItems, ...props }: Pro
<Space v={3} />
<Field label={t('browse-dashboards.action.move-modal-field-label', 'Folder name')}>
{config.featureToggles.nestedFolderPicker ? (
<NestedFolderPicker value={moveTarget} excludeUIDs={selectedFolders} onChange={setMoveTarget} />
) : (
<OldFolderPicker allowEmpty onChange={handleFolderChange} />
)}
<FolderPicker value={moveTarget} excludeUIDs={selectedFolders} onChange={setMoveTarget} />
</Field>
<Modal.ButtonRow>