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

🐛 Fix aggregated wave status. Reflect all states in Jira instance #1124

Merged
merged 2 commits into from
Jul 13, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
type={isPasswordHidden ? "password" : "text"}
formGroupProps={{
labelIcon: !isPasswordEncrypted ? (
// TODO: add info icon for auth text explanation
<KeyDisplayToggle
keyName="password"
isKeyHidden={isPasswordHidden}
Expand All @@ -707,12 +708,13 @@ export const IdentityForm: React.FC<IdentityFormProps> = ({
<HookFormPFTextInput
control={control}
name="key"
label={"key"}
label={"Token"}
fieldId="key"
isRequired={true}
type={isKeyHidden ? "password" : "text"}
formGroupProps={{
labelIcon: !isKeyEncrypted ? (
// TODO: add info icon for auth text explanation
<KeyDisplayToggle
keyName="key"
isKeyHidden={isKeyHidden}
Expand Down
16 changes: 0 additions & 16 deletions client/src/app/pages/identities/identities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,6 @@ export const Identities: React.FC = () => {
return item.kind || "";
},
},
{
key: "createdBy",
title: "Created By",
type: FilterType.search,
placeholderText: "Filter by created by User...",
getItemValue: (item) => {
return item.createUser || "";
},
},
];

const { filterValues, setFilterValues, filteredItems } = useLegacyFilterState(
Expand All @@ -148,7 +139,6 @@ export const Identities: React.FC = () => {
identity?.name || "",
"", // description column
identity?.kind || "",
identity?.createUser || "",
"", // Action column
];
const { sortBy, onSort, sortedItems } = useLegacySortState(
Expand All @@ -167,7 +157,6 @@ export const Identities: React.FC = () => {
},
{ title: "Description", transforms: [cellWidth(25)] },
{ title: "Type", transforms: [sortable, cellWidth(20)] },
{ title: "Created by", transforms: [sortable, cellWidth(10)] },
{
title: "",
props: {
Expand Down Expand Up @@ -203,11 +192,6 @@ export const Identities: React.FC = () => {
</TableText>
),
},
{
title: (
<TableText wrapModifier="truncate">{item.createUser}</TableText>
),
},
{
title: (
<AppTableActionButtons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const WaveForm: React.FC<WaveFormProps> = ({
}) => {
const { t } = useTranslation();

const { migrationWaves } = useFetchMigrationWaves();
const { pushNotification } = React.useContext(NotificationsContext);

const { stakeholders } = useFetchStakeholders();
Expand Down
4 changes: 1 addition & 3 deletions client/src/app/pages/migration-waves/migration-waves.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ export const MigrationWaves: React.FC = () => {
const { t } = useTranslation();
const { pushNotification } = React.useContext(NotificationsContext);

const { migrationWaves, isFetching, fetchError, refetch } =
useFetchMigrationWaves();

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

Expand Down
14 changes: 11 additions & 3 deletions client/src/app/queries/migration-waves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
deleteAllMigrationWaves,
} from "@app/api/rest";
import { getWavesWithStatus } from "@app/utils/waves-selector";
import { TicketsQueryKey } from "./tickets";
import { useFetchTickets } from "./tickets";
import { TrackersQueryKey } from "./trackers";
import { useFetchApplications } from "./applications";
import { useFetchStakeholders } from "./stakeholders";

export const MigrationWavesQueryKey = "migration-waves";

Expand All @@ -29,14 +32,19 @@ export const useCreateMigrationWaveMutation = (
};

export const useFetchMigrationWaves = () => {
const { tickets } = useFetchTickets();
const { stakeholders } = useFetchStakeholders();
const { data: applications } = useFetchApplications();

const queryClient = useQueryClient();
const { isLoading, error, refetch, data } = useQuery({
queryKey: [MigrationWavesQueryKey],
queryFn: getMigrationWaves,
refetchInterval: 5000,
onError: (error) => console.log("error, ", error),
onSuccess: () => queryClient.invalidateQueries([TicketsQueryKey]),
select: (waves) => getWavesWithStatus(queryClient, waves),
onSuccess: () => queryClient.invalidateQueries([TrackersQueryKey]),
select: (waves) =>
getWavesWithStatus(waves, tickets, stakeholders, applications),
});
return {
migrationWaves: data || [],
Expand Down
44 changes: 21 additions & 23 deletions client/src/app/utils/waves-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,14 @@ import {
TicketStatus,
WaveWithStatus,
} from "@app/api/models";
import { ApplicationsQueryKey } from "@app/queries/applications";
import { StakeholdersQueryKey } from "@app/queries/stakeholders";
import { TicketsQueryKey } from "@app/queries/tickets";
import { QueryClient, useQueryClient } from "@tanstack/react-query";
import dayjs from "dayjs";

export const getWavesWithStatus = (
queryClient: QueryClient,
waves: MigrationWave[]
waves: MigrationWave[],
tickets: Ticket[],
stakeholders: StakeholderWithRole[],
applications: Application[]
) => {
const tickets = queryClient.getQueryData<Ticket[]>([TicketsQueryKey]) || [];

const stakeholders =
queryClient.getQueryData<StakeholderWithRole[]>([StakeholdersQueryKey]) ||
[];

const applications =
queryClient.getQueryData<Application[]>([ApplicationsQueryKey]) || [];

const aggregatedTicketStatus = (
wave: MigrationWave,
tickets: Ticket[]
Expand All @@ -45,6 +34,13 @@ export const getWavesWithStatus = (
}
} else if (statuses.includes("New")) {
return "Issues Created";
} else if (statuses.includes("In Progress")) {
return "In Progress";
} else if (
!!statuses.length &&
statuses.every((status) => status === "Done")
) {
return "Completed";
} else {
return "Not Started";
}
Expand All @@ -56,14 +52,16 @@ export const getWavesWithStatus = (
wave: MigrationWave,
tickets: Ticket[]
): TicketStatus[] =>
wave.applications.map((application): TicketStatus => {
const matchingTicket = getTicketByApplication(tickets, application.id);
if (matchingTicket?.error) {
return "Error";
} else if (matchingTicket?.status) {
return matchingTicket.status;
} else return "";
});
wave.applications
.map((application): TicketStatus => {
const matchingTicket = getTicketByApplication(tickets, application.id);
if (matchingTicket?.error) {
return "Error";
} else if (matchingTicket?.status) {
return matchingTicket.status;
} else return "";
})
.filter(Boolean);

const getApplicationsOwners = (id: number) => {
const applicationOwnerIds = applications
Expand Down