From f3235ba959fb2c8e2f864c8cf655f9352a1fb6bd Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Fri, 21 Jul 2023 13:24:43 +0000 Subject: [PATCH] NestedFolders: Rename FolderPicker to OldFolderPicker (#72098) * Rename FolderPicker to OldFolderPicker * fix jest mock * fix jest mock --- .betterer.results | 2 +- public/app/angular/angular_wrappers.ts | 4 ++-- ...icker.test.tsx => OldFolderPicker.test.tsx} | 18 +++++++++--------- .../{FolderPicker.tsx => OldFolderPicker.tsx} | 2 +- .../rule-editor/RuleFolderPicker.tsx | 6 +++--- .../components/BrowseActions/MoveModal.tsx | 4 ++-- .../DashboardSettings/GeneralSettings.tsx | 4 ++-- .../forms/SaveDashboardAsForm.tsx | 4 ++-- .../AddLibraryPanelModal.tsx | 4 ++-- .../components/ImportDashboardForm.tsx | 4 ++-- .../page/components/ManageActions.test.tsx | 4 ++-- .../page/components/MoveToFolderModal.tsx | 4 ++-- public/app/plugins/panel/alertlist/module.tsx | 4 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) rename public/app/core/components/Select/{FolderPicker.test.tsx => OldFolderPicker.test.tsx} (91%) rename public/app/core/components/Select/{FolderPicker.tsx => OldFolderPicker.tsx} (99%) diff --git a/.betterer.results b/.betterer.results index 8bbd416ff1b..3db8c6dee02 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1550,7 +1550,7 @@ exports[`better eslint`] = { "public/app/core/components/QueryOperationRow/QueryOperationAction.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], - "public/app/core/components/Select/FolderPicker.tsx:5381": [ + "public/app/core/components/Select/OldFolderPicker.tsx:5381": [ [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] ], "public/app/core/components/TagFilter/TagFilter.tsx:5381": [ diff --git a/public/app/angular/angular_wrappers.ts b/public/app/angular/angular_wrappers.ts index 30a63a5af02..fc0263ca322 100644 --- a/public/app/angular/angular_wrappers.ts +++ b/public/app/angular/angular_wrappers.ts @@ -11,7 +11,7 @@ import { UnitPicker, } from '@grafana/ui'; import { react2AngularDirective } from 'app/angular/react2angular'; -import { FolderPicker } from 'app/core/components/Select/FolderPicker'; +import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker'; import { TimePickerSettings } from 'app/features/dashboard/components/DashboardSettings/TimePickerSettings'; import { QueryEditor as CloudMonitoringQueryEditor } from 'app/plugins/datasource/cloud-monitoring/components/QueryEditor'; @@ -119,7 +119,7 @@ export function registerAngularDirectives() { 'showForwardOAuthIdentityOption', ['onChange', { watchDepth: 'reference', wrapApply: true }], ]); - react2AngularDirective('folderPicker', FolderPicker, [ + react2AngularDirective('folderPicker', OldFolderPicker, [ 'labelClass', 'rootName', 'enableCreateNew', diff --git a/public/app/core/components/Select/FolderPicker.test.tsx b/public/app/core/components/Select/OldFolderPicker.test.tsx similarity index 91% rename from public/app/core/components/Select/FolderPicker.test.tsx rename to public/app/core/components/Select/OldFolderPicker.test.tsx index a074d4f5bd3..e75e65e1982 100644 --- a/public/app/core/components/Select/FolderPicker.test.tsx +++ b/public/app/core/components/Select/OldFolderPicker.test.tsx @@ -9,9 +9,9 @@ import * as api from 'app/features/manage-dashboards/state/actions'; import { DashboardSearchHit } from '../../../features/search/types'; -import { FolderPicker, getInitialValues } from './FolderPicker'; +import { OldFolderPicker, getInitialValues } from './OldFolderPicker'; -describe('FolderPicker', () => { +describe('OldFolderPicker', () => { it('should render', async () => { jest .spyOn(api, 'searchFolders') @@ -20,7 +20,7 @@ describe('FolderPicker', () => { { title: 'Dash 2', uid: 'wfTJJL5Wz' } as DashboardSearchHit, ]); - render(); + render(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); }); @@ -33,7 +33,7 @@ describe('FolderPicker', () => { { title: 'Dash 3', uid: '7MeksYbmk' } as DashboardSearchHit, ]); - render( hits.filter((h) => h.uid !== 'wfTJJL5Wz')} />); + render( hits.filter((h) => h.uid !== 'wfTJJL5Wz')} />); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); selectEvent.openMenu(pickerContainer); @@ -59,7 +59,7 @@ describe('FolderPicker', () => { const create = jest.spyOn(api, 'createFolder').mockResolvedValue(newFolder); - render(); + render(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); await userEvent.type(screen.getByLabelText('Select a folder'), newFolder.title); @@ -87,7 +87,7 @@ describe('FolderPicker', () => { jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(true); const onChangeFn = jest.fn(); - render(); + render(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); selectEvent.openMenu(pickerContainer); @@ -108,7 +108,7 @@ describe('FolderPicker', () => { jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(true); const onChangeFn = jest.fn(); - render(); + render(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); selectEvent.openMenu(pickerContainer); @@ -129,7 +129,7 @@ describe('FolderPicker', () => { jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(false); const onChangeFn = jest.fn(); - render(); + render(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); selectEvent.openMenu(pickerContainer); @@ -150,7 +150,7 @@ describe('FolderPicker', () => { }); jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(false); const onChangeFn = jest.fn(); - render(); + render(); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); await userEvent.type(pickerContainer, 'Test'); diff --git a/public/app/core/components/Select/FolderPicker.tsx b/public/app/core/components/Select/OldFolderPicker.tsx similarity index 99% rename from public/app/core/components/Select/FolderPicker.tsx rename to public/app/core/components/Select/OldFolderPicker.tsx index 96b9f0be4de..1290e25bd01 100644 --- a/public/app/core/components/Select/FolderPicker.tsx +++ b/public/app/core/components/Select/OldFolderPicker.tsx @@ -58,7 +58,7 @@ export interface Props { export type SelectedFolder = SelectableValue; const VALUE_FOR_ADD = '-10'; -export function FolderPicker(props: Props) { +export function OldFolderPicker(props: Props) { const { dashboardId, allowEmpty, diff --git a/public/app/features/alerting/unified/components/rule-editor/RuleFolderPicker.tsx b/public/app/features/alerting/unified/components/rule-editor/RuleFolderPicker.tsx index 73798d29ab1..98318fd3a8b 100644 --- a/public/app/features/alerting/unified/components/rule-editor/RuleFolderPicker.tsx +++ b/public/app/features/alerting/unified/components/rule-editor/RuleFolderPicker.tsx @@ -4,10 +4,10 @@ import React from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Stack } from '@grafana/experimental'; import { Icon, Tooltip, useStyles2 } from '@grafana/ui'; -import { FolderPicker, Props as FolderPickerProps } from 'app/core/components/Select/FolderPicker'; +import { OldFolderPicker, Props as FolderPickerProps } from 'app/core/components/Select/OldFolderPicker'; import { PermissionLevelString, SearchQueryType } from 'app/types'; -import { FolderWarning, CustomAdd } from '../../../../../core/components/Select/FolderPicker'; +import { FolderWarning, CustomAdd } from '../../../../../core/components/Select/OldFolderPicker'; export interface Folder { title: string; @@ -48,7 +48,7 @@ export function RuleFolderPicker(props: RuleFolderPickerProps) { }; return ( - ) : ( - + )} diff --git a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx index c5a6a46bc82..efef51b7b67 100644 --- a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.tsx @@ -7,7 +7,7 @@ import { CollapsableSection, Field, Input, RadioButtonGroup, TagsInput } from '@ import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker'; import { FolderChange } from 'app/core/components/NestedFolderPicker/types'; import { Page } from 'app/core/components/Page/Page'; -import { FolderPicker } from 'app/core/components/Select/FolderPicker'; +import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker'; import { updateTimeZoneDashboard, updateWeekStartDashboard } from 'app/features/dashboard/state/actions'; import { DeleteDashboardButton } from '../DeleteDashboard/DeleteDashboardButton'; @@ -112,7 +112,7 @@ export function GeneralSettingsUnconnected({ {config.featureToggles.nestedFolderPicker ? ( ) : ( - ) : ( - - setFolderUid(uid)} initialFolderUid={initialFolderUid} inputId="share-panel-library-panel-folder-picker" diff --git a/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx b/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx index 75475419cda..1e735327472 100644 --- a/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx +++ b/public/app/features/manage-dashboards/components/ImportDashboardForm.tsx @@ -14,7 +14,7 @@ import { InputControl, Legend, } from '@grafana/ui'; -import { FolderPicker } from 'app/core/components/Select/FolderPicker'; +import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker'; import { DashboardInput, @@ -82,7 +82,7 @@ export const ImportDashboardForm = ({ ( - + )} name="folder" control={control} diff --git a/public/app/features/search/page/components/ManageActions.test.tsx b/public/app/features/search/page/components/ManageActions.test.tsx index 04b25893b00..cd78a0c0899 100644 --- a/public/app/features/search/page/components/ManageActions.test.tsx +++ b/public/app/features/search/page/components/ManageActions.test.tsx @@ -14,9 +14,9 @@ jest.mock('app/core/services/context_srv', () => ({ }, })); -jest.mock('app/core/components/Select/FolderPicker', () => { +jest.mock('app/core/components/Select/OldFolderPicker', () => { return { - FolderPicker: () => null, + OldFolderPicker: () => null, }; }); diff --git a/public/app/features/search/page/components/MoveToFolderModal.tsx b/public/app/features/search/page/components/MoveToFolderModal.tsx index d2abba85b84..31440bc7c2d 100644 --- a/public/app/features/search/page/components/MoveToFolderModal.tsx +++ b/public/app/features/search/page/components/MoveToFolderModal.tsx @@ -3,7 +3,7 @@ import React, { useCallback, useState } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; import { Alert, Button, HorizontalGroup, Modal, useStyles2 } from '@grafana/ui'; -import { FolderPicker } from 'app/core/components/Select/FolderPicker'; +import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker'; import config from 'app/core/config'; import { useAppNotification } from 'app/core/copy/appNotification'; import { moveDashboards, moveFolders } from 'app/features/manage-dashboards/state/actions'; @@ -125,7 +125,7 @@ export const MoveToFolderModal = ({ results, onMoveItems, onDismiss }: Props) =>

Move {thingsMoving} to:

- + diff --git a/public/app/plugins/panel/alertlist/module.tsx b/public/app/plugins/panel/alertlist/module.tsx index 8a1cce08cd4..481d3ec14b0 100644 --- a/public/app/plugins/panel/alertlist/module.tsx +++ b/public/app/plugins/panel/alertlist/module.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { PanelPlugin } from '@grafana/data'; import { config, DataSourcePicker } from '@grafana/runtime'; import { TagsInput } from '@grafana/ui'; -import { FolderPicker } from 'app/core/components/Select/FolderPicker'; +import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker'; import { ALL_FOLDER, GENERAL_FOLDER, @@ -275,7 +275,7 @@ const unifiedAlertList = new PanelPlugin(UnifiedAlertLi defaultValue: null, editor: function RenderFolderPicker(props) { return ( -