Skip to content

Commit

Permalink
Merge branch 'konveyor:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wise-king-sullyman authored Oct 17, 2023
2 parents 384ee9e + 357a54c commit 1a0c80e
Show file tree
Hide file tree
Showing 43 changed files with 714 additions and 632 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
"@typescript-eslint",
"react",
"react-hooks",
"@tanstack/query",
],

// NOTE: Tweak the rules as needed when bulk fixes get merged
Expand All @@ -55,6 +56,9 @@ module.exports = {

// Allow the "cy-data" property for tackle-ui-test (but should really be "data-cy" w/o this rule)
"react/no-unknown-property": ["error", { ignore: ["cy-data"] }],

"@tanstack/query/exhaustive-deps": "error",
"@tanstack/query/prefer-query-object-syntax": "error",
},

settings: {
Expand Down
7 changes: 6 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,21 @@
"terms": {
"accepted": "Accepted",
"acceptedAppsAndDeps": "Accepted applications and dependencies",
"associatedApplications": "Associated applications",
"associatedArchetypes": "Associated archetypes",
"archetypesReviewed": "Archetypes reviewed",
"add": "Add",
"additionalNotesOrComments": "Additional notes or comments",
"adoptionCandidateDistribution": "Adoption candidate distribution",
"adoptionCandidateDistribution": "Assessment confidence and risk",
"affectedApplications": "Affected applications",
"analysis": "Analysis",
"answer": "Answer",
"application": "Application",
"applicationReview": "Application review",
"application(s)": "Application(s)",
"applicationImports": "Application imports",
"applicationName": "Application name",
"archetypeName": "Archetype name",
"applications": "Applications",
"archetype": "Archetype",
"archetypes": "Archetypes",
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum MimeType {
YAML = "yaml",
}

/** Mark an object as "New" therefore does not have an `id` field. */
export type New<T extends { id: number }> = Omit<T, "id">;

export interface HubFilter {
Expand Down Expand Up @@ -712,6 +713,7 @@ export interface Assessment
description: string;
status: AssessmentStatus;
risk: Risk;
confidence?: number;
stakeholders?: Ref[];
stakeholderGroups?: Ref[];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.confirm-deletion {
margin-top: var(--pf-v5-global--spacer--xl);
}

.confirm-deletion-input {
margin-top: var(--pf-v5-global--spacer--sm);
margin-bottom: var(--pf-v5-global--spacer--sm);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,21 @@ const ConfirmDeleteDialog: FC<ConfirmDeleteDialogProps> = ({
onClose();
};

const handleOnConfirmDelete = () => {
if (!isDisabled) {
setNameToDeleteInput("");
onConfirmDelete();
}
};

const confirmBtn = (
<Button
id="confirm-delete-dialog-button"
key="confirm"
aria-label="confirm"
variant={ButtonVariant.danger}
isDisabled={isDisabled}
onClick={isDisabled ? undefined : onConfirmDelete}
onClick={handleOnConfirmDelete}
>
{deleteBtnLabel ?? t("actions.delete")}
</Button>
Expand All @@ -70,6 +77,7 @@ const ConfirmDeleteDialog: FC<ConfirmDeleteDialogProps> = ({
{cancelBtnLabel ?? t("actions.cancel")}
</Button>
);

return (
<Modal
id="confirm-delete-dialog"
Expand All @@ -91,7 +99,7 @@ const ConfirmDeleteDialog: FC<ConfirmDeleteDialogProps> = ({
</Trans>
</Text>
<TextInput
className="confirm-deletion-input"
id="confirm-deletion-input"
value={nameToDeleteInput}
onChange={(_, value) => setNameToDeleteInput(value)}
/>
Expand Down
22 changes: 10 additions & 12 deletions client/src/app/layout/HeaderApp/HeaderApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,21 @@ export const HeaderApp: React.FC = () => {
<BarsIcon />
</PageToggleButton>
</MastheadToggle>
{APP_BRAND === BrandType.Konveyor ? (
<MastheadMain>
<MastheadBrand>
<MastheadMain>
<MastheadBrand>
{APP_BRAND === BrandType.Konveyor ? (
<Brand
src={konveyorBrandImage}
alt="brand"
heights={{ default: "60px" }}
/>
</MastheadBrand>
</MastheadMain>
) : (
<MastheadContent>
<Title className="logo-pointer" headingLevel="h1" size="2xl">
Migration Toolkit for Applications
</Title>
</MastheadContent>
)}
) : (
<Title className="logo-pointer" headingLevel="h1" size="2xl">
Migration Toolkit for Applications
</Title>
)}
</MastheadBrand>
</MastheadMain>
<MastheadContent>{toolbar}</MastheadContent>
</Masthead>
);
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/layout/SidebarApp/SidebarApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ export const SidebarApp: React.FC = () => {
{t("sidebar.archetypes")}
</NavLink>
</NavItem>
<NavItem>
{/* <NavItem>
<NavLink
to={Paths.reports + search}
activeClassName="pf-m-current"
>
{t("sidebar.reports")}
</NavLink>
</NavItem>
</NavItem> */}
<NavItem>
<NavLink to={Paths.controls} activeClassName="pf-m-current">
{t("sidebar.controls")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
name={t("wizard.terms.review")}
id={StepId.Review}
isDisabled={!isStepEnabled(StepId.Review)}
footer={{ nextButtonText: "Run" }}
>
<Review applications={applications} mode={mode} />
</WizardStep>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export const UploadBinary: React.FC = () => {
title: "Uploaded binary file.",
variant: "success",
});
setFileUploadStatus("success");
setFileUploadProgress(100);
};

const failedUpload = (error: AxiosError) => {
Expand All @@ -66,9 +64,6 @@ export const UploadBinary: React.FC = () => {
title: "Removed binary file.",
variant: "success",
});
setFileUploadStatus(undefined);
setFileUploadProgress(undefined);
setValue("artifact", null);
};

const failedRemove = (error: AxiosError) => {
Expand Down Expand Up @@ -135,7 +130,19 @@ export const UploadBinary: React.FC = () => {
file: droppedFiles[0],
});
}
setValue("artifact", droppedFiles[0]);
readFile(droppedFiles[0])
.then((data) => {
if (data) {
setFileUploadProgress(100);
setFileUploadStatus("success");
setValue("artifact", droppedFiles[0]);
}
})
.catch((error) => {
setValue("artifact", undefined);
setFileUploadProgress(0);
setFileUploadStatus("danger");
});
}
};

Expand Down Expand Up @@ -206,12 +213,14 @@ export const UploadBinary: React.FC = () => {
key={artifact.name}
customFileHandler={handleFile}
onClearClick={() => {
setFileUploadStatus(undefined);
setFileUploadProgress(undefined);
setValue("artifact", null);
taskGroup?.id &&
removeFile({
id: taskGroup?.id,
path: `binary/${artifact}`,
});
setValue("artifact", null);
}}
progressAriaLabel={"text"}
progressValue={fileUploadProgress}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ export const ApplicationsTable: React.FC = () => {
{...getTdProps({ columnKey: "assessment" })}
>
<ApplicationAssessmentStatus
assessments={application.assessments}
application={application}
/>
</Td>
<Td
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,45 @@
import React from "react";
import { AxiosError } from "axios";
import { useTranslation } from "react-i18next";
import { Spinner } from "@patternfly/react-core";

import { EmptyTextMessage } from "@app/components/EmptyTextMessage";
import { Assessment, Ref } from "@app/api/models";
import { IconedStatus, IconedStatusPreset } from "@app/components/IconedStatus";
import { useFetchAssessmentById } from "@app/queries/assessments";
import { Application } from "@app/api/models";
import { IconedStatus } from "@app/components/IconedStatus";
import { useFetchAssessmentsByItemId } from "@app/queries/assessments";

export interface ApplicationAssessmentStatusProps {
assessments?: Ref[];
application: Application;
isLoading?: boolean;
fetchError?: AxiosError;
}

const getStatusIconFrom = (assessment: Assessment): IconedStatusPreset => {
switch (assessment.status) {
case "empty":
return "NotStarted";
case "started":
return "InProgress";
case "complete":
return "Completed";
default:
return "NotStarted";
}
};

export const ApplicationAssessmentStatus: React.FC<
ApplicationAssessmentStatusProps
> = ({ assessments, isLoading = false, fetchError = null }) => {
> = ({ application, isLoading = false }) => {
const { t } = useTranslation();
//TODO: remove this once we have a proper assessment status
const { assessment } = useFetchAssessmentById(assessments?.[0]?.id);

const {
assessments,
isFetching: isFetchingAssessmentsById,
fetchError,
} = useFetchAssessmentsByItemId(false, application.id);

if (application?.assessed) {
return <IconedStatus preset="Completed" />;
}

if (fetchError) {
return <EmptyTextMessage message={t("terms.notAvailable")} />;
}
if (isLoading) {

if (isLoading || isFetchingAssessmentsById) {
return <Spinner size="md" />;
}

return assessment ? (
<IconedStatus preset={getStatusIconFrom(assessment)} />
) : (
<IconedStatus preset="NotStarted" />
);
if (
assessments?.some((a) => a.status === "started" || a.status === "complete")
) {
return <IconedStatus preset="InProgress" />;
}

return <IconedStatus preset="NotStarted" />;
};
Loading

0 comments on commit 1a0c80e

Please sign in to comment.