Skip to content
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
2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"git-url-parse": "^16.1.0",
"i18next": "^25.3.0",
"i18next-http-backend": "^3.0.2",
"immer": "^10.1.3",
"js-yaml": "^4.1.0",
"keycloak-js": "^26.1.0",
"monaco-editor": "^0.52.2",
Expand All @@ -54,6 +55,7 @@
"react-measure": "^2.5.2",
"react-router-dom": "^5.2.0",
"tinycolor2": "^1.6.0",
"use-immer": "^0.11.0",
"xmllint-wasm": "^5.0.0",
"yup": "^0.32.11"
},
Expand Down
12 changes: 9 additions & 3 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"discardAssessment": "Discard assessment(s)",
"discardReview": "Discard review",
"discoverApplications": "Discover applications",
"discoverImport": "Discover & Import",
"downloadCsvTemplate": "Download CSV template",
"download": "Download {{what}}",
"duplicate": "Duplicate",
Expand All @@ -45,11 +44,12 @@
"export": "Export",
"filterBy": "Filter by {{what}}",
"import": "Import",
"importFromCsv": "Import applications from CSV",
"logout": "Logout",
"manageAccount": "User management",
"manageCredentials": "Manage credentials",
"manageDependencies": "Manage dependencies",
"manageImports": "Manage imports",
"manageApplicationImports": "Manage application imports",
"manageTargetProfiles": "Manage target profiles",
"next": "Next",
"override": "Override",
Expand Down Expand Up @@ -749,12 +749,18 @@
},
"platformDiscoverWizard": {
"title": "Discover Applications",
"description": "Discover and import applications from the selected platform.",
"description": "Discover and import applications from a source platform.",
"noPlatformSelected": "No platform selected for discovery.",
"noPlatformSelectedDescription": "A source platform must be selected to continue.",
"toast": {
"submittedOk": "Platform application discovery task submitted",
"submittedFailed": "Platform application discovery task failed"
},
"platformSelect": {
"stepTitle": "Platform",
"title": "Select a platform",
"description": "Select a platform to access for application discovery and import."
},
"filterInput": {
"stepTitle": "Filters",
"title": "Configure Discovery Filters",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react";
import { useTranslation } from "react-i18next";
import {
Button,
Modal,
ModalVariant,
Wizard,
Expand All @@ -16,6 +15,8 @@ import { universalComparator } from "@app/utils/utils";
import { FilterInput } from "./filter-input";
import { Results } from "./results";
import { Review } from "./review";
import { SelectPlatform } from "./select-platform";
import { SourcePlatformRequired } from "./source-platform-required";
import { useStartPlatformApplicationImport } from "./useStartPlatformApplicationImport";
import { useWizardReducer } from "./useWizardReducer";

Expand Down Expand Up @@ -43,15 +44,18 @@ export interface IDiscoverImportWizard {
}

const DiscoverImportWizardInner: React.FC<IDiscoverImportWizard> = ({
platform,
platform: initialPlatform,
onClose,
isOpen,
}: IDiscoverImportWizard) => {
const { t } = useTranslation();
const { pushNotification } = React.useContext(NotificationsContext);
const { submitTask } = useStartPlatformApplicationImport();
const { state, setFilters, setResults, reset } = useWizardReducer();
const { results, filters } = state;
const { state, setPlatform, setFilters, setResults, reset } =
useWizardReducer((initial) => {
initial.platform = initialPlatform ?? null;
});
const { platform, results, filters, isReady } = state;

const handleCancel = () => {
reset();
Expand Down Expand Up @@ -89,26 +93,6 @@ const DiscoverImportWizardInner: React.FC<IDiscoverImportWizard> = ({
}
};

if (!platform) {
return (
<Modal
variant={ModalVariant.medium}
title={t("dialog.title.discoverApplications")}
isOpen={isOpen}
onClose={handleCancel}
footer={
<Button variant="primary" onClick={handleCancel}>
{t("actions.close")}
</Button>
}
>
<div style={{ padding: "20px" }}>
<p>{t("platformDiscoverWizard.noPlatformSelected")}</p>
</div>
</Modal>
);
}

return (
<Modal
variant={ModalVariant.large}
Expand All @@ -129,41 +113,72 @@ const DiscoverImportWizardInner: React.FC<IDiscoverImportWizard> = ({
}
isVisitRequired
>
{!initialPlatform ? (
<WizardStep
id="platform"
name={t("platformDiscoverWizard.platformSelect.stepTitle")}
footer={{
nextButtonText: t("actions.next"),
backButtonText: t("actions.back"),
isNextDisabled: platform === null,
}}
>
<SelectPlatform
platform={platform}
onPlatformSelected={setPlatform}
/>
</WizardStep>
) : null}

<WizardStep
id="filter-input"
name={t("platformDiscoverWizard.filterInput.stepTitle")}
isDisabled={!platform}
footer={{
nextButtonText: t("actions.next"),
backButtonText: t("actions.back"),
isNextDisabled: !filters.isValid,
}}
>
<FilterInput
platform={platform}
onFiltersChanged={setFilters}
initialFilters={filters}
/>
{!platform ? (
<SourcePlatformRequired
title={t("platformDiscoverWizard.filterInput.title")}
/>
) : (
<FilterInput
platform={platform}
onFiltersChanged={setFilters}
initialFilters={filters}
/>
)}
</WizardStep>

<WizardStep
id="review"
name={t("platformDiscoverWizard.review.stepTitle")}
isDisabled={!platform || !filters.isValid}
footer={{
nextButtonText: results
? t("actions.close")
: t("actions.discoverApplications"),
backButtonText: t("actions.back"),
isNextDisabled: !state.isReady && !results,
isNextDisabled: !isReady && !results,
isBackDisabled: !!results,
isCancelHidden: !!results,
onNext: results ? handleCancel : onSubmitTask,
}}
>
{!results ? (
{!platform ? (
<SourcePlatformRequired
title={t("platformDiscoverWizard.review.title")}
/>
) : null}

{platform && !results ? (
<Review platform={platform} filters={filters} />
) : (
<Results results={results} />
)}
) : null}

{platform && results ? <Results results={results} /> : null}
</WizardStep>
</Wizard>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,12 @@ export const FilterInputCloudFoundry: React.FC<
names: formValueToStrings(values.names),
spaces: formValueToStrings(values.spaces),
};
console.log("subscription document", asDocument);
onDocumentChanged(asDocument);
},
});
return () => subscription();
}, [subscribe, onDocumentChanged]);

// useFormUpdateHandler(form, onDocumentChanged);

// // Initialize from values prop
// useEffect(() => {
// reset({
// names: (values?.names as string[]) || [],
// spaces: (values?.spaces as string[]) || [],
// });
// }, [values, reset]);

return (
<Stack id={id}>
<StackItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import { JsonDocument, SourcePlatform, TargetedSchema } from "@app/api/models";
import { HookFormPFGroupController } from "@app/components/HookFormPFFields";
import { SchemaDefinedField } from "@app/components/schema-defined-fields";
import { jsonSchemaToYupSchema } from "@app/components/schema-defined-fields/utils";
import { usePlatformKindList } from "@app/hooks/usePlatformKindList";
import { useFetchPlatformDiscoveryFilterSchema } from "@app/queries/schemas";
import { wrapAsEvent } from "@app/utils/utils";

import { usePlatformKindList } from "../usePlatformKindList";

import { FilterInputCloudFoundry } from "./filter-input-cloudfoundry";

interface FiltersFormValues {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./discover-import-wizard";
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
import { SourcePlatform } from "@app/api/models";
import { EmptyTextMessage } from "@app/components/EmptyTextMessage";
import { SchemaDefinedField } from "@app/components/schema-defined-fields";

import { usePlatformKindList } from "../usePlatformKindList";
import { usePlatformKindList } from "@app/hooks/usePlatformKindList";

import { FilterState } from "./filter-input";
import { ReviewInputCloudFoundry } from "./review-input-cloudfoundry";
Expand All @@ -24,6 +23,7 @@ export const Review: React.FC<{
}> = ({ platform, filters }) => {
const { t } = useTranslation();
const { getDisplayLabel } = usePlatformKindList();

const showFilters =
filters.filterRequired && filters.schema && filters.document;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { Form, Text, TextContent } from "@patternfly/react-core";

import { DEFAULT_SELECT_MAX_HEIGHT } from "@app/Constants";
import { SourcePlatform } from "@app/api/models";
import { useFetchPlatforms } from "@app/queries/platforms";
import { toOptionLike } from "@app/utils/model-utils";

import { OptionWithValue, SimpleSelect } from "../SimpleSelect";

export interface SelectPlatformProps {
platform: SourcePlatform | null;
onPlatformSelected: (platform: SourcePlatform | null) => void;
}

export const SelectPlatform: React.FC<SelectPlatformProps> = ({
platform,
onPlatformSelected,
}) => {
const { t } = useTranslation();
const { platforms, isLoading } = useFetchPlatforms();
const platformOptions = React.useMemo(
() =>
platforms.map((platform) => ({
value: platform,
toString: () => platform.name,
})),
[platforms]
);

return (
<div>
<TextContent style={{ marginBottom: "var(--pf-v5-global--spacer--lg)" }}>
<Text component="h3">
{t("platformDiscoverWizard.platformSelect.title")}
</Text>
<Text component="p">
{t("platformDiscoverWizard.platformSelect.description")}
</Text>
</TextContent>

<Form id="platform-select-form">
<SimpleSelect
maxHeight={DEFAULT_SELECT_MAX_HEIGHT}
placeholderText={
isLoading
? t("message.loadingTripleDot")
: t("composed.selectOne", {
what: t("terms.platform").toLowerCase(),
})
}
loadingVariant={isLoading ? "spinner" : undefined}
variant="typeahead"
toggleId="platform-select-toggle"
id="platform-select"
toggleAriaLabel="Platform select dropdown toggle"
aria-label="platform-select"
value={platform ? toOptionLike(platform, platformOptions) : undefined}
options={platformOptions}
onChange={(selection) => {
const selectionValue = selection as OptionWithValue<SourcePlatform>;
onPlatformSelected(selectionValue.value);
}}
onClear={() => onPlatformSelected(null)}
/>
</Form>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from "react";
import { useTranslation } from "react-i18next";
import { Text, TextContent } from "@patternfly/react-core";

export const SourcePlatformRequired: React.FC<{
title: string;
}> = ({ title }) => {
const { t } = useTranslation();

return (
<div>
<TextContent style={{ marginBottom: "var(--pf-v5-global--spacer--lg)" }}>
<Text component="h3">{title}</Text>
<Text component="p">
{t("platformDiscoverWizard.noPlatformSelectedDescription")}
</Text>
</TextContent>
</div>
);
};
Loading
Loading