This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch fix-6084 in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit a5a49d31f93bebf0330b937ee16eefa1ae50b0d6 Author: mintsweet <[email protected]> AuthorDate: Thu Sep 14 18:49:19 2023 +1200 refactor(config-ui): remove data scope search --- .../plugins/components/data-scope-search/api.ts | 31 ---------- .../plugins/components/data-scope-search/index.tsx | 70 ---------------------- .../plugins/components/data-scope-search/types.ts | 24 -------- config-ui/src/plugins/components/index.ts | 1 - 4 files changed, 126 deletions(-) diff --git a/config-ui/src/plugins/components/data-scope-search/api.ts b/config-ui/src/plugins/components/data-scope-search/api.ts deleted file mode 100644 index e1e7e74a4..000000000 --- a/config-ui/src/plugins/components/data-scope-search/api.ts +++ /dev/null @@ -1,31 +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 = { - search?: string; - page?: number; - pageSize?: number; -}; - -export const searchScope = (plugin: string, connectionId: ID, params: Params) => - request(`/plugins/${plugin}/connections/${connectionId}/search-remote-scopes`, { - method: 'get', - data: params, - }); diff --git a/config-ui/src/plugins/components/data-scope-search/index.tsx b/config-ui/src/plugins/components/data-scope-search/index.tsx deleted file mode 100644 index 5ab73d613..000000000 --- a/config-ui/src/plugins/components/data-scope-search/index.tsx +++ /dev/null @@ -1,70 +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 } from 'react'; -import { useDebounce } from 'ahooks'; - -import { MultiSelector } from '@/components'; -import { useRefreshData } from '@/hooks'; - -import type { ItemType } from './types'; -import * as API from './api'; - -interface Props { - plugin: string; - connectionId: ID; - disabledItems?: any[]; - selectedItems?: any[]; - onChangeItems?: (selectedItems: any[]) => void; -} - -export const DataScopeSearch = ({ plugin, connectionId, disabledItems, selectedItems, onChangeItems }: Props) => { - const [query, setQuery] = useState(''); - - const search = useDebounce(query, { wait: 500 }); - - const { ready, data } = useRefreshData<{ children: ItemType[] }>(async () => { - if (!search) return { children: [] }; - return API.searchScope(plugin, connectionId, { - search, - page: 1, - pageSize: 50, - }); - }, [search]); - - const getKey = (it: ItemType) => it.id; - - const getName = (it: ItemType) => it.fullName; - - const handleChangeItems = (selectedItems: ItemType[]) => onChangeItems?.(selectedItems); - - return ( - <MultiSelector - placeholder="Search Repositories..." - items={data?.children ?? []} - getKey={getKey} - getName={getName} - disabledItems={disabledItems} - selectedItems={selectedItems} - onChangeItems={handleChangeItems} - loading={!ready} - noResult="No Repositories Available." - onQueryChange={(query) => setQuery(query)} - /> - ); -}; diff --git a/config-ui/src/plugins/components/data-scope-search/types.ts b/config-ui/src/plugins/components/data-scope-search/types.ts deleted file mode 100644 index c3f6318a3..000000000 --- a/config-ui/src/plugins/components/data-scope-search/types.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. - * - */ - -export type ItemType = { - id: ID; - name: string; - fullName: string; - data: any; -}; diff --git a/config-ui/src/plugins/components/index.ts b/config-ui/src/plugins/components/index.ts index 194f390e3..ce54614f8 100644 --- a/config-ui/src/plugins/components/index.ts +++ b/config-ui/src/plugins/components/index.ts @@ -20,7 +20,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'; export * from './scope-config-form';
