Jelajahi Sumber

[ui-core] remove redundant file chooser component (#4104)

Ram Prasad Agarwal 7 bulan lalu
induk
melakukan
34418a5265

+ 0 - 42
desktop/core/src/desktop/js/reactComponents/FileChooser/FileChooserModal/FileChooserModal.scss

@@ -1,42 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-@use 'variables' as vars;
-
-.hue-file-chooser__modal .ant-modal-body {
-  padding: 0;
-  height: 554px;
-
-  .hue-file-system__panel {
-    height: 554px;
-    background-color: vars.$fluidx-gray-100;
-    padding-top: 20px;
-
-    .ant-menu-item {
-      display: flex;
-      align-items: center;
-    }
-
-    .ant-menu-item-icon {
-      height: 20px;
-      width: 20px;
-    }
-
-    .ant-menu-item-selected {
-      background-color: vars.$fluidx-gray-300;
-    }
-  }
-}

+ 0 - 128
desktop/core/src/desktop/js/reactComponents/FileChooser/FileChooserModal/FileChooserModal.tsx

@@ -1,128 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import React, { useState, useEffect, useMemo } from 'react';
-import Modal from 'antd/lib/modal/Modal';
-import { Col, Menu, Row, Spin, Button } from 'antd';
-
-import HdfsIcon from '../../../components/icons/HdfsIcon';
-import S3Icon from '../../../components/icons/S3Icon';
-import AdlsIcon from '../../../components/icons/AdlsIcon';
-
-import { FILESYSTEMS_API_URL } from '../../../apps/storageBrowser/api';
-import { FileSystem } from '../../../apps/storageBrowser/types';
-import './FileChooserModal.scss';
-import PathBrowser from '../../PathBrowser/PathBrowser';
-import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';
-
-interface FileProps {
-  show: boolean;
-  onCancel: () => void;
-  title?: string;
-  okText?: string;
-}
-
-interface FileChooserMenu {
-  label: string;
-  key: number;
-  icon: React.ReactNode;
-  user_home_dir: string;
-}
-
-const defaultProps = { title: 'Choose a file', okText: 'Select' };
-
-const FileChooserModal: React.FC<FileProps> = ({ show, onCancel, title, okText }) => {
-  const [filePath, setFilePath] = useState<string | undefined>();
-
-  const icons = {
-    hdfs: <HdfsIcon />,
-    abfs: <AdlsIcon />,
-    s3: <S3Icon />
-  };
-
-  //temporary until the file is selected through the file chooser component
-  const handleOk = onCancel;
-  const handleCancel = onCancel;
-
-  const { data, loading } = useLoadData<FileSystem[]>(FILESYSTEMS_API_URL);
-
-  const fileSystemList: FileChooserMenu[] | undefined = useMemo(
-    () =>
-      data?.map((fileSystem, index) => ({
-        label: fileSystem.name,
-        key: index,
-        icon: icons[fileSystem.name],
-        user_home_dir: fileSystem.userHomeDirectory
-      })),
-    [data]
-  );
-
-  useEffect(() => {
-    if (data && data?.length !== 0) {
-      setFilePath(data[0].userHomeDirectory);
-    }
-  }, [data]);
-
-  return (
-    <Modal
-      title={title}
-      open={show}
-      onOk={handleOk}
-      onCancel={handleCancel}
-      okText={okText}
-      width={930}
-      className="hue-file-chooser__modal"
-    >
-      <Spin spinning={loading}>
-        <Row>
-          <Col span={5}>
-            <Menu
-              items={fileSystemList}
-              onSelect={selectedMenuItem => {
-                setFilePath(fileSystemList?.[selectedMenuItem.key].user_home_dir);
-              }}
-              className="hue-file-system__panel"
-            ></Menu>
-          </Col>
-          <Col span={19}>
-            <Row className="hue-path-browser-panel" onClick={e => e.stopPropagation()}>
-              <Col span={18}>
-                {filePath && (
-                  <PathBrowser
-                    filePath={filePath}
-                    onFilepathChange={setFilePath}
-                    separator={'>'}
-                    showIcon={true}
-                  />
-                )}
-              </Col>
-              <Col span={3}>
-                <Button className="hue-path-browser-panel__button">New Folder</Button>
-              </Col>
-              <Col span={3}>
-                <Button className="hue-path-browser-panel__button">Upload</Button>
-              </Col>
-            </Row>
-          </Col>
-        </Row>
-      </Spin>
-    </Modal>
-  );
-};
-
-FileChooserModal.defaultProps = defaultProps;
-
-export default FileChooserModal;

+ 0 - 25
desktop/core/src/desktop/js/reactComponents/FileChooser/FileChooserWithButton/FileChooserWithButton.scss

@@ -1,25 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-@use 'variables' as vars;
-
-
-.hue-file-chooser__button {
-  background-color: vars.$hue-primary-color-dark;
-  color: white;
-  margin-left: 40px;
-  margin-top: 12px;
-}

+ 0 - 50
desktop/core/src/desktop/js/reactComponents/FileChooser/FileChooserWithButton/FileChooserWithButton.tsx

@@ -1,50 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import React, { useState } from 'react';
-import { Button } from 'antd';
-
-import './FileChooserWithButton.scss';
-import FileChooserModal from '../FileChooserModal/FileChooserModal';
-
-interface FileChooserWithButtonProps {
-  title: string;
-}
-
-const defaultProps = { title: 'File chooser component' };
-
-const FileChooserWithButton: React.FC<FileChooserWithButtonProps> = ({ title }): JSX.Element => {
-  const [show, setShow] = useState(false);
-
-  return (
-    <>
-      <Button className="hue-file-chooser__button" type="primary" onClick={() => setShow(true)}>
-        {title}
-      </Button>
-
-      <FileChooserModal
-        onCancel={() => setShow(false)}
-        show={show}
-        title="Choose a file"
-        okText="Select"
-      />
-    </>
-  );
-};
-
-FileChooserWithButton.defaultProps = defaultProps;
-
-export default FileChooserWithButton;

+ 0 - 3
desktop/core/src/desktop/js/reactComponents/imports.js

@@ -29,9 +29,6 @@ export async function loadComponent(name) {
     case 'ReactExampleGlobal':
       return (await import('./ReactExampleGlobal/ReactExampleGlobal')).default;
 
-    case 'FileChooserWithButton':
-      return (await import('./FileChooser/FileChooserWithButton/FileChooserWithButton')).default;
-
     case 'WelcomeTour':
       return (await import('./WelcomeTour/WelcomeTour')).default;