forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 17
feat(ingestion): add Executors tab with create/delete executor pools #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bmiller-dh
wants to merge
3
commits into
master
Choose a base branch
from
feat/ingestion-executor-pools-tab
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
675d7bc
feat(ingestion): add Executors tab with create/delete executor pools
bmiller-dh b714dac
fix(ingestion): resolver null checks, javadoc, and store delete style
bmiller-dh ad4f0e0
refactor(ingestion): scope PR to UI + E2E only, drop executor backend
bmiller-dh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
datahub-web-react/src/app/ingestV2/executor/CreateExecutorPoolModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { Form, Input } from 'antd'; | ||
| import React, { useState } from 'react'; | ||
|
|
||
| import { Modal } from '@src/alchemy-components'; | ||
|
|
||
| const ID_FIELD = 'id'; | ||
| const NAME_FIELD = 'name'; | ||
|
|
||
| export type CreateExecutorPoolInput = { | ||
| id: string; | ||
| name?: string; | ||
| }; | ||
|
|
||
| type Props = { | ||
| open: boolean; | ||
| onSubmit: (input: CreateExecutorPoolInput) => Promise<void>; | ||
| onCancel: () => void; | ||
| }; | ||
|
|
||
| export const CreateExecutorPoolModal = ({ open, onSubmit, onCancel }: Props) => { | ||
| const [submitting, setSubmitting] = useState(false); | ||
| const [form] = Form.useForm(); | ||
|
|
||
| const handleSubmit = async () => { | ||
| try { | ||
| const values = await form.validateFields(); | ||
| setSubmitting(true); | ||
| await onSubmit({ | ||
| id: values[ID_FIELD]?.trim() ?? '', | ||
| name: values[NAME_FIELD]?.trim() || undefined, | ||
| }); | ||
| form.resetFields(); | ||
| onCancel(); | ||
| } catch (e) { | ||
| if (e && typeof e === 'object' && 'errorFields' in e) return; | ||
| throw e; | ||
| } finally { | ||
| setSubmitting(false); | ||
| } | ||
| }; | ||
|
|
||
| const handleClose = () => { | ||
| if (!submitting) { | ||
| form.resetFields(); | ||
| onCancel(); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal | ||
| width={480} | ||
| title="Create executor pool" | ||
| open={open} | ||
| onCancel={handleClose} | ||
| buttons={[ | ||
| { text: 'Cancel', variant: 'text', onClick: handleClose }, | ||
| { | ||
| text: submitting ? 'Creating…' : 'Create', | ||
| variant: 'filled', | ||
| disabled: submitting, | ||
| buttonDataTestId: 'create-executor-pool-button', | ||
| onClick: handleSubmit, | ||
| }, | ||
| ]} | ||
| > | ||
| <Form form={form} layout="vertical" preserve={false}> | ||
| <Form.Item | ||
| name={ID_FIELD} | ||
| label="Pool ID" | ||
| rules={[ | ||
| { required: true, message: 'Pool ID is required' }, | ||
| { whitespace: true, message: 'Pool ID cannot be blank' }, | ||
| ]} | ||
| > | ||
| <Input placeholder="e.g. my-pool" data-testid="create-pool-id-input" /> | ||
| </Form.Item> | ||
| <Form.Item name={NAME_FIELD} label="Name (optional)"> | ||
| <Input placeholder="Display name" data-testid="create-pool-name-input" /> | ||
| </Form.Item> | ||
| </Form> | ||
| </Modal> | ||
| ); | ||
| }; |
271 changes: 271 additions & 0 deletions
271
datahub-web-react/src/app/ingestV2/executor/ExecutorPoolsList.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,271 @@ | ||
| import { Button, Pagination, Table, colors } from '@components'; | ||
| import { Alert, Typography, message } from 'antd'; | ||
| import React, { useCallback, useMemo, useState } from 'react'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| import TabToolbar from '@app/entity/shared/components/styled/TabToolbar'; | ||
| import EmptySources from '@app/ingestV2/EmptySources'; | ||
| import { DEFAULT_PAGE_SIZE } from '@app/ingestV2/constants'; | ||
| import { CreateExecutorPoolInput, CreateExecutorPoolModal } from '@app/ingestV2/executor/CreateExecutorPoolModal'; | ||
| import { scrollToTop } from '@app/shared/searchUtils'; | ||
| import { ConfirmationModal } from '@app/sharedV2/modals/ConfirmationModal'; | ||
|
|
||
| const PoolsContainer = styled.div` | ||
| display: flex; | ||
| flex-direction: column; | ||
| height: 100%; | ||
| overflow: auto; | ||
| `; | ||
|
|
||
| const StyledTabToolbar = styled(TabToolbar)` | ||
| padding: 0 20px 16px 0; | ||
| height: auto; | ||
| box-shadow: none; | ||
| border-bottom: none; | ||
| `; | ||
|
|
||
| const ToolbarActions = styled.div` | ||
| display: flex; | ||
| align-items: center; | ||
| gap: 8px; | ||
| `; | ||
|
|
||
| const TableContainer = styled.div` | ||
| flex: 1; | ||
| overflow: auto; | ||
| `; | ||
|
|
||
| const TextContainer = styled(Typography.Text)` | ||
| color: ${colors.gray[1700]}; | ||
| `; | ||
|
|
||
| export type ExecutorPool = { | ||
| id: string; | ||
| name?: string; | ||
| }; | ||
|
|
||
| type TableRow = { | ||
| id: string; | ||
| name: string; | ||
| }; | ||
|
|
||
| interface Props { | ||
| pools: ExecutorPool[]; | ||
| loading?: boolean; | ||
| error?: Error | null; | ||
| sourcesByExecutorId?: Record<string, string[]>; | ||
| onDeletePools: (poolIds: string[]) => Promise<void>; | ||
| onCreatePool?: (input: CreateExecutorPoolInput) => Promise<void>; | ||
| refetch?: () => void; | ||
| } | ||
|
|
||
| export const ExecutorPoolsList = ({ | ||
| pools, | ||
| loading = false, | ||
| error = null, | ||
| sourcesByExecutorId = {}, | ||
| onDeletePools, | ||
| onCreatePool, | ||
| refetch, | ||
| }: Props) => { | ||
| const [page, setPage] = useState(1); | ||
| const [selectedPoolIds, setSelectedPoolIds] = useState<string[]>([]); | ||
| const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); | ||
| const [isDeleting, setIsDeleting] = useState(false); | ||
| const [showCreateModal, setShowCreateModal] = useState(false); | ||
|
|
||
| const poolsInUse = useMemo( | ||
| () => selectedPoolIds.filter((id) => sourcesByExecutorId[id] && sourcesByExecutorId[id].length > 0), | ||
| [selectedPoolIds, sourcesByExecutorId], | ||
| ); | ||
| const deleteBlocked = poolsInUse.length > 0; | ||
| const deleteConfirmContent = useMemo(() => { | ||
| if (deleteBlocked) { | ||
| const lines = poolsInUse.map( | ||
| (id) => | ||
| `Pool "${id}" is used by: ${sourcesByExecutorId[id].join(', ')}. Remove or reassign sources before deleting.`, | ||
| ); | ||
| return lines.join('\n\n'); | ||
| } | ||
| return `Are you sure you want to delete ${selectedPoolIds.length} selected pool${selectedPoolIds.length === 1 ? '' : 's'}? Ingestion sources using these pools may no longer run as expected.`; | ||
| }, [deleteBlocked, poolsInUse, selectedPoolIds.length, sourcesByExecutorId]); | ||
|
|
||
| const pageSize = DEFAULT_PAGE_SIZE; | ||
| const start = (page - 1) * pageSize; | ||
| const totalPools = pools.length; | ||
| const paginatedPools = pools.slice(start, start + pageSize); | ||
|
|
||
| const tableData: TableRow[] = paginatedPools.map((pool) => ({ | ||
| id: pool.id, | ||
| name: pool.name ?? pool.id, | ||
| })); | ||
|
|
||
| const onChangePage = useCallback((newPage: number) => { | ||
| scrollToTop(); | ||
| setPage(newPage); | ||
| }, []); | ||
|
|
||
| const handleSelectionChange = useCallback((selectedKeys: string[]) => { | ||
| setSelectedPoolIds(selectedKeys); | ||
| }, []); | ||
|
|
||
| const handleDeleteClick = useCallback(() => { | ||
| if (selectedPoolIds.length === 0) return; | ||
| setShowDeleteConfirm(true); | ||
| }, [selectedPoolIds.length]); | ||
|
|
||
| const handleConfirmDelete = useCallback(async () => { | ||
| if (selectedPoolIds.length === 0 || deleteBlocked) { | ||
| if (deleteBlocked) setShowDeleteConfirm(false); | ||
| return; | ||
| } | ||
| setIsDeleting(true); | ||
| try { | ||
| await onDeletePools(selectedPoolIds); | ||
| message.success({ | ||
| content: `Deleted ${selectedPoolIds.length} pool${selectedPoolIds.length === 1 ? '' : 's'}.`, | ||
| duration: 2, | ||
| }); | ||
| setSelectedPoolIds([]); | ||
| setShowDeleteConfirm(false); | ||
| refetch?.(); | ||
| } catch (e) { | ||
| message.destroy(); | ||
| if (e instanceof Error) { | ||
| message.error({ content: `Failed to delete pool(s): ${e.message}`, duration: 3 }); | ||
| } | ||
| } finally { | ||
| setIsDeleting(false); | ||
| } | ||
| }, [deleteBlocked, onDeletePools, refetch, selectedPoolIds]); | ||
|
|
||
| const handleCloseDeleteConfirm = useCallback(() => { | ||
| if (!isDeleting) setShowDeleteConfirm(false); | ||
| }, [isDeleting]); | ||
|
|
||
| const columns = [ | ||
| { | ||
| title: 'Pool ID', | ||
| key: 'id', | ||
| render: (record: TableRow) => ( | ||
| <TextContainer | ||
| ellipsis={{ | ||
| tooltip: { | ||
| title: record.id, | ||
| color: 'white', | ||
| overlayInnerStyle: { color: colors.gray[1700] }, | ||
| showArrow: false, | ||
| }, | ||
| }} | ||
| > | ||
| {record.id} | ||
| </TextContainer> | ||
| ), | ||
| sorter: (a: TableRow, b: TableRow) => a.id.localeCompare(b.id), | ||
| }, | ||
| { | ||
| title: 'Name', | ||
| key: 'name', | ||
| render: (record: TableRow) => ( | ||
| <TextContainer | ||
| ellipsis={{ | ||
| tooltip: { | ||
| title: record.name, | ||
| color: 'white', | ||
| overlayInnerStyle: { color: colors.gray[1700] }, | ||
| showArrow: false, | ||
| }, | ||
| }} | ||
| > | ||
| {record.name} | ||
| </TextContainer> | ||
| ), | ||
| sorter: (a: TableRow, b: TableRow) => a.name.localeCompare(b.name), | ||
| }, | ||
| ]; | ||
|
|
||
| return ( | ||
| <> | ||
| <PoolsContainer> | ||
| <StyledTabToolbar> | ||
| <ToolbarActions> | ||
| {onCreatePool && ( | ||
| <Button | ||
| variant="filled" | ||
| onClick={() => setShowCreateModal(true)} | ||
| icon={{ icon: 'Plus', source: 'phosphor' }} | ||
| data-testid="create-pool-button" | ||
| > | ||
| Create pool | ||
| </Button> | ||
| )} | ||
| <Button | ||
| variant="filled" | ||
| color="red" | ||
| disabled={selectedPoolIds.length === 0} | ||
| onClick={handleDeleteClick} | ||
| icon={{ icon: 'Trash', source: 'phosphor' }} | ||
| data-testid="delete-pool-button" | ||
| > | ||
| Delete Pool{selectedPoolIds.length !== 1 ? 's' : ''} | ||
| </Button> | ||
| </ToolbarActions> | ||
| </StyledTabToolbar> | ||
| {error && ( | ||
| <Alert | ||
| type="error" | ||
| showIcon | ||
| style={{ marginBottom: 16 }} | ||
| message="Failed to load executor pools" | ||
| description={error.message} | ||
| /> | ||
| )} | ||
| {!loading && totalPools === 0 && !error ? ( | ||
| <EmptySources sourceType="executor pools" /> | ||
| ) : ( | ||
| <> | ||
| <TableContainer> | ||
| <Table<TableRow> | ||
| columns={columns} | ||
| data={tableData} | ||
| rowKey="id" | ||
| isScrollable | ||
| style={{ tableLayout: 'fixed' }} | ||
| isLoading={loading} | ||
| rowSelection={{ | ||
| selectedRowKeys: selectedPoolIds, | ||
| onChange: (selectedKeys) => handleSelectionChange(selectedKeys as string[]), | ||
| }} | ||
| /> | ||
| </TableContainer> | ||
| <Pagination | ||
| currentPage={page} | ||
| itemsPerPage={pageSize} | ||
| total={totalPools} | ||
| showLessItems | ||
| onPageChange={onChangePage} | ||
| showSizeChanger={false} | ||
| hideOnSinglePage | ||
| /> | ||
| </> | ||
| )} | ||
| </PoolsContainer> | ||
| <ConfirmationModal | ||
| isOpen={showDeleteConfirm} | ||
| modalTitle={deleteBlocked ? 'Cannot delete pool(s)' : 'Delete executor pool(s)'} | ||
| modalText={deleteConfirmContent} | ||
| handleConfirm={deleteBlocked ? handleCloseDeleteConfirm : handleConfirmDelete} | ||
| handleClose={handleCloseDeleteConfirm} | ||
| isDeleteModal={!deleteBlocked} | ||
| hideConfirmButton={deleteBlocked} | ||
| /> | ||
| {onCreatePool && ( | ||
| <CreateExecutorPoolModal | ||
| open={showCreateModal} | ||
| onSubmit={onCreatePool} | ||
| onCancel={() => setShowCreateModal(false)} | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Page state not reset after deletion causes empty view
Medium Severity
After successfully deleting pools,
selectedPoolIdsis cleared andrefetch()is called, but thepagestate is never reset. If a user is on page 2 and deletes all items on that page, after refetch the current page will be empty (pools.slice(25, 50)returns[]). BecausetotalPools > 0, the empty state component won't render, and withhideOnSinglePagethe pagination is hidden when only one page of data remains. The user sees an empty table with no visible way to navigate back to page 1.Additional Locations (2)
datahub-web-react/src/app/ingestV2/executor/ExecutorPoolsList.tsx#L70-L71datahub-web-react/src/app/ingestV2/executor/ExecutorPoolsList.tsx#L240-L249