Skip to content

Commit

Permalink
[ui-core] move hooks to nested folder (#3969)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramprasadagarwal authored Jan 27, 2025
1 parent 7d6d0d2 commit 07ab5d5
Show file tree
Hide file tree
Showing 37 changed files with 44 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Ace } from '../../../../../ext/ace';

import { CURSOR_POSITION_CHANGED_EVENT } from '../../aceEditor/AceLocationHandler';
import ReactExampleGlobal from '../../../../../reactComponents/ReactExampleGlobal/ReactExampleGlobal';
import { useHuePubSub } from '../../../../../utils/hooks/useHuePubSub';
import { useHuePubSub } from '../../../../../utils/hooks/useHuePubSub/useHuePubSub';
import SqlExecutable from '../../../execution/sqlExecutable';

import './ReactExample.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import FileIcon from '@cloudera/cuix-core/icons/react/DocumentationIcon';

import { i18nReact } from '../../../utils/i18nReact';
import useDebounce from '../../../utils/useDebounce';
import useLoadData from '../../../utils/hooks/useLoadData';
import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';

import { BrowserViewType, ListDirectory } from '../../../reactComponents/FileChooser/types';
import { LIST_DIRECTORY_API_URL } from '../../../reactComponents/FileChooser/api';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import StorageBrowserTab from './StorageBrowserTab/StorageBrowserTab';
import { ApiFileSystem, FILESYSTEMS_API_URL } from '../../reactComponents/FileChooser/api';

import './StorageBrowserPage.scss';
import useLoadData from '../../utils/hooks/useLoadData';
import useLoadData from '../../utils/hooks/useLoadData/useLoadData';
import LoadingErrorWrapper from '../../reactComponents/LoadingErrorWrapper/LoadingErrorWrapper';

const StorageBrowserPage = (): JSX.Element => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import PathBrowser from '../../../reactComponents/PathBrowser/PathBrowser';
import StorageDirectoryPage from '../StorageDirectoryPage/StorageDirectoryPage';
import { FILE_STATS_API_URL } from '../../../reactComponents/FileChooser/api';
import { BrowserViewType, FileStats } from '../../../reactComponents/FileChooser/types';
import useLoadData from '../../../utils/hooks/useLoadData';
import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';

import './StorageBrowserTab.scss';
import StorageFilePage from '../StorageFilePage/StorageFilePage';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../../../reactComponents/FileChooser/api';

const mockSave = jest.fn();
jest.mock('../../../../utils/hooks/useSaveData', () => ({
jest.mock('../../../../utils/hooks/useSaveData/useSaveData', () => ({
__esModule: true,
default: jest.fn(() => ({
save: mockSave
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
CREATE_FILE_API_URL
} from '../../../../reactComponents/FileChooser/api';
import { FileStats } from '../../../../reactComponents/FileChooser/types';
import useSaveData from '../../../../utils/hooks/useSaveData';
import useSaveData from '../../../../utils/hooks/useSaveData/useSaveData';
import InputModal from '../../InputModal/InputModal';
import './CreateAndUploadAction.scss';
import DragAndDrop from '../../../../reactComponents/DragAndDrop/DragAndDrop';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const mockFiles: StorageDirectoryTableData[] = [
];

const mockSave = jest.fn();
jest.mock('../../../../../utils/hooks/useSaveData', () => ({
jest.mock('../../../../../utils/hooks/useSaveData/useSaveData', () => ({
__esModule: true,
default: jest.fn(() => ({
save: mockSave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React, { useState } from 'react';
import Modal from 'cuix/dist/components/Modal';
import { i18nReact } from '../../../../../utils/i18nReact';
import useSaveData from '../../../../../utils/hooks/useSaveData';
import useSaveData from '../../../../../utils/hooks/useSaveData/useSaveData';
import { StorageDirectoryTableData } from '../../../../../reactComponents/FileChooser/types';
import { COMPRESS_API_URL } from '../../../../../reactComponents/FileChooser/api';
import { Input } from 'antd';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const mockFiles: StorageDirectoryTableData[] = [
];

const mockSave = jest.fn();
jest.mock('../../../../../utils/hooks/useSaveData', () => ({
jest.mock('../../../../../utils/hooks/useSaveData/useSaveData', () => ({
__esModule: true,
default: jest.fn(() => ({
save: mockSave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React from 'react';
import Modal from 'cuix/dist/components/Modal';
import { i18nReact } from '../../../../../utils/i18nReact';
import useSaveData from '../../../../../utils/hooks/useSaveData';
import useSaveData from '../../../../../utils/hooks/useSaveData/useSaveData';
import { StorageDirectoryTableData } from '../../../../../reactComponents/FileChooser/types';
import {
BULK_DELETION_API_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const mockFile: StorageDirectoryTableData = {

const mockSave = jest.fn();
let mockLoading = false;
jest.mock('../../../../../utils/hooks/useSaveData', () => ({
jest.mock('../../../../../utils/hooks/useSaveData/useSaveData', () => ({
__esModule: true,
default: jest.fn(() => ({
save: mockSave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React from 'react';
import Modal from 'cuix/dist/components/Modal';
import { i18nReact } from '../../../../../utils/i18nReact';
import useSaveData from '../../../../../utils/hooks/useSaveData';
import useSaveData from '../../../../../utils/hooks/useSaveData/useSaveData';
import { StorageDirectoryTableData } from '../../../../../reactComponents/FileChooser/types';
import { EXTRACT_API_URL } from '../../../../../reactComponents/FileChooser/api';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const mockFiles: StorageDirectoryTableData[] = [
replication: 1
}
];
jest.mock('../../../../../utils/hooks/useLoadData', () => ({
jest.mock('../../../../../utils/hooks/useLoadData/useLoadData', () => ({
__esModule: true,
default: jest.fn(() => ({
data: {
Expand All @@ -71,7 +71,7 @@ jest.mock('../../../../../utils/hooks/useLoadData', () => ({
}));

const mockSave = jest.fn();
jest.mock('../../../../../utils/hooks/useSaveData', () => ({
jest.mock('../../../../../utils/hooks/useSaveData/useSaveData', () => ({
__esModule: true,
default: jest.fn(() => ({
save: mockSave
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import React from 'react';
import { i18nReact } from '../../../../../utils/i18nReact';
import useSaveData from '../../../../../utils/hooks/useSaveData';
import useSaveData from '../../../../../utils/hooks/useSaveData/useSaveData';
import { ActionType } from '../StorageBrowserActions.util';
import {
BULK_COPY_API_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import RenameModal from './RenameModal';
import { StorageDirectoryTableData } from '../../../../../reactComponents/FileChooser/types';

const mockSave = jest.fn();
jest.mock('../../../../../utils/hooks/useSaveData', () => ({
jest.mock('../../../../../utils/hooks/useSaveData/useSaveData', () => ({
__esModule: true,
default: jest.fn(() => ({
save: mockSave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React from 'react';
import { StorageDirectoryTableData } from '../../../../../reactComponents/FileChooser/types';
import { i18nReact } from '../../../../../utils/i18nReact';
import useSaveData from '../../../../../utils/hooks/useSaveData';
import useSaveData from '../../../../../utils/hooks/useSaveData/useSaveData';
import { RENAME_API_URL } from '../../../../../reactComponents/FileChooser/api';
import InputModal from '../../../InputModal/InputModal';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ReplicationModal from './ReplicationModal';
import { StorageDirectoryTableData } from '../../../../../reactComponents/FileChooser/types';

const mockSave = jest.fn();
jest.mock('../../../../../utils/hooks/useSaveData', () => ({
jest.mock('../../../../../utils/hooks/useSaveData/useSaveData', () => ({
__esModule: true,
default: jest.fn(() => ({
save: mockSave,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import React from 'react';
import { StorageDirectoryTableData } from '../../../../../reactComponents/FileChooser/types';
import { i18nReact } from '../../../../../utils/i18nReact';
import useSaveData from '../../../../../utils/hooks/useSaveData';
import useSaveData from '../../../../../utils/hooks/useSaveData/useSaveData';
import { SET_REPLICATION_API_URL } from '../../../../../reactComponents/FileChooser/api';
import InputModal from '../../../InputModal/InputModal';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Spin } from 'antd';
import huePubSub from '../../../../../utils/huePubSub';
import { i18nReact } from '../../../../../utils/i18nReact';
import formatBytes from '../../../../../utils/formatBytes';
import useLoadData from '../../../../../utils/hooks/useLoadData';
import useLoadData from '../../../../../utils/hooks/useLoadData/useLoadData';
import { CONTENT_SUMMARY_API_URL } from '../../../../../reactComponents/FileChooser/api';
import {
ContentSummary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import formatBytes from '../../../utils/formatBytes';

import './StorageDirectoryPage.scss';
import { formatTimestamp } from '../../../utils/dateTimeUtils';
import useLoadData from '../../../utils/hooks/useLoadData';
import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';
import {
DEFAULT_PAGE_SIZE,
DEFAULT_POLLING_TIME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const mockData = jest.fn().mockReturnValue({
compression: 'none'
});

jest.mock('../../../utils/hooks/useLoadData', () => {
jest.mock('../../../utils/hooks/useLoadData/useLoadData', () => {
return jest.fn(() => ({
data: mockData(),
loading: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ import {
SAVE_FILE_API_URL
} from '../../../reactComponents/FileChooser/api';
import huePubSub from '../../../utils/huePubSub';
import useSaveData from '../../../utils/hooks/useSaveData';
import useSaveData from '../../../utils/hooks/useSaveData/useSaveData';
import Pagination from '../../../reactComponents/Pagination/Pagination';
import {
DEFAULT_PREVIEW_PAGE_SIZE,
EDITABLE_FILE_FORMATS,
SUPPORTED_FILE_EXTENSIONS,
SupportedFileTypes
} from '../../../utils/constants/storageBrowser';
import useLoadData from '../../../utils/hooks/useLoadData';
import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';
import { getLastKnownConfig } from '../../../config/hueConfig';
import LoadingErrorWrapper from '../../../reactComponents/LoadingErrorWrapper/LoadingErrorWrapper';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ApiFileSystem, FILESYSTEMS_API_URL } from '../api';
import { FileSystem } from '../types';
import './FileChooserModal.scss';
import PathBrowser from '../../PathBrowser/PathBrowser';
import useLoadData from '../../../utils/hooks/useLoadData';
import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';

interface FileProps {
show: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const sortOrder = [
const FileUploadQueue: React.FC<FileUploadQueueProps> = ({ filesQueue, onClose, onComplete }) => {
const config = getLastKnownConfig();
const isChunkUpload =
config?.storage_browser.enable_chunked_file_upload ?? DEFAULT_ENABLE_CHUNK_UPLOAD;
(config?.storage_browser.enable_chunked_file_upload ?? DEFAULT_ENABLE_CHUNK_UPLOAD) &&
!!config?.hue_config.enable_task_server;

const { t } = i18nReact.useTranslation();
const [isExpanded, setIsExpanded] = useState(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
HIDE_GLOBAL_ALERTS_TOPIC
} from './events';
import { HueAlert } from './types';
import { useHuePubSub } from '../../utils/hooks/useHuePubSub';
import { useHuePubSub } from '../../utils/hooks/useHuePubSub/useHuePubSub';
import { i18nReact } from 'utils/i18nReact';

type alertType = AlertProps['type'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Pagination = ({
label: (
<BorderlessButton
onClick={() => {
setPageSize && setPageSize(option);
setPageSize?.(option);
setPageNumber(1);
}}
className="hue-pagination__page-size-menu-item-btn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Joyride from 'react-joyride';

import { hueWindow } from 'types/types';
import I18n from 'utils/i18n';
import { useHuePubSub } from '../../utils/hooks/useHuePubSub';
import { useHuePubSub } from '../../utils/hooks/useHuePubSub/useHuePubSub';

import './WelcomeTour.scss';
import scssVariables from './WelcomeTour.module.scss';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

import { useEffect, useState } from 'react';
import { getLastKnownConfig } from '../../../config/hueConfig';
import useSaveData from '../useSaveData';
import useQueueProcessor from '../useQueueProcessor';
import useSaveData from '../useSaveData/useSaveData';
import useQueueProcessor from '../useQueueProcessor/useQueueProcessor';
import {
DEFAULT_CHUNK_SIZE,
DEFAULT_CONCURRENT_MAX_CONNECTIONS,
FileUploadStatus
} from '../../constants/storageBrowser';
import useLoadData from '../useLoadData';
import useLoadData from '../useLoadData/useLoadData';
import { TaskServerResponse, TaskStatus } from '../../../reactComponents/TaskBrowser/TaskBrowser';
import {
createChunks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import useQueueProcessor from '../useQueueProcessor';
import useQueueProcessor from '../useQueueProcessor/useQueueProcessor';
import { UPLOAD_FILE_URL } from '../../../reactComponents/FileChooser/api';
import {
DEFAULT_CONCURRENT_MAX_CONNECTIONS,
FileUploadStatus
} from '../../constants/storageBrowser';
import useSaveData from '../useSaveData';
import useSaveData from '../useSaveData/useSaveData';
import { UploadItem } from './util';

interface UseUploadQueueResponse {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { renderHook, act } from '@testing-library/react';
import { useHuePubSub } from './useHuePubSub';
import huePubSub from '../huePubSub';
import noop from '../timing/noop';
import huePubSub from '../../huePubSub';
import noop from '../../timing/noop';

describe('useHuePubSub', () => {
const originalSubscribe = huePubSub.subscribe;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// limitations under the License.

import { useState, useEffect } from 'react';
import huePubSub from '../huePubSub';
import huePubSub from '../../huePubSub';

// Basic helper hook to let a component subscribe to a huePubSub topic and rerender for each message
// by placing the message/info in a state that is automatically updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import { renderHook, act, waitFor } from '@testing-library/react';
import useLoadData from './useLoadData';
import { get } from '../../api/utils';
import { get } from '../../../api/utils';

// Mock the `get` function
jest.mock('../../api/utils', () => ({
jest.mock('../../../api/utils', () => ({
get: jest.fn()
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// limitations under the License.

import { useCallback, useEffect, useMemo, useState } from 'react';
import { ApiFetchOptions, get } from '../../api/utils';
import { ApiFetchOptions, get } from '../../../api/utils';
import { AxiosError } from 'axios';

export interface Options<T, U> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// limitations under the License.
import { renderHook, act, waitFor } from '@testing-library/react';
import useSaveData from './useSaveData';
import { post } from '../../api/utils';
import { post } from '../../../api/utils';

jest.mock('../../api/utils', () => ({
jest.mock('../../../api/utils', () => ({
post: jest.fn()
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// limitations under the License.

import { useCallback, useEffect, useMemo, useState } from 'react';
import { ApiFetchOptions, post } from '../../api/utils';
import { ApiFetchOptions, post } from '../../../api/utils';

interface saveOptions<T> {
url?: string;
Expand Down

0 comments on commit 07ab5d5

Please sign in to comment.