From 87ec130bf5ee40c1eeeb6eb3204018c23d02477e Mon Sep 17 00:00:00 2001 From: KubeSphere CI Bot <47586280+ks-ci-bot@users.noreply.github.com> Date: Mon, 23 Dec 2024 18:07:06 +0800 Subject: [PATCH] [master] chore: remove useless WorkspaceSelectorModal in packages/console (#4380) chore: remove useless WorkspaceSelectorModal in packages/console Signed-off-by: donniean Co-authored-by: donniean --- .../Modals/WorkspaceSelectorModal/index.tsx | 183 ------------------ .../Modals/WorkspaceSelectorModal/styles.ts | 75 ------- .../workspaces/components/Modals/index.ts | 1 - 3 files changed, 259 deletions(-) delete mode 100644 packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/index.tsx delete mode 100644 packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/styles.ts diff --git a/packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/index.tsx b/packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/index.tsx deleted file mode 100644 index f3efce5c400..00000000000 --- a/packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/index.tsx +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Please refer to the LICENSE file in the root directory of the project. - * https://github.com/kubesphere/console/blob/master/LICENSE - */ - -import React, { useState } from 'react'; -import { isEmpty } from 'lodash'; -import { FilterInput, Button, Tag, notify } from '@kubed/components'; -import { useDisclosure } from '@kubed/hooks'; -import { Refresh, Enterprise } from '@kubed/icons'; - -import type { FormattedWorkspace } from '@ks-console/shared'; -import { - formatTime, - getActions, - clusterStore, - workspaceStore, - InfiniteScroll, - ClusterWrapper, - WorkspaceFormValues, - FavoriteHistory, -} from '@ks-console/shared'; -import { CreateWorkspacesModal } from '../CreateWorkspaceModal'; -import { - Toolbar, - FilterInputWrapper, - ButtonsWrapper, - ListWrapper, - StyledEntity, - StyledField, - ListContainer, -} from './styles'; - -const { useClusterList } = clusterStore; -const { useFetchWorkspacesInfiniteQuery, usePostMutation } = workspaceStore; - -interface WorkspaceSelectorModalProps { - onSelect: (formattedWorkspace: FormattedWorkspace) => void; -} - -export default function WorkspaceSelectorModal({ onSelect }: WorkspaceSelectorModalProps) { - const enabledCreate = - getActions({ module: 'workspaces' }).includes('global-manager-workspaces') || - getActions({ module: 'workspaces' }).includes('global-create-workspaces'); - const createWorkspaceModal = useDisclosure(); - - const [filteredWorkspaceName, setFilteredWorkspaceName] = useState(''); - const params = filteredWorkspaceName - ? { - name: filteredWorkspaceName, - } - : undefined; - - const { formattedClusters } = useClusterList({ params: { limit: -1 } }); - const { - isLoading, - isRefetching, - isFetchingNextPage, - hasNextPage, - formattedWorkspaces, - fetchNextPage, - refetch, - } = useFetchWorkspacesInfiniteQuery({ params }); - - const handleChange = (value: string) => { - setFilteredWorkspaceName(value); - }; - - const refresh = () => { - refetch({ refetchPage: (page, index) => index === 0 }); - }; - - const createWorkspaceMutation = usePostMutation(undefined, { - onSuccess: () => { - refresh(); - notify.success(t('CREATE_SUCCESSFUL')); - createWorkspaceModal.close(); - }, - }); - - const handleCreate = (values: WorkspaceFormValues) => { - createWorkspaceMutation.mutate({ data: values }); - }; - - const workspaces = formattedWorkspaces.map(formattedWorkspace => { - const { name, description, clusters, createTime } = formattedWorkspace; - const fields = [ - { - className: 'field-main-title', - avatar: , - value: name, - label: description ?? '-', - }, - { - value: - name === 'system-workspace' ? ( - {t('ALL_CLUSTERS')} - ) : isEmpty(clusters) ? ( - '-' - ) : ( - - ), - }, - { - value: createTime ? formatTime(createTime) : '-', - label: t('CREATION_TIME_TCAP'), - }, - ]; - - return ( - onSelect(formattedWorkspace)}> - {fields.map((props, index) => ( - - ))} - - - ); - }); - - return ( - <> - - - { - if (filteredWorkspaceName !== value) { - handleChange(value); - } - }} - onClear={() => handleChange('')} - /> - - - - {enabledCreate && ( - - )} - - - - - - {workspaces} - - - - {createWorkspaceModal.isOpen && ( - - )} - - ); -} diff --git a/packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/styles.ts b/packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/styles.ts deleted file mode 100644 index d52cb97dab3..00000000000 --- a/packages/console/src/pages/workspaces/components/Modals/WorkspaceSelectorModal/styles.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Please refer to the LICENSE file in the root directory of the project. - * https://github.com/kubesphere/console/blob/master/LICENSE - */ - -import styled from 'styled-components'; -import { Entity, Field } from '@kubed/components'; - -export const Toolbar = styled.div` - display: flex; - padding: 6px 20px; - box-shadow: - 0 1px 0 0 ${({ theme }) => theme.palette.accents_2}, - 0 -1px 0 0 ${({ theme }) => theme.palette.accents_3}; - background-color: ${({ theme }) => theme.palette.accents_1}; -`; - -export const FilterInputWrapper = styled.div` - flex: 1; - padding: 0 12px; -`; - -export const ButtonsWrapper = styled.div` - display: flex; - align-items: center; - column-gap: 12px; - padding: 0 12px; -`; - -export const ListWrapper = styled.div` - padding: 12px; -`; - -export const ListContainer = styled.div` - height: 472px; - padding: 12px 0; - border-radius: 4px; - background-color: ${({ theme }) => theme.palette.accents_0}; - - .ks-InfiniteScroll-container { - padding: 0 12px; - - .ks-InfiniteScroll-content { - display: flex; - flex-direction: column; - row-gap: 8px; - } - } -`; - -export const StyledEntity = styled(Entity)` - cursor: pointer; - - .entity-main { - padding: 0 12px; - } - - .favorite-action { - visibility: hidden; - } - &:hover .favorite-action { - visibility: visible; - } -`; - -export const StyledField = styled(Field)` - flex: unset; - min-width: 160px; - - &.field-main-title { - flex: 1; - min-width: 200px; - width: auto; - } -`; diff --git a/packages/console/src/pages/workspaces/components/Modals/index.ts b/packages/console/src/pages/workspaces/components/Modals/index.ts index 0d9f235fcca..d3ae6391145 100644 --- a/packages/console/src/pages/workspaces/components/Modals/index.ts +++ b/packages/console/src/pages/workspaces/components/Modals/index.ts @@ -6,7 +6,6 @@ export { default as HelmUploadModal } from './HelmUploadModal'; export { default as RepoManagementModal } from './RepoManagementModal'; export { default as EditAppModal } from './EditAppModal'; -export { default as WorkspaceSelectorModal } from './WorkspaceSelectorModal'; export * from './CreateWorkspaceModal'; export * from './EditWorkspaceModal'; export * from './DeleteWorkspaceModal';