Use new NestedFolderPicker in SaveDashboardAsForm (#72189)

This commit is contained in:
Josh Hunt
2023-07-24 11:11:35 +00:00
committed by GitHub
parent 57a54fc38a
commit 3c48701f08
2 changed files with 48 additions and 24 deletions

View File

@@ -1,9 +1,7 @@
import React from 'react';
import { config } from '@grafana/runtime';
import { Button, Input, Switch, Form, Field, InputControl, HorizontalGroup } from '@grafana/ui';
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 { DashboardModel, PanelModel } from 'app/features/dashboard/state';
import { validationSrv } from 'app/features/manage-dashboards/services/ValidationSrv';
@@ -110,23 +108,17 @@ export const SaveDashboardAsForm = ({
</Field>
<Field label="Folder">
<InputControl
render={({ field: { ref, ...field } }) =>
config.featureToggles.nestedFolderPicker ? (
<NestedFolderPicker
{...field}
onChange={(uid: string, title: string) => field.onChange({ uid, title })}
value={field.value?.uid}
/>
) : (
<OldFolderPicker
{...field}
dashboardId={dashboard.id}
initialFolderUid={dashboard.meta.folderUid}
initialTitle={dashboard.meta.folderTitle}
enableCreateNew
/>
)
}
render={({ field: { ref, ...field } }) => (
<FolderPicker
{...field}
onChange={(uid: string, title: string) => field.onChange({ uid, title })}
value={field.value?.uid}
// Old folder picker fields
initialTitle={dashboard.meta.folderTitle}
dashboardId={dashboard.id}
enableCreateNew
/>
)}
control={control}
name="$folder"
/>