mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user