Skip to content

Commit

Permalink
🐛 Show disabled tooltip for export when no apps available for exp… (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 authored Feb 27, 2024
1 parent e930c3c commit 3ab62f6
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions client/src/app/pages/migration-waves/migration-waves.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
useFetchMigrationWaves,
useUpdateMigrationWaveMutation,
} from "@app/queries/migration-waves";
import { MigrationWave, Ref } from "@app/api/models";
import { MigrationWave, Ref, Ticket } from "@app/api/models";
import { FilterToolbar, FilterType } from "@app/components/FilterToolbar";
import { useLocalTableControls } from "@app/hooks/table-controls";
import { SimplePagination } from "@app/components/SimplePagination";
Expand All @@ -68,6 +68,7 @@ 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";

export const MigrationWaves: React.FC = () => {
const { t } = useTranslation();
Expand All @@ -76,6 +77,7 @@ export const MigrationWaves: React.FC = () => {
const currentTimezone = dayjs.tz.guess();

const { migrationWaves, isFetching, fetchError } = useFetchMigrationWaves();
const { tickets } = useFetchTickets();
const { trackers: trackers } = useFetchTrackers();
const { data: applications } = useFetchApplications();

Expand Down Expand Up @@ -495,16 +497,24 @@ export const MigrationWaves: React.FC = () => {
<ConditionalTooltip
key="export-to-issue-manager"
isTooltipEnabled={
migrationWave.applications?.length < 1
migrationWave.applications?.length < 1 ||
!hasExportableApplications(
tickets,
migrationWave?.applications
)
}
content={
"There are no applications assigned to this migration wave to export."
"No applications are available for export."
}
>
<DropdownItem
key="export-to-issue-manager"
isDisabled={
migrationWave.applications?.length < 1
isAriaDisabled={
migrationWave.applications?.length < 1 ||
!hasExportableApplications(
tickets,
migrationWave?.applications
)
}
onClick={() =>
setApplicationsToExport(
Expand Down Expand Up @@ -666,3 +676,11 @@ export const MigrationWaves: React.FC = () => {
</>
);
};

const hasExportableApplications = (tickets: Ticket[], applicationRefs: Ref[]) =>
applicationRefs.some(
(applicationRef) =>
!tickets
?.map((ticket) => ticket?.application?.id)
.includes(applicationRef.id)
);

0 comments on commit 3ab62f6

Please sign in to comment.