NestedFolders: Rename FolderPicker to OldFolderPicker (#72098)

* Rename FolderPicker to OldFolderPicker

* fix jest mock

* fix jest mock
This commit is contained in:
Josh Hunt 2023-07-21 13:24:43 +00:00 committed by GitHub
parent b9fc097ccd
commit f3235ba959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 32 additions and 32 deletions

View File

@ -1550,7 +1550,7 @@ exports[`better eslint`] = {
"public/app/core/components/QueryOperationRow/QueryOperationAction.tsx:5381": [ "public/app/core/components/QueryOperationRow/QueryOperationAction.tsx:5381": [
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"] [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"] [0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
], ],
"public/app/core/components/TagFilter/TagFilter.tsx:5381": [ "public/app/core/components/TagFilter/TagFilter.tsx:5381": [

View File

@ -11,7 +11,7 @@ import {
UnitPicker, UnitPicker,
} from '@grafana/ui'; } from '@grafana/ui';
import { react2AngularDirective } from 'app/angular/react2angular'; 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 { TimePickerSettings } from 'app/features/dashboard/components/DashboardSettings/TimePickerSettings';
import { QueryEditor as CloudMonitoringQueryEditor } from 'app/plugins/datasource/cloud-monitoring/components/QueryEditor'; import { QueryEditor as CloudMonitoringQueryEditor } from 'app/plugins/datasource/cloud-monitoring/components/QueryEditor';
@ -119,7 +119,7 @@ export function registerAngularDirectives() {
'showForwardOAuthIdentityOption', 'showForwardOAuthIdentityOption',
['onChange', { watchDepth: 'reference', wrapApply: true }], ['onChange', { watchDepth: 'reference', wrapApply: true }],
]); ]);
react2AngularDirective('folderPicker', FolderPicker, [ react2AngularDirective('folderPicker', OldFolderPicker, [
'labelClass', 'labelClass',
'rootName', 'rootName',
'enableCreateNew', 'enableCreateNew',

View File

@ -9,9 +9,9 @@ import * as api from 'app/features/manage-dashboards/state/actions';
import { DashboardSearchHit } from '../../../features/search/types'; import { DashboardSearchHit } from '../../../features/search/types';
import { FolderPicker, getInitialValues } from './FolderPicker'; import { OldFolderPicker, getInitialValues } from './OldFolderPicker';
describe('FolderPicker', () => { describe('OldFolderPicker', () => {
it('should render', async () => { it('should render', async () => {
jest jest
.spyOn(api, 'searchFolders') .spyOn(api, 'searchFolders')
@ -20,7 +20,7 @@ describe('FolderPicker', () => {
{ title: 'Dash 2', uid: 'wfTJJL5Wz' } as DashboardSearchHit, { title: 'Dash 2', uid: 'wfTJJL5Wz' } as DashboardSearchHit,
]); ]);
render(<FolderPicker onChange={jest.fn()} />); render(<OldFolderPicker onChange={jest.fn()} />);
expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument();
}); });
@ -33,7 +33,7 @@ describe('FolderPicker', () => {
{ title: 'Dash 3', uid: '7MeksYbmk' } as DashboardSearchHit, { title: 'Dash 3', uid: '7MeksYbmk' } as DashboardSearchHit,
]); ]);
render(<FolderPicker onChange={jest.fn()} filter={(hits) => hits.filter((h) => h.uid !== 'wfTJJL5Wz')} />); render(<OldFolderPicker onChange={jest.fn()} filter={(hits) => hits.filter((h) => h.uid !== 'wfTJJL5Wz')} />);
const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input);
selectEvent.openMenu(pickerContainer); selectEvent.openMenu(pickerContainer);
@ -59,7 +59,7 @@ describe('FolderPicker', () => {
const create = jest.spyOn(api, 'createFolder').mockResolvedValue(newFolder); const create = jest.spyOn(api, 'createFolder').mockResolvedValue(newFolder);
render(<FolderPicker onChange={onChangeFn} enableCreateNew={true} allowEmpty={true} />); render(<OldFolderPicker onChange={onChangeFn} enableCreateNew={true} allowEmpty={true} />);
expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument();
await userEvent.type(screen.getByLabelText('Select a folder'), newFolder.title); await userEvent.type(screen.getByLabelText('Select a folder'), newFolder.title);
@ -87,7 +87,7 @@ describe('FolderPicker', () => {
jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(true); jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(true);
const onChangeFn = jest.fn(); const onChangeFn = jest.fn();
render(<FolderPicker onChange={onChangeFn} />); render(<OldFolderPicker onChange={onChangeFn} />);
expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument();
const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input);
selectEvent.openMenu(pickerContainer); selectEvent.openMenu(pickerContainer);
@ -108,7 +108,7 @@ describe('FolderPicker', () => {
jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(true); jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(true);
const onChangeFn = jest.fn(); const onChangeFn = jest.fn();
render(<FolderPicker onChange={onChangeFn} showRoot={false} />); render(<OldFolderPicker onChange={onChangeFn} showRoot={false} />);
expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument();
const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input);
selectEvent.openMenu(pickerContainer); selectEvent.openMenu(pickerContainer);
@ -129,7 +129,7 @@ describe('FolderPicker', () => {
jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(false); jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(false);
const onChangeFn = jest.fn(); const onChangeFn = jest.fn();
render(<FolderPicker onChange={onChangeFn} />); render(<OldFolderPicker onChange={onChangeFn} />);
expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument(); expect(await screen.findByTestId(selectors.components.FolderPicker.containerV2)).toBeInTheDocument();
const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input);
selectEvent.openMenu(pickerContainer); selectEvent.openMenu(pickerContainer);
@ -150,7 +150,7 @@ describe('FolderPicker', () => {
}); });
jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(false); jest.spyOn(contextSrv, 'hasAccess').mockReturnValue(false);
const onChangeFn = jest.fn(); const onChangeFn = jest.fn();
render(<FolderPicker onChange={onChangeFn} />); render(<OldFolderPicker onChange={onChangeFn} />);
const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input); const pickerContainer = screen.getByLabelText(selectors.components.FolderPicker.input);
await userEvent.type(pickerContainer, 'Test'); await userEvent.type(pickerContainer, 'Test');

View File

@ -58,7 +58,7 @@ export interface Props {
export type SelectedFolder = SelectableValue<string>; export type SelectedFolder = SelectableValue<string>;
const VALUE_FOR_ADD = '-10'; const VALUE_FOR_ADD = '-10';
export function FolderPicker(props: Props) { export function OldFolderPicker(props: Props) {
const { const {
dashboardId, dashboardId,
allowEmpty, allowEmpty,

View File

@ -4,10 +4,10 @@ import React from 'react';
import { GrafanaTheme2 } from '@grafana/data'; import { GrafanaTheme2 } from '@grafana/data';
import { Stack } from '@grafana/experimental'; import { Stack } from '@grafana/experimental';
import { Icon, Tooltip, useStyles2 } from '@grafana/ui'; 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 { PermissionLevelString, SearchQueryType } from 'app/types';
import { FolderWarning, CustomAdd } from '../../../../../core/components/Select/FolderPicker'; import { FolderWarning, CustomAdd } from '../../../../../core/components/Select/OldFolderPicker';
export interface Folder { export interface Folder {
title: string; title: string;
@ -48,7 +48,7 @@ export function RuleFolderPicker(props: RuleFolderPickerProps) {
}; };
return ( return (
<FolderPicker <OldFolderPicker
showRoot={false} showRoot={false}
rootName="" rootName=""
allowEmpty={true} allowEmpty={true}

View File

@ -6,7 +6,7 @@ import { Alert, Button, Field, Modal } from '@grafana/ui';
import { Text } from '@grafana/ui/src/unstable'; import { Text } from '@grafana/ui/src/unstable';
import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker'; import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker';
import { FolderChange } from 'app/core/components/NestedFolderPicker/types'; import { FolderChange } from 'app/core/components/NestedFolderPicker/types';
import { FolderPicker } from 'app/core/components/Select/FolderPicker'; import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
import { t, Trans } from 'app/core/internationalization'; import { t, Trans } from 'app/core/internationalization';
import { DashboardTreeSelection } from '../../types'; import { DashboardTreeSelection } from '../../types';
@ -63,7 +63,7 @@ export const MoveModal = ({ onConfirm, onDismiss, selectedItems, ...props }: Pro
{config.featureToggles.nestedFolderPicker ? ( {config.featureToggles.nestedFolderPicker ? (
<NestedFolderPicker value={moveTarget} onChange={handleFolderChange} excludeUIDs={selectedFolders} /> <NestedFolderPicker value={moveTarget} onChange={handleFolderChange} excludeUIDs={selectedFolders} />
) : ( ) : (
<FolderPicker allowEmpty onChange={handleFolderChange} /> <OldFolderPicker allowEmpty onChange={handleFolderChange} />
)} )}
</Field> </Field>

View File

@ -7,7 +7,7 @@ import { CollapsableSection, Field, Input, RadioButtonGroup, TagsInput } from '@
import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker'; import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker';
import { FolderChange } from 'app/core/components/NestedFolderPicker/types'; import { FolderChange } from 'app/core/components/NestedFolderPicker/types';
import { Page } from 'app/core/components/Page/Page'; 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 { updateTimeZoneDashboard, updateWeekStartDashboard } from 'app/features/dashboard/state/actions';
import { DeleteDashboardButton } from '../DeleteDashboard/DeleteDashboardButton'; import { DeleteDashboardButton } from '../DeleteDashboard/DeleteDashboardButton';
@ -112,7 +112,7 @@ export function GeneralSettingsUnconnected({
{config.featureToggles.nestedFolderPicker ? ( {config.featureToggles.nestedFolderPicker ? (
<NestedFolderPicker value={dashboard.meta.folderUid} onChange={onFolderChange} /> <NestedFolderPicker value={dashboard.meta.folderUid} onChange={onFolderChange} />
) : ( ) : (
<FolderPicker <OldFolderPicker
inputId="dashboard-folder-input" inputId="dashboard-folder-input"
initialTitle={dashboard.meta.folderTitle} initialTitle={dashboard.meta.folderTitle}
initialFolderUid={dashboard.meta.folderUid} initialFolderUid={dashboard.meta.folderUid}

View File

@ -3,7 +3,7 @@ import React from 'react';
import { config } from '@grafana/runtime'; import { config } from '@grafana/runtime';
import { Button, Input, Switch, Form, Field, InputControl, HorizontalGroup } from '@grafana/ui'; import { Button, Input, Switch, Form, Field, InputControl, HorizontalGroup } from '@grafana/ui';
import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker'; import { NestedFolderPicker } from 'app/core/components/NestedFolderPicker/NestedFolderPicker';
import { FolderPicker } from 'app/core/components/Select/FolderPicker'; import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
import { DashboardModel, PanelModel } from 'app/features/dashboard/state'; import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
import { validationSrv } from 'app/features/manage-dashboards/services/ValidationSrv'; import { validationSrv } from 'app/features/manage-dashboards/services/ValidationSrv';
@ -114,7 +114,7 @@ export const SaveDashboardAsForm = ({
config.featureToggles.nestedFolderPicker ? ( config.featureToggles.nestedFolderPicker ? (
<NestedFolderPicker {...field} value={field.value?.uid} /> <NestedFolderPicker {...field} value={field.value?.uid} />
) : ( ) : (
<FolderPicker <OldFolderPicker
{...field} {...field}
dashboardId={dashboard.id} dashboardId={dashboard.id}
initialFolderUid={dashboard.meta.folderUid} initialFolderUid={dashboard.meta.folderUid}

View File

@ -3,7 +3,7 @@ import { useAsync, useDebounce } from 'react-use';
import { isFetchError } from '@grafana/runtime'; import { isFetchError } from '@grafana/runtime';
import { Button, Field, Input, Modal } from '@grafana/ui'; import { Button, Field, Input, Modal } from '@grafana/ui';
import { FolderPicker } from 'app/core/components/Select/FolderPicker'; import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
import { t, Trans } from 'app/core/internationalization'; import { t, Trans } from 'app/core/internationalization';
import { PanelModel } from '../../../dashboard/state'; import { PanelModel } from '../../../dashboard/state';
@ -71,7 +71,7 @@ export const AddLibraryPanelContents = ({ panel, initialFolderUid, onDismiss }:
'Library panel permissions are derived from the folder permissions' 'Library panel permissions are derived from the folder permissions'
)} )}
> >
<FolderPicker <OldFolderPicker
onChange={({ uid }) => setFolderUid(uid)} onChange={({ uid }) => setFolderUid(uid)}
initialFolderUid={initialFolderUid} initialFolderUid={initialFolderUid}
inputId="share-panel-library-panel-folder-picker" inputId="share-panel-library-panel-folder-picker"

View File

@ -14,7 +14,7 @@ import {
InputControl, InputControl,
Legend, Legend,
} from '@grafana/ui'; } from '@grafana/ui';
import { FolderPicker } from 'app/core/components/Select/FolderPicker'; import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
import { import {
DashboardInput, DashboardInput,
@ -82,7 +82,7 @@ export const ImportDashboardForm = ({
<Field label="Folder"> <Field label="Folder">
<InputControl <InputControl
render={({ field: { ref, ...field } }) => ( render={({ field: { ref, ...field } }) => (
<FolderPicker {...field} enableCreateNew initialFolderUid={initialFolderUid} /> <OldFolderPicker {...field} enableCreateNew initialFolderUid={initialFolderUid} />
)} )}
name="folder" name="folder"
control={control} control={control}

View File

@ -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 { return {
FolderPicker: () => null, OldFolderPicker: () => null,
}; };
}); });

View File

@ -3,7 +3,7 @@ import React, { useCallback, useState } from 'react';
import { GrafanaTheme2 } from '@grafana/data'; import { GrafanaTheme2 } from '@grafana/data';
import { Alert, Button, HorizontalGroup, Modal, useStyles2 } from '@grafana/ui'; 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 config from 'app/core/config';
import { useAppNotification } from 'app/core/copy/appNotification'; import { useAppNotification } from 'app/core/copy/appNotification';
import { moveDashboards, moveFolders } from 'app/features/manage-dashboards/state/actions'; import { moveDashboards, moveFolders } from 'app/features/manage-dashboards/state/actions';
@ -125,7 +125,7 @@ export const MoveToFolderModal = ({ results, onMoveItems, onDismiss }: Props) =>
<p>Move {thingsMoving} to:</p> <p>Move {thingsMoving} to:</p>
<FolderPicker allowEmpty={true} enableCreateNew={false} onChange={handleFolderChange} /> <OldFolderPicker allowEmpty={true} enableCreateNew={false} onChange={handleFolderChange} />
</div> </div>
<HorizontalGroup justify="flex-end"> <HorizontalGroup justify="flex-end">

View File

@ -3,7 +3,7 @@ import React from 'react';
import { PanelPlugin } from '@grafana/data'; import { PanelPlugin } from '@grafana/data';
import { config, DataSourcePicker } from '@grafana/runtime'; import { config, DataSourcePicker } from '@grafana/runtime';
import { TagsInput } from '@grafana/ui'; import { TagsInput } from '@grafana/ui';
import { FolderPicker } from 'app/core/components/Select/FolderPicker'; import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
import { import {
ALL_FOLDER, ALL_FOLDER,
GENERAL_FOLDER, GENERAL_FOLDER,
@ -275,7 +275,7 @@ const unifiedAlertList = new PanelPlugin<UnifiedAlertListOptions>(UnifiedAlertLi
defaultValue: null, defaultValue: null,
editor: function RenderFolderPicker(props) { editor: function RenderFolderPicker(props) {
return ( return (
<FolderPicker <OldFolderPicker
enableReset={true} enableReset={true}
showRoot={false} showRoot={false}
allowEmpty={true} allowEmpty={true}