) => {
- const value = e.currentTarget.value;
- setNewFolderValue(value);
- setFolder({ id: undefined, title: value });
- };
-
- const onBlur = () => {
- setFolder({ value: '', label: rootName });
- setIsCreatingNew(false);
- };
-
- const onInputChange = (value: string, { action }: InputActionMeta) => {
- if (action === 'input-change') {
- setInputValue((ant) => value);
- }
-
- if (action === 'menu-close') {
- setInputValue((_) => value);
- }
- return;
- };
-
- const FolderWarningWhenCreating = () => {
- if (folderWarning?.warningCondition(newFolderValue)) {
- return ;
- } else {
- return null;
- }
- };
-
- const FolderWarningWhenSearching = () => {
- if (folderWarning?.warningCondition(inputValue)) {
- return ;
- } else {
- return null;
- }
- };
-
- if (isCreatingNew) {
- return (
- <>
-
-
- Press enter to create the new folder.
-
-
- >
- );
- } else {
- return (
-
- );
- }
-}
-
-function mapSearchHitsToOptions(hits: DashboardSearchHit[], filter?: FolderPickerFilter) {
- const filteredHits = filter ? filter(hits) : hits;
- return filteredHits.map((hit) => ({ label: hit.title, value: hit.uid }));
-}
-interface Args {
- getFolder: typeof getFolderByUid;
- folderUid?: string;
- folderName?: string;
-}
-
-export async function getInitialValues({ folderName, folderUid, getFolder }: Args): Promise> {
- if (folderUid === null || folderUid === undefined) {
- throw new Error('folderUid is not found.');
- }
-
- if (folderName) {
- return { label: folderName, value: folderUid };
- }
-
- const folderDto = await getFolder(folderUid);
- return { label: folderDto.title, value: folderUid };
-}
-
-const getStyles = (theme: GrafanaTheme2) => ({
- newFolder: css({
- color: theme.colors.warning.main,
- fontSize: theme.typography.bodySmall.fontSize,
- paddingBottom: theme.spacing(1),
- }),
-});
diff --git a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx
index de5b14e257c..232e692fc9e 100644
--- a/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx
+++ b/public/app/features/dashboard/components/SaveDashboard/forms/SaveDashboardAsForm.test.tsx
@@ -2,7 +2,6 @@ import userEvent from '@testing-library/user-event';
import { render, screen } from 'test/test-utils';
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
-import * as api from 'app/features/manage-dashboards/state/actions';
import { SaveDashboardResponseDTO } from 'app/types/dashboard';
import { SaveDashboardAsForm, SaveDashboardAsFormProps } from './SaveDashboardAsForm';
@@ -15,8 +14,6 @@ jest.mock('app/features/manage-dashboards/services/ValidationSrv', () => ({
},
}));
-jest.spyOn(api, 'searchFolders').mockResolvedValue([]);
-
const prepareDashboardMock = (panel: object) => {
const json = {
title: 'name',
@@ -56,7 +53,6 @@ const renderAndSubmitForm = async (
describe('SaveDashboardAsForm', () => {
describe('default values', () => {
it('applies default dashboard properties', async () => {
- jest.spyOn(api, 'searchFolders').mockResolvedValue([]);
const spy = jest.fn();
await renderAndSubmitForm(prepareDashboardMock({}), spy, {
@@ -72,7 +68,6 @@ describe('SaveDashboardAsForm', () => {
});
it("appends 'Copy' to the name when the dashboard isnt new", async () => {
- jest.spyOn(api, 'searchFolders').mockResolvedValue([]);
const spy = jest.fn();
await renderAndSubmitForm(prepareDashboardMock({}), spy, {
diff --git a/public/app/features/manage-dashboards/state/actions.ts b/public/app/features/manage-dashboards/state/actions.ts
index 039c5b5999a..2f3e278ff7a 100644
--- a/public/app/features/manage-dashboards/state/actions.ts
+++ b/public/app/features/manage-dashboards/state/actions.ts
@@ -10,7 +10,6 @@ import { notifyApp } from 'app/core/actions';
import { createErrorNotification } from 'app/core/copy/appNotification';
import { browseDashboardsAPI, ImportInputs } from 'app/features/browse-dashboards/api/browseDashboardsAPI';
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
-import { PermissionLevelString, SearchQueryType } from 'app/types/acl';
import { ThunkResult } from 'app/types/store';
import {
@@ -21,7 +20,6 @@ import {
} from '../../dashboard/components/DashExportModal/DashboardExporter';
import { getLibraryPanel } from '../../library-panels/state/api';
import { LibraryElementDTO, LibraryElementKind } from '../../library-panels/types';
-import { DashboardSearchHit } from '../../search/types';
import { DashboardJson } from '../types';
import {
@@ -308,30 +306,6 @@ const getDataSourceDescription = (input: { usage?: InputUsage }): string | undef
return undefined;
};
-/** @deprecated Use RTK Query methods from features/browse-dashboards/api/browseDashboardsAPI.ts instead */
-export function createFolder(payload: any) {
- return getBackendSrv().post('/api/folders', payload);
-}
-
-export const SLICE_FOLDER_RESULTS_TO = 1000;
-
-export async function searchFolders(
- query: string,
- permission?: PermissionLevelString,
- type: SearchQueryType = SearchQueryType.Folder
-): Promise {
- return getBackendSrv().get('/api/search', {
- query,
- type: type,
- permission,
- limit: SLICE_FOLDER_RESULTS_TO,
- });
-}
-
-export function getFolderByUid(uid: string): Promise<{ uid: string; title: string }> {
- return getBackendSrv().get(`/api/folders/${uid}`);
-}
-
export async function processV2DatasourceInput(
spec: PanelQueryKind['spec'] | QueryVariableKind['spec'] | AnnotationQueryKind['spec'],
inputs: Record = {}
diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json
index d39902baac5..d6a38f55e6e 100644
--- a/public/locales/en-US/grafana.json
+++ b/public/locales/en-US/grafana.json
@@ -7526,11 +7526,6 @@
"select-aria-label": "Folder filter",
"select-placeholder": "Filter by folder"
},
- "folder-picker": {
- "create-instructions": "Press enter to create the new folder.",
- "input-placeholder": "Press enter to confirm new folder",
- "loading": "Loading folders..."
- },
"folder-repo": {
"provisioned-badge": "Provisioned",
"read-only-badge": "Read only"