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

🐛 Accurately represent upload state in binary upload step #1487

Merged
merged 1 commit into from
Oct 25, 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 @@ -340,10 +340,9 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
<WizardStep
id={StepId.AnalysisMode}
name={t("wizard.terms.analysisMode")}
isDisabled={!isStepEnabled(StepId.AnalysisMode)}
footer={{
isNextDisabled:
!isMutating && !isStepEnabled(StepId.AnalysisMode + 1),
!!isMutating || !isStepEnabled(StepId.AnalysisMode + 1),
}}
>
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
title: "Uploaded binary file.",
variant: "success",
});
setFileUploadStatus("success");
setFileUploadProgress(100);

Check warning on line 50 in client/src/app/pages/applications/analysis-wizard/components/upload-binary.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/pages/applications/analysis-wizard/components/upload-binary.tsx#L49-L50

Added lines #L49 - L50 were not covered by tests
};

const failedUpload = (error: AxiosError) => {
Expand Down Expand Up @@ -82,10 +84,8 @@
failedUpload
);

const { mutate: removeFile } = useRemoveUploadedFileMutation(
completedRemove,
failedRemove
);
const { mutate: removeFile, isLoading: isRemovingFile } =
useRemoveUploadedFileMutation(completedRemove, failedRemove);

Check warning on line 88 in client/src/app/pages/applications/analysis-wizard/components/upload-binary.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/pages/applications/analysis-wizard/components/upload-binary.tsx#L88

Added line #L88 was not covered by tests
const onCreateTaskgroupSuccess = (data: Taskgroup) => {
updateTaskGroup(data);
};
Expand Down Expand Up @@ -133,9 +133,8 @@
readFile(droppedFiles[0])
.then((data) => {
if (data) {
setFileUploadProgress(100);
setFileUploadStatus("success");
setValue("artifact", droppedFiles[0]);
setFileUploadProgress(0);

Check warning on line 137 in client/src/app/pages/applications/analysis-wizard/components/upload-binary.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/pages/applications/analysis-wizard/components/upload-binary.tsx#L137

Added line #L137 was not covered by tests
}
})
.catch((error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import {
useFetchApplications,
} from "@app/queries/applications";
import { useCancelTaskMutation, useFetchTasks } from "@app/queries/tasks";
import { useFetchReviews } from "@app/queries/reviews";
import { useFetchIdentities } from "@app/queries/identities";
import { useFetchTagCategories } from "@app/queries/tags";

Expand Down Expand Up @@ -116,7 +115,7 @@ export const ApplicationsTableAnalyze: React.FC = () => {
const getTask = (application: Application) =>
tasks.find((task: Task) => task.application?.id === application.id);

const { tasks } = useFetchTasks({ addon: "analyzer" });
const { tasks } = useFetchTasks({ addon: "analyzer" }, isAnalyzeModalOpen);

const { tagCategories: tagCategories } = useFetchTagCategories();

Expand All @@ -127,7 +126,7 @@ export const ApplicationsTableAnalyze: React.FC = () => {
isFetching: isFetchingApplications,
error: applicationsFetchError,
refetch: fetchApplications,
} = useFetchApplications();
} = useFetchApplications(isAnalyzeModalOpen);

const onDeleteApplicationSuccess = (appIDCount: number) => {
pushNotification({
Expand Down Expand Up @@ -350,8 +349,6 @@ export const ApplicationsTableAnalyze: React.FC = () => {
selectionState: { selectedItems: selectedRows },
} = tableControls;

const { reviews } = useFetchReviews();

const [
saveApplicationsCredentialsModalState,
setSaveApplicationsCredentialsModalState,
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/queries/applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ interface DownloadOptions {
mimeType: MimeType;
}

export const useFetchApplications = () => {
export const useFetchApplications = (refetchDisabled: boolean = false) => {
const queryClient = useQueryClient();
const { isLoading, error, refetch, data } = useQuery({
initialData: [],
queryKey: [ApplicationsQueryKey],
queryFn: getApplications,
refetchInterval: 5000,
refetchInterval: !refetchDisabled ? 5000 : false,
onSuccess: () => {
queryClient.invalidateQueries([reviewsQueryKey]);
queryClient.invalidateQueries([assessmentsQueryKey]);
Expand Down
7 changes: 5 additions & 2 deletions client/src/app/queries/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

export const TasksQueryKey = "tasks";

export const useFetchTasks = (filters: FetchTasksFilters = {}) => {
export const useFetchTasks = (
filters: FetchTasksFilters = {},
refetchDisabled: boolean = false
) => {

Check warning on line 14 in client/src/app/queries/tasks.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/tasks.ts#L14

Added line #L14 was not covered by tests
const { isLoading, error, refetch, data } = useQuery({
queryKey: [TasksQueryKey],
queryFn: getTasks,
refetchInterval: 5000,
refetchInterval: !refetchDisabled ? 5000 : false,
select: (allTasks) => {
const uniqSorted = allTasks
.filter((task) =>
Expand Down
Loading