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 1 commit into
base: main
Choose a base branch
from
Open
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
149 changes: 80 additions & 69 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 @@ -455,6 +457,15 @@ export const MigrationWaves: React.FC = () => {
? migrationWave.status
: "--"}
</Td>
<Td isActionCell id="pencil-action">
<Tooltip content={t("actions.edit")}>
<Button
variant="plain"
icon={<PencilAltIcon />}
onClick={() => setWaveModalState(migrationWave)}
/>
</Tooltip>
</Td>
<Td isActionCell id="row-actions">
<Dropdown
isOpen={isRowDropdownOpen === migrationWave.id}
Expand Down Expand Up @@ -482,74 +493,74 @@ export const MigrationWaves: React.FC = () => {
)}
shouldFocusToggleOnSelect
>
<DropdownItem
key="edit"
component="button"
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", {
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={
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>
<ActionsColumn
items={[
// {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented code.

// title: t("actions.edit"),
// onClick: () => setWaveModalState(migrationWave),
// },
{
isAriaDisabled:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! I haven't used it yet but isAriaDisabled does bring some advantages over isDisabled

migrationWave.applications.length === 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You use several ways of checking that the applications list is empty - they all OK but for the sake of consistency I would pick one option. My preference would be the one that is already used in the legacy code but feel free to chose.

tooltipProps: {
content:
migrationWave.applications.length === 0
? "No applications are available for assignment."
: "",
},
title: t("composed.manage", {
what: t("terms.applications").toLowerCase(),
}),
onClick: () => {
if (migrationWave.applications.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this check ? I would expect that isAriaDisabled === true should block clicks.

setWaveToManageModalState(migrationWave);
}
},
},
{
isAriaDisabled:
migrationWave.applications?.length < 1 ||
!hasExportableApplications(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to check for both conditions? I haven't tested this flow but looking at the code: when there is no apps then there should also be no exportable apps so the second condition alone would do the job.

tickets,
migrationWave?.applications
),
tooltipProps: {
content:
migrationWave.applications?.length < 1 ||
!hasExportableApplications(
tickets,
migrationWave?.applications
)
? "No applications are available for export."
: "",
},
title: t("terms.exportToIssue"),
onClick: () => {
if (
migrationWave.applications?.length > 0 &&
hasExportableApplications(
tickets,
migrationWave?.applications
)
) {
setApplicationsToExport(
migrationWave.fullApplications
);
}
},
},
{
title: t("actions.delete"),
onClick: () => {
setMigrationWaveToDelete({
id: migrationWave.id,
name: migrationWave.name,
});
},
isDanger: true,
},
]}
/>
</Dropdown>
</Td>
</TableRowContentWithControls>
Expand Down
Loading