Skip to content
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

MGMT-18977: Solving problems with context menu in 'Add hosts' tab #2674

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions libs/ui-lib/lib/common/components/hosts/AITable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type TableMemoProps = {
variant?: TableProps['variant'];
// eslint-disable-next-line
actionResolver?: ActionsResolver<any>;
skipScroll?: boolean;
};
const TableMemo: React.FC<WithTestID & TableMemoProps> = React.memo(
({
Expand All @@ -48,6 +49,7 @@ const TableMemo: React.FC<WithTestID & TableMemoProps> = React.memo(
testId,
variant,
actionResolver,
skipScroll,
}) => {
const tableActionResolver = React.useCallback(
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
Expand All @@ -58,28 +60,27 @@ const TableMemo: React.FC<WithTestID & TableMemoProps> = React.memo(
const newProps = {
canCollapseAll: false,
};
return (
<InnerScrollContainer>
<Table
rows={rows}
cells={cells}
onCollapse={onCollapse}
aria-label="Hosts table"
className={classnames(className, 'hosts-table')}
sortBy={sortBy}
onSort={onSort}
rowWrapper={rowWrapper}
data-testid={testId}
actionResolver={actionResolver ? tableActionResolver : undefined}
variant={variant}
actionsMenuAppendTo={() => document.body}
{...newProps}
>
<TableHeader />
<TableBody rowKey={rowKey} />
</Table>
</InnerScrollContainer>
const tableElement = (
<Table
rows={rows}
cells={cells}
onCollapse={onCollapse}
aria-label="Hosts table"
className={classnames(className, 'hosts-table')}
sortBy={sortBy}
onSort={onSort}
rowWrapper={rowWrapper}
data-testid={testId}
actionResolver={actionResolver ? tableActionResolver : undefined}
variant={variant}
actionsMenuAppendTo={() => document.body}
{...newProps}
>
<TableHeader />
<TableBody rowKey={rowKey} />
</Table>
);
return skipScroll ? tableElement : <InnerScrollContainer>{tableElement}</InnerScrollContainer>;
},
);
TableMemo.displayName = 'tableMemo';
Expand Down Expand Up @@ -155,6 +156,7 @@ export type AITableProps<R> = ReturnType<typeof usePagination> & {
actionResolver?: ActionsResolver<R>;
canSelectAll?: boolean;
variant?: TableProps['variant'];
skipScroll?: boolean;
};
// eslint-disable-next-line
const AITable = <R extends any>({
Expand All @@ -177,6 +179,7 @@ const AITable = <R extends any>({
perPageOptions,
canSelectAll,
variant,
skipScroll,
}: WithTestID & AITableProps<R>) => {
const itemIDs = React.useMemo(() => data.map(getDataId), [data, getDataId]);
React.useEffect(() => {
Expand Down Expand Up @@ -331,6 +334,7 @@ const AITable = <R extends any>({
data-testid={testId}
actionResolver={actionResolver}
variant={variant}
skipScroll={skipScroll}
/>
</SelectionProvider.Provider>
{showPagination && (
Expand Down
1 change: 1 addition & 0 deletions libs/ui-lib/lib/common/components/hosts/HostsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type HostsTableProps = ReturnType<typeof usePagination> &
hosts: Host[];
skipDisabled?: boolean;
children: React.ReactNode;
skipScroll?: boolean;
};

const HostsTable = ({ hosts, skipDisabled, ...rest }: HostsTableProps & WithTestID) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const InventoryAddHosts = ({ cluster }: { cluster?: Cluster }) => {
</StackItem>
)}
<StackItem>
<ClusterHostsTable cluster={cluster} />
<ClusterHostsTable cluster={cluster} skipScroll />
</StackItem>
</Stack>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ export function ExpandComponent({ obj: host }: ExpandComponentProps<Host>) {
export interface ClusterHostsTableProps {
cluster: Cluster;
skipDisabled?: boolean;
skipScroll?: boolean;
}

const ClusterHostsTable = ({ cluster, skipDisabled }: ClusterHostsTableProps) => {
const ClusterHostsTable = ({ cluster, skipDisabled, skipScroll }: ClusterHostsTableProps) => {
const { wizardPerPage, setWizardPerPage } = React.useContext(ClusterWizardContext) || {};
const {
onEditHost,
Expand Down Expand Up @@ -99,6 +100,7 @@ const ClusterHostsTable = ({ cluster, skipDisabled }: ClusterHostsTableProps) =>
content={content}
actionResolver={actionResolver}
variant={TableVariant.compact}
skipScroll={skipScroll}
{...paginationProps}
>
<HostsTableEmptyState isSingleNode={isSNO(cluster)} />
Expand Down
Loading