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

✨ add ActionsColumn to Migration waves table #2109

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 3 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
168 changes: 74 additions & 94 deletions client/src/app/pages/migration-waves/migration-waves.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import {
ToolbarContent,
ToolbarGroup,
ToolbarItem,
Tooltip,
} from "@patternfly/react-core";
import {
ActionsColumn,
ExpandableRowContent,
Table,
Tbody,
Expand Down Expand Up @@ -62,14 +64,14 @@ import { WaveStatusTable } from "./components/wave-status-table";
import { WaveForm } from "./components/migration-wave-form";
import { ManageApplicationsForm } from "./components/manage-applications-form";
import { deleteMigrationWave } from "@app/api/rest";
import { ConditionalTooltip } from "@app/components/ConditionalTooltip";
import { ConditionalRender } from "@app/components/ConditionalRender";
import { AppPlaceholder } from "@app/components/AppPlaceholder";
import { ToolbarBulkSelector } from "@app/components/ToolbarBulkSelector";
import { ConfirmDialog } from "@app/components/ConfirmDialog";
import { toRefs } from "@app/utils/model-utils";
import { useFetchTickets } from "@app/queries/tickets";
import { isInClosedRange } from "@app/components/FilterToolbar/dateUtils";
import { PencilAltIcon } from "@patternfly/react-icons";

export const MigrationWaves: React.FC = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -388,7 +390,7 @@ export const MigrationWaves: React.FC = () => {
}
numRenderedColumns={numRenderedColumns}
>
{currentPageItems?.map((migrationWave, rowIndex) => (
{currentPageItems?.map((migrationWave, rowIndex) => {
mguetta1 marked this conversation as resolved.
Show resolved Hide resolved
<Tbody
key={migrationWave.id}
isExpanded={isCellExpanded(migrationWave)}
Expand Down Expand Up @@ -455,102 +457,80 @@ export const MigrationWaves: React.FC = () => {
? migrationWave.status
: "--"}
</Td>
<Td isActionCell id="row-actions">
<Dropdown
isOpen={isRowDropdownOpen === migrationWave.id}
onSelect={() => setIsRowDropdownOpen(null)}
onOpenChange={(_isOpen) =>
setIsRowDropdownOpen(null)
}
popperProps={{ position: "right" }}
toggle={(
toggleRef: React.Ref<MenuToggleElement>
) => (
<MenuToggle
ref={toggleRef}
aria-label="row actions dropdown toggle"
variant="plain"
onClick={() => {
isRowDropdownOpen
? setIsRowDropdownOpen(null)
: setIsRowDropdownOpen(migrationWave.id);
}}
isExpanded={isRowDropdownOpen === rowIndex}
>
<EllipsisVIcon />
</MenuToggle>
)}
shouldFocusToggleOnSelect
>
<DropdownItem
key="edit"
component="button"
<Td isActionCell id="pencil-action">
<Tooltip content={t("actions.edit")}>
<Button
variant="plain"
icon={<PencilAltIcon />}
onClick={() => setWaveModalState(migrationWave)}
>
{t("actions.edit")}
</DropdownItem>
<ConditionalTooltip
key="manage-app"
isTooltipEnabled={applications.length === 0}
content={
"No applications are available for assignment."
}
>
<DropdownItem
key="manage-app"
isAriaDisabled={applications.length === 0}
onClick={() => {
setWaveToManageModalState(migrationWave);
}}
>
{t("composed.manage", {
/>
</Tooltip>
</Td>
<Td isActionCell id="row-actions">
<ActionsColumn
open={isRowDropdownOpen === migrationWave.id}
mguetta1 marked this conversation as resolved.
Show resolved Hide resolved
items={[
{
isAriaDisabled:
migrationWave.applications?.length < 1,
tooltipProps: {
content:
migrationWave.applications?.length < 1
? "No applications are available for assignment."
: "",
},
title: t("composed.manage", {
what: t("terms.applications").toLowerCase(),
})}
</DropdownItem>
</ConditionalTooltip>
<ConditionalTooltip
key="export-to-issue-manager"
isTooltipEnabled={
migrationWave.applications?.length < 1 ||
!hasExportableApplications(
tickets,
migrationWave?.applications
)
}
content={
"No applications are available for export."
}
>
<DropdownItem
key="export-to-issue-manager"
isAriaDisabled={
}),
onClick: () => {
{
setWaveToManageModalState(migrationWave);
}
},
},
{
isAriaDisabled:
migrationWave.applications?.length < 1 ||
!hasExportableApplications(
tickets,
migrationWave?.applications
)
}
onClick={() =>
setApplicationsToExport(
migrationWave.fullApplications
)
}
>
{t("terms.exportToIssue")}
</DropdownItem>
</ConditionalTooltip>
<DropdownItem
key="delete"
onClick={() =>
setMigrationWaveToDelete({
id: migrationWave.id,
name: migrationWave.name,
})
}
>
{t("actions.delete")}
</DropdownItem>
</Dropdown>
),
tooltipProps: {
content:
migrationWave.applications?.length < 1 ||
!hasExportableApplications(
sarinailinger marked this conversation as resolved.
Show resolved Hide resolved
tickets,
migrationWave?.applications
)
? "No applications are available for export."
: "",
},
title: t("terms.exportToIssue"),
onClick: () => {
if (
hasExportableApplications(
tickets,
migrationWave?.applications
)
) {
setApplicationsToExport(
migrationWave.fullApplications
);
}
},
},
{
title: t("actions.delete"),
onClick: () => {
setMigrationWaveToDelete({
id: migrationWave.id,
name: migrationWave.name,
});
},
isDanger: true,
},
]}
/>
</Td>
</TableRowContentWithControls>
</Tr>
Expand Down Expand Up @@ -586,8 +566,8 @@ export const MigrationWaves: React.FC = () => {
</Td>
</Tr>
) : null}
</Tbody>
))}
</Tbody>;
})}
</ConditionalTableBody>
</Table>
<SimplePagination
Expand Down
Loading