This is an automated email from the ASF dual-hosted git repository.

mintsweet pushed a commit to branch fix-6086
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit a5c6e29083d6c93bc4a7f0c9e86082f0e03f24a1
Author: mintsweet <[email protected]>
AuthorDate: Thu Sep 14 19:16:36 2023 +1200

    refactor(config-ui): remove data scope miller columns
---
 .../components/data-scope-miller-columns/api.ts    |  36 ------
 .../components/data-scope-miller-columns/index.tsx | 138 ---------------------
 .../components/data-scope-miller-columns/styled.ts |  24 ----
 .../components/data-scope-miller-columns/types.ts  |  22 ----
 config-ui/src/plugins/components/index.ts          |   1 -
 5 files changed, 221 deletions(-)

diff --git a/config-ui/src/plugins/components/data-scope-miller-columns/api.ts 
b/config-ui/src/plugins/components/data-scope-miller-columns/api.ts
deleted file mode 100644
index 56f052889..000000000
--- a/config-ui/src/plugins/components/data-scope-miller-columns/api.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 { request } from '@/utils';
-
-type Params = {
-  groupId: ID | null;
-  pageToken?: string;
-};
-
-export const prepareToken = (plugin: string, connectionId: ID, params: object) 
=>
-  
request(`/plugins/${plugin}/connections/${connectionId}/remote-scopes-prepare-token`,
 {
-    method: 'get',
-    data: params,
-  });
-
-export const getScope = (plugin: string, connectionId: ID, params: Params) =>
-  request(`/plugins/${plugin}/connections/${connectionId}/remote-scopes`, {
-    method: 'get',
-    data: params,
-  });
diff --git 
a/config-ui/src/plugins/components/data-scope-miller-columns/index.tsx 
b/config-ui/src/plugins/components/data-scope-miller-columns/index.tsx
deleted file mode 100644
index 97396786f..000000000
--- a/config-ui/src/plugins/components/data-scope-miller-columns/index.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 { useState, useEffect } from 'react';
-import type { McsID, McsItem, McsColumn } from 'miller-columns-select';
-import type { MillerColumnsSelectProps } from 'miller-columns-select';
-import MillerColumnsSelect from 'miller-columns-select';
-
-import { Loading } from '@/components';
-
-import type { ExtraType } from './types';
-import * as API from './api';
-import * as S from './styled';
-
-interface Props extends Pick<MillerColumnsSelectProps<ExtraType>, 
'columnCount'> {
-  title?: string;
-  plugin: string;
-  connectionId: ID;
-  disabledItems?: any[];
-  selectedItems?: any[];
-  pageToken?: string;
-  onChangeItems?: (selectedItems: any[]) => void;
-}
-
-export const DataScopeMillerColumns = ({
-  title,
-  plugin,
-  connectionId,
-  disabledItems,
-  selectedItems,
-  onChangeItems,
-  pageToken,
-  ...props
-}: Props) => {
-  const [items, setItems] = useState<McsItem<ExtraType>[]>([]);
-  const [selectedIds, setSelectedIds] = useState<ID[]>([]);
-  const [disabledIds, setDisabledIds] = useState<ID[]>([]);
-  const [loadedIds, setLoadedIds] = useState<ID[]>([]);
-  const [nextTokenMap, setNextTokenMap] = useState<Record<ID, string>>({});
-
-  useEffect(() => {
-    setSelectedIds((selectedItems ?? []).map((it) => it.id));
-  }, [selectedItems]);
-
-  useEffect(() => {
-    setDisabledIds((disabledItems ?? []).map((it) => it.id));
-  }, [disabledItems]);
-
-  const getItems = async (groupId: ID | null, currentPageToken?: string) => {
-    if (!currentPageToken) {
-      currentPageToken = pageToken;
-    }
-    const res = await API.getScope(plugin, connectionId, {
-      groupId,
-      pageToken: currentPageToken,
-    });
-
-    setItems([
-      ...items,
-      ...(res.children ?? []).map((it: any) => ({
-        ...it,
-        title: it.name,
-      })),
-    ]);
-
-    if (!res.nextPageToken) {
-      setLoadedIds([...loadedIds, groupId ? groupId : 'root']);
-    } else {
-      setNextTokenMap({
-        ...nextTokenMap,
-        [`${groupId ? groupId : 'root'}`]: res.nextPageToken,
-      });
-    }
-  };
-
-  useEffect(() => {
-    getItems(null);
-  }, []);
-
-  const handleChangeItems = (selectedIds: ID[]) => {
-    const result = selectedIds.map((id) => {
-      const selectedItem = (selectedItems ?? []).find((it) => it.id === id);
-      if (selectedItem) {
-        return selectedItem;
-      }
-
-      const item = items.find((it) => it.id === id) as McsItem<ExtraType>;
-      return item;
-    });
-
-    onChangeItems ? onChangeItems(result) : setSelectedIds(selectedIds);
-  };
-
-  const handleExpand = (id: McsID) => getItems(id, nextTokenMap[id]);
-
-  const handleScroll = (id: McsID | null) => getItems(id, nextTokenMap[id ?? 
'root']);
-
-  const renderTitle = (column: McsColumn) => {
-    return !column.parentId && title && <S.ColumnTitle>{title}</S.ColumnTitle>;
-  };
-
-  const renderLoading = () => {
-    return <Loading size={20} style={{ padding: '4px 12px' }} />;
-  };
-
-  return (
-    <MillerColumnsSelect
-      items={items}
-      getCanExpand={(it) => it.type === 'group'}
-      getHasMore={(id) => !loadedIds.includes(id ?? 'root')}
-      onExpand={handleExpand}
-      onScroll={handleScroll}
-      columnCount={2.5}
-      columnHeight={300}
-      renderTitle={renderTitle}
-      renderLoading={renderLoading}
-      disabledIds={disabledIds}
-      selectedIds={selectedIds}
-      onSelectItemIds={handleChangeItems}
-      {...props}
-    />
-  );
-};
diff --git 
a/config-ui/src/plugins/components/data-scope-miller-columns/styled.ts 
b/config-ui/src/plugins/components/data-scope-miller-columns/styled.ts
deleted file mode 100644
index 6730edaff..000000000
--- a/config-ui/src/plugins/components/data-scope-miller-columns/styled.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 styled from 'styled-components';
-
-export const ColumnTitle = styled.div`
-  padding: 6px 12px;
-  font-weight: 600;
-`;
diff --git 
a/config-ui/src/plugins/components/data-scope-miller-columns/types.ts 
b/config-ui/src/plugins/components/data-scope-miller-columns/types.ts
deleted file mode 100644
index e8b87419d..000000000
--- a/config-ui/src/plugins/components/data-scope-miller-columns/types.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.
- *
- */
-
-export type ExtraType = {
-  type: 'group' | 'scope';
-  data: any;
-};
diff --git a/config-ui/src/plugins/components/index.ts 
b/config-ui/src/plugins/components/index.ts
index 194f390e3..03f86c5a9 100644
--- a/config-ui/src/plugins/components/index.ts
+++ b/config-ui/src/plugins/components/index.ts
@@ -19,7 +19,6 @@
 export * from './connection-form';
 export * from './connection-list';
 export * from './connection-status';
-export * from './data-scope-miller-columns';
 export * from './data-scope-search';
 export * from './data-scope-select';
 export * from './data-scope-select-remote';

Reply via email to