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

🐛 Show disabled tooltip for export when no apps available for export #1691

Merged
merged 3 commits into from
Feb 22, 2024
Merged
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
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)
);
Loading