Dataset Viewer
Auto-converted to Parquet
element_type
stringclasses
4 values
project_name
stringclasses
2 values
uuid
stringlengths
36
36
name
stringlengths
3
66
imports
stringlengths
0
1.04k
file_location
stringlengths
64
148
code
stringlengths
28
14.1k
parent
stringclasses
18 values
file
kubev2v/migration-planner-ui
1f694b03-64c5-4c8e-977f-007ce0f155bf
eslint.config.js
https://github.com/kubev2v/migration-planner-ui/eslint.config.js
import globals from "globals"; import eslintJs from "@eslint/js"; import tsEslint from "typescript-eslint"; import pluginReact from "eslint-plugin-react"; import pluginReactHooks from 'eslint-plugin-react-hooks'; import pluginReactRefresh from 'eslint-plugin-react-refresh'; const config = tsEslint.config( eslintJs.configs.recommended, ...tsEslint.configs.recommended, { name: "General", languageOptions: { parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname, }, globals: { ...globals.node, }, }, rules: { "@typescript-eslint/no-unused-vars": [ "warn", { args: "all", argsIgnorePattern: "^_", destructuredArrayIgnorePattern: "^_", varsIgnorePattern: "^_", ignoreRestSiblings: true, }, ], "@typescript-eslint/explicit-function-return-type": "warn", } }, { name: "React (Web)", files: ["**/*.{tsx,jsx}"], languageOptions: { globals: { ...globals.browser, } }, settings: { react: { version: "detect" } }, plugins: { 'react': pluginReact, 'react-hooks': pluginReactHooks, 'react-refresh': pluginReactRefresh, }, rules: { ...pluginReact.configs.flat['jsx-runtime'].rules, ...pluginReactHooks.configs.recommended.rules, "react-refresh/only-export-components": "warn", }, }, { name: "Ignored", ignores: ["**/dist", "**/node_modules", "eslint.config.js"], } ); export default config;
null
file
kubev2v/migration-planner-ui
9ce256e2-0915-42fa-a4c3-9b241172cea8
vite.config.ts
[{'import_name': ['defineConfig'], 'import_path': 'vite'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/vite.config.ts
import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import tsconfigPaths from "vite-tsconfig-paths"; // https://vitejs.dev/config/ export default defineConfig((_env) => { return { plugins: [tsconfigPaths(), react()], server: { proxy: { "/agent/api/v1": { target: "http://172.17.0.3:3333", changeOrigin: true, rewrite: (path): string => path.replace(/^\/agent/, ""), }, }, }, }; });
null
file
kubev2v/migration-planner-ui
1c3486d9-9ac2-4ac2-a01d-0a450589b04f
vite-env.d.ts
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/@types/vite-env.d.ts
/// <reference types="vite/client" /> interface ImportMetaEnv { readonly VITE_AGENT_BASEPATH: string; // Add other env variables here } interface ImportMeta { readonly env: ImportMetaEnv; }
null
file
kubev2v/migration-planner-ui
de5ff8fd-3ee7-4f4b-bb62-bb1e7d50500f
AbortSignal.ts
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/common/AbortSignal.ts
export function newAbortSignal( delay?: number, abortMessage?: string ): AbortSignal { const abortController = new AbortController(); const signal = abortController.signal; if (delay) { window.setTimeout(() => { abortController.abort(abortMessage); }, delay); } return signal; }
null
function
kubev2v/migration-planner-ui
ddadabf7-a5da-4e71-86ec-d0e2fd583da8
newAbortSignal
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/common/AbortSignal.ts
function newAbortSignal( delay?: number, abortMessage?: string ): AbortSignal { const abortController = new AbortController(); const signal = abortController.signal; if (delay) { window.setTimeout(() => { abortController.abort(abortMessage); }, delay); } return signal; }
{}
file
kubev2v/migration-planner-ui
5729a4f7-c329-472f-b34f-8762ec20d1cd
AgentUIVersion.tsx
[{'import_name': ['useState', 'useEffect'], 'import_path': 'react'}, {'import_name': ['AgentApiInterface'], 'import_path': '@migration-planner-ui/agent-client/apis'}, {'import_name': ['useInjection'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['Symbols'], 'import_path': '#/main/Symbols'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/common/AgentUIVersion.tsx
import React, { useState, useEffect } from 'react'; import type { AgentApiInterface } from "@migration-planner-ui/agent-client/apis"; import { useInjection } from '@migration-planner-ui/ioc'; import { Symbols } from '#/main/Symbols'; export const AgentUIVersion: React.FC = () => { const agentApi = useInjection<AgentApiInterface>(Symbols.AgentApi); const [versionInfo, setVersionInfo] = useState<string | null>(null); const [error, setError] = useState<string | null>(null); useEffect(() => { const fetchVersion = async ():Promise<void> => { try { const statusReply = await agentApi.getAgentVersion(); setVersionInfo(statusReply); } catch (err) { console.error('Error fetching agent version:', err); setError('Error fetching version'); } }; fetchVersion(); }, [agentApi]); if (error) { return <div data-testid="agent-api-lib-version" hidden>Error: {error}</div>; } if (!versionInfo) { return <div data-testid="agent-api-lib-version" hidden>Loading...</div>; } return ( <div data-testid="agent-api-lib-version" hidden> {versionInfo} </div> ); };
null
function
kubev2v/migration-planner-ui
eb5b8299-b6a6-4ae3-9b56-5310a7d24a00
AgentUIVersion
[{'import_name': ['useState', 'useEffect'], 'import_path': 'react'}, {'import_name': ['AgentApiInterface'], 'import_path': '@migration-planner-ui/agent-client/apis'}, {'import_name': ['useInjection'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['Symbols'], 'import_path': '#/main/Symbols'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/common/AgentUIVersion.tsx
() => { const agentApi = useInjection<AgentApiInterface>(Symbols.AgentApi); const [versionInfo, setVersionInfo] = useState<string | null>(null); const [error, setError] = useState<string | null>(null); useEffect(() => { const fetchVersion = async ():Promise<void> => { try { const statusReply = await agentApi.getAgentVersion(); setVersionInfo(statusReply); } catch (err) { console.error('Error fetching agent version:', err); setError('Error fetching version'); } }; fetchVersion(); }, [agentApi]); if (error) { return <div data-testid="agent-api-lib-version" hidden>Error: {error}</div>; } if (!versionInfo) { return <div data-testid="agent-api-lib-version" hidden>Loading...</div>; } return ( <div data-testid="agent-api-lib-version" hidden> {versionInfo} </div> ); }
{}
file
kubev2v/migration-planner-ui
42822398-bc0c-451e-bd7c-ba1eb2371e82
Time.ts
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/common/Time.ts
export type Duration = number; export const enum Time { Millisecond = 1, Second = 1000 * Millisecond, Minute = 60 * Second, Hour = 60 * Minute, Day = 24 * Hour, Week = 7 * Day, } export const sleep = (delayMs: Duration): Promise<void> => new Promise((resolve) => { setTimeout(resolve, delayMs); });
null
function
kubev2v/migration-planner-ui
c5f63536-e0da-41a5-be62-26366848c777
sleep
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/common/Time.ts
(delayMs: Duration): Promise<void> => new Promise((resolve) => { setTimeout(resolve, delayMs); })
{}
file
kubev2v/migration-planner-ui
81986736-4902-48a7-9c3e-afa4455ff13c
Aliases.ts
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/login-form/Aliases.ts
export type FormControlValidatedStateVariant = | "success" | "warning" | "error" | "default";
null
file
kubev2v/migration-planner-ui
863a9fdb-0187-4368-8743-860b501d951b
Constants.ts
[{'import_name': ['Time'], 'import_path': '#/common/Time'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/login-form/Constants.ts
import { Time } from "#/common/Time"; export const DATA_SHARING_ALLOWED_DEFAULT_STATE = true; export const REQUEST_TIMEOUT_SECONDS = 30 * Time.Second;
null
file
kubev2v/migration-planner-ui
06837832-eba4-435b-b9f8-770ed39b7d5a
FormStates.ts
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/login-form/FormStates.ts
export const enum FormStates { CheckingStatus = "checkingStatus", WaitingForCredentials = "waitingForCredentials", Submitting = "submitting", CredentialsAccepted = "credentialsAccepted", CredentialsRejected = "credentialsRejected", InvalidCredentials = "invalidCredentials", GatheringInventory = "gatheringInventory" }
null
file
kubev2v/migration-planner-ui
dfc3e195-5b0a-43c0-b0ae-0a90dd979add
LoginForm.tsx
[{'import_name': ['Alert', 'AlertActionLink', 'Button', 'Card', 'CardBody', 'CardFooter', 'CardHeader', 'Checkbox', 'Form', 'FormGroup', 'FormHelperText', 'HelperText', 'HelperTextItem', 'List', 'ListItem', 'Text', 'TextContent', 'TextInput', 'Spinner', 'SplitItem', 'Split', 'Icon', 'Divider'], 'import_path': '@patternfly/react-core'}, {'import_name': ['LoginFormViewModelInterface'], 'import_path': './hooks/UseViewModel'}, {'import_name': ['FormStates'], 'import_path': './FormStates'}, {'import_name': ['CheckCircleIcon', 'InfoCircleIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['getConfigurationBasePath'], 'import_path': '#/main/Root'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/login-form/LoginForm.tsx
import React from "react"; import { Alert, AlertActionLink, Button, Card, CardBody, CardFooter, CardHeader, Checkbox, Form, FormGroup, FormHelperText, HelperText, HelperTextItem, List, ListItem, Text, TextContent, TextInput, Spinner, SplitItem, Split, Icon, Divider, } from "@patternfly/react-core"; import { LoginFormViewModelInterface } from "./hooks/UseViewModel"; import { FormStates } from "./FormStates"; import { CheckCircleIcon, InfoCircleIcon } from "@patternfly/react-icons"; import { getConfigurationBasePath } from "#/main/Root"; import globalSuccessColor100 from "@patternfly/react-tokens/dist/esm/global_success_color_100"; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace LoginForm { export type Props = { vm: LoginFormViewModelInterface; }; } export const LoginForm: React.FC<LoginForm.Props> = (props) => { const { vm } = props; console.log(vm.formState); return ( <Card style={{ width: "36rem" }} isFlat isRounded aria-labelledby="card-header-title" aria-describedby="card-body-description" > <CardHeader id="card-header-title"> <TextContent> <Text component="h2">Migration Discovery VM</Text> <Text> The migration discovery VM requires access to your VMware environment to execute a discovery process that gathers essential data, including network topology, storage configuration, and VM inventory. The process leverages this information to provide recommendations for a seamless migration to OpenShift Virtualization. </Text> </TextContent> </CardHeader> <Divider style={{ backgroundColor: "#f5f5f5", height: "10px", border: "none" }} /> <CardBody id="card-body-note" style={{ backgroundColor: "#ffffff", border: "1px solid #d2d2d2", padding: "1rem" }}> <TextContent style={{ display: "flex", alignItems: "center", gap: "0.5rem" }}> <InfoCircleIcon color="#007bff" /> <Text component="p" style={{ color: "#002952", fontWeight: "bold" }}> Access control </Text> </TextContent> <Text component="p" style={{ marginTop: "0.5rem", marginLeft: "1.5rem" }}> To ensure secure access during the discovery process, we recommend creating a dedicated VMware user account with read-only permissions. </Text> </CardBody> <Divider style={{ backgroundColor: "#f5f5f5", height: "10px", border: "none" }} /> <CardBody id="card-body-description" > <Form ref={vm.formRef} onSubmit={vm.handleSubmit} id="login-form"> <FormGroup label="Environment URL" isRequired fieldId="url-form-control" hidden={ vm.formState === FormStates.GatheringInventory || vm.formState === FormStates.CredentialsAccepted } > <TextInput validated={vm.urlControlStateVariant} isDisabled={vm.shouldDisableFormControl} id="url-form-control" type="url" name="url" isRequired placeholder="https://vcenter_server_ip_address_or_fqdn" pattern="https://.*" aria-describedby="url-helper-text" /> {vm.urlControlHelperText && ( <FormHelperText> <HelperText> <HelperTextItem variant={vm.urlControlStateVariant} id="url-helper-text" > {vm.urlControlHelperText} </HelperTextItem> </HelperText> </FormHelperText> )} </FormGroup> <FormGroup label="VMware Username" isRequired fieldId="username-form-control" hidden={ vm.formState === FormStates.GatheringInventory || vm.formState === FormStates.CredentialsAccepted } > <TextInput validated={vm.usernameControlStateVariant} isDisabled={vm.shouldDisableFormControl} id="username-form-control" type="email" name="username" isRequired placeholder="[email protected]" aria-describedby="username-helper-text" /> {vm.usernameControlHelperText && ( <FormHelperText> <HelperText> <HelperTextItem variant={vm.usernameControlStateVariant} id="username-helper-text" > {vm.usernameControlHelperText} </HelperTextItem> </HelperText> </FormHelperText> )} </FormGroup> <FormGroup label="Password" isRequired fieldId="password-form-control" hidden={ vm.formState === FormStates.GatheringInventory || vm.formState === FormStates.CredentialsAccepted } > <TextInput validated={vm.passwordControlStateVariant} isDisabled={vm.shouldDisableFormControl} id="password-form-control" type="password" name="password" isRequired aria-describedby="password-helper-text" /> {vm.passwordControlHelperText && vm.passwordControlHelperText && ( <FormHelperText> <HelperText> <HelperTextItem variant={vm.passwordControlStateVariant} id="password-helper-text" > {vm.passwordControlHelperText} </HelperTextItem> </HelperText> </FormHelperText> )} </FormGroup> <FormGroup fieldId="checkbox-form-control" hidden={ vm.formState === FormStates.GatheringInventory || vm.formState === FormStates.CredentialsAccepted }> <Checkbox isDisabled={vm.shouldDisableFormControl} id="checkbox-form-control" name="isDataSharingAllowed" label="I agree to share aggregated data about my environment with Red Hat." aria-label="Share aggregated data" onChange={(_event,checked)=>vm.handleChangeDataSharingAllowed(checked)} isChecked={vm.isDataSharingChecked} /> </FormGroup> {vm.shouldDisplayAlert && ( <FormGroup> <Alert isInline variant={vm.alertVariant} title={vm.alertTitle} actionLinks={ <AlertActionLink component="a" href="#"> {vm.alertActionLinkText} </AlertActionLink> } > {vm.alertDescriptionList && vm.alertDescriptionList.length > 0 && ( <List> {vm.alertDescriptionList.map(({ id, text }) => ( <ListItem key={id}>{text}</ListItem> ))} </List> )} </Alert> </FormGroup> )} </Form> </CardBody> <CardBody id="card-body-discovery-status" hidden={ vm.formState !== FormStates.GatheringInventory && vm.formState !== FormStates.CredentialsAccepted } > {vm.formState === FormStates.GatheringInventory && ( <Text component="p" style={{ textAlign: "center" }}> <Icon size="xl" > <Spinner /> </Icon> <br/>Gathering inventory... </Text> )} {vm.formState === FormStates.CredentialsAccepted && ( <Text component="p" style={{ textAlign: "center" }}> <Icon size="xl" isInline> <CheckCircleIcon color={globalSuccessColor100.value} /> </Icon> <br/>Discovery completed </Text> )} </CardBody> <CardFooter> <Split style={{ alignItems: "flex-end" }}> <SplitItem> {vm.formState !== FormStates.CredentialsAccepted && vm.formState !== FormStates.GatheringInventory && ( <Button type="submit" variant="primary" isDisabled={vm.shouldDisableFormControl || !vm.isDataSharingChecked} form="login-form" > Log in </Button>)} {(vm.formState === FormStates.CredentialsAccepted || vm.formState === FormStates.GatheringInventory) && ( <> <Button variant="primary" onClick={vm.handleReturnToAssistedMigration} style={{ marginLeft: "16px" }} > Go back to assessment wizard </Button> <Button variant="secondary" onClick={() => window.open(getConfigurationBasePath() + "/inventory", "_blank")} style={{ marginLeft: "16px" }} > Download Inventory </Button> </> )} </SplitItem> <SplitItem isFilled></SplitItem> <SplitItem style={{ paddingRight: "2rem" }}> {vm.formState === FormStates.CheckingStatus && ( <TextContent> <Text component="p"> <Spinner isInline /> Checking status... </Text> </TextContent> )} </SplitItem> </Split> </CardFooter> </Card> ); }; LoginForm.displayName = "LoginForm";
null
file
kubev2v/migration-planner-ui
15c8c1b9-93db-4d4e-bedd-942e5bec70c8
UseViewModel.ts
[{'import_name': ['useState', 'useRef', 'useCallback', 'useMemo'], 'import_path': 'react'}, {'import_name': ['useAsync', 'useMount', 'useTitle'], 'import_path': 'react-use'}, {'import_name': ['useNavigate'], 'import_path': 'react-router-dom'}, {'import_name': ['AlertVariant'], 'import_path': '@patternfly/react-core'}, {'import_name': ['SourceStatus', 'Credentials'], 'import_path': '@migration-planner-ui/agent-client/models'}, {'import_name': ['AgentApiInterface'], 'import_path': '@migration-planner-ui/agent-client/apis'}, {'import_name': ['useInjection'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['newAbortSignal'], 'import_path': '#/common/AbortSignal'}, {'import_name': ['DATA_SHARING_ALLOWED_DEFAULT_STATE', 'REQUEST_TIMEOUT_SECONDS'], 'import_path': '#/login-form/Constants'}, {'import_name': ['FormStates'], 'import_path': '#/login-form/FormStates'}, {'import_name': ['FormControlValidatedStateVariant'], 'import_path': '#/login-form/Aliases'}, {'import_name': ['Symbols'], 'import_path': '#/main/Symbols'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/login-form/hooks/UseViewModel.ts
import { useState, useRef, useCallback, useMemo } from "react"; import { useAsync, useMount, useTitle } from "react-use"; import { useNavigate } from "react-router-dom"; import { AlertVariant } from "@patternfly/react-core"; import { SourceStatus, type Credentials, } from "@migration-planner-ui/agent-client/models"; import type { AgentApiInterface } from "@migration-planner-ui/agent-client/apis"; import { useInjection } from "@migration-planner-ui/ioc"; import { newAbortSignal } from "#/common/AbortSignal"; import { DATA_SHARING_ALLOWED_DEFAULT_STATE, REQUEST_TIMEOUT_SECONDS, } from "#/login-form/Constants"; import { FormStates } from "#/login-form/FormStates"; import { FormControlValidatedStateVariant } from "#/login-form/Aliases"; import { Symbols } from "#/main/Symbols"; export interface LoginFormViewModelInterface { formState: FormStates; formRef: React.MutableRefObject<HTMLFormElement | undefined>; urlControlStateVariant: FormControlValidatedStateVariant; urlControlHelperText?: string; usernameControlStateVariant: FormControlValidatedStateVariant; usernameControlHelperText?: string; passwordControlStateVariant: FormControlValidatedStateVariant; passwordControlHelperText?: string; shouldDisableFormControl: boolean; alertVariant?: AlertVariant; alertTitle?: string; alertDescriptionList?: Array<{ id: number; text: string }>; alertActionLinkText?: string; shouldDisplayAlert: boolean; handleSubmit: React.FormEventHandler<HTMLFormElement>; handleReturnToAssistedMigration: () => void; handleChangeDataSharingAllowed: (checked:boolean)=>void; isDataSharingChecked: boolean; } const _computeFormControlVariant = ( formState: FormStates ): FormControlValidatedStateVariant => { switch (formState) { case FormStates.CredentialsAccepted: return "success"; case FormStates.InvalidCredentials: case FormStates.CredentialsRejected: return "error"; default: return "default"; } }; export const useViewModel = (): LoginFormViewModelInterface => { useTitle("Login"); const navigateTo = useNavigate(); const [formState, setFormState] = useState<FormStates>( FormStates.CheckingStatus ); const formRef = useRef<HTMLFormElement>(); const agentApi = useInjection<AgentApiInterface>(Symbols.AgentApi); const [isDataSharingAllowed,setIsDataSharingAllowed] = useState<boolean>(DATA_SHARING_ALLOWED_DEFAULT_STATE); useMount(() => { const form = formRef.current; if (!form) { return; } form["isDataSharingAllowed"].checked = isDataSharingAllowed; }); useAsync(async () => { const res = await agentApi.getStatus(); switch (res.status) { case SourceStatus.SourceStatusWaitingForCredentials: setFormState(FormStates.WaitingForCredentials); break; case SourceStatus.SourceStatusGatheringInitialInventory: setFormState(FormStates.GatheringInventory); break; case SourceStatus.SourceStatusUpToDate: setFormState(FormStates.CredentialsAccepted); break; default: break; } }); return { formState, formRef, urlControlStateVariant: useMemo<FormControlValidatedStateVariant>(() => { switch (formState) { case FormStates.CredentialsAccepted: return "success"; case FormStates.InvalidCredentials: return "success"; case FormStates.CredentialsRejected: return "error"; default: return "default"; } }, [formState]), usernameControlStateVariant: _computeFormControlVariant(formState), passwordControlStateVariant: _computeFormControlVariant(formState), shouldDisableFormControl: useMemo( () => [ FormStates.CheckingStatus, FormStates.Submitting, FormStates.CredentialsAccepted, ].includes(formState), [formState] ), alertVariant: useMemo(() => { switch (formState) { case FormStates.CredentialsAccepted: return AlertVariant.success; case FormStates.InvalidCredentials: case FormStates.CredentialsRejected: return AlertVariant.danger; } }, [formState]), alertTitle: useMemo(() => { switch (formState) { case FormStates.CredentialsAccepted: return "Connected"; case FormStates.InvalidCredentials: return "Invalid Credentials"; case FormStates.CredentialsRejected: return "Error"; } }, [formState]), alertDescriptionList: useMemo(() => { switch (formState) { case FormStates.CredentialsAccepted: return [ { id: 1, text: "The migration discovery VM is connected to your VMware environment", }, ]; case FormStates.InvalidCredentials: return [ { id: 1, text: "Please double-check your entry for any typos." }, { id: 2, text: "Verify your account has not been temporarily locked for security reasons.", }, ]; case FormStates.CredentialsRejected: return [ { id: 1, text: "Please double-check the URL is correct and reachable from within the VM.", }, ]; } }, [formState]), shouldDisplayAlert: useMemo( () => ![ FormStates.CheckingStatus, FormStates.WaitingForCredentials, FormStates.Submitting, FormStates.GatheringInventory ].includes(formState), [formState] ), handleSubmit: useCallback<React.FormEventHandler<HTMLFormElement>>( async (event) => { event.preventDefault(); const form = formRef.current; if (!form) { return; } const ok = form.reportValidity(); if (ok) { setFormState(FormStates.Submitting); } else { return; } const credentials: Credentials = { url: form["url"].value, username: form["username"].value, password: form["password"].value, isDataSharingAllowed: form["isDataSharingAllowed"].checked, }; const signal = newAbortSignal( REQUEST_TIMEOUT_SECONDS, "The server didn't respond in a timely fashion." ); const [statusCodeOK, error] = await agentApi.putCredentials( credentials, { signal, } ); const status = statusCodeOK ?? error.code; switch (status) { case 204: setFormState(FormStates.CredentialsAccepted); break; case 400: setFormState(FormStates.CredentialsRejected); break; case 401: setFormState(FormStates.InvalidCredentials); break; case 422: setFormState(FormStates.CredentialsRejected); break; default: navigateTo(`/error/${error!.code}`, { state: { message: error!.message }, }); break; } }, [agentApi, navigateTo] ), handleReturnToAssistedMigration: useCallback(async () => { const serviceUrl = await agentApi.getServiceUiUrl() || "http://localhost:3000/migrate/wizard"; window.open(serviceUrl, '_blank', 'noopener,noreferrer'); }, []), handleChangeDataSharingAllowed: useCallback((checked)=>{ console.log(checked); setIsDataSharingAllowed(checked); },[]), isDataSharingChecked: isDataSharingAllowed }; };
null
function
kubev2v/migration-planner-ui
d0976c15-8dd1-4e5f-a82b-09506a0ee7b6
_computeFormControlVariant
[{'import_name': ['Credentials'], 'import_path': '@migration-planner-ui/agent-client/models'}, {'import_name': ['FormStates'], 'import_path': '#/login-form/FormStates'}, {'import_name': ['FormControlValidatedStateVariant'], 'import_path': '#/login-form/Aliases'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/login-form/hooks/UseViewModel.ts
( formState: FormStates ): FormControlValidatedStateVariant => { switch (formState) { case FormStates.CredentialsAccepted: return "success"; case FormStates.InvalidCredentials: case FormStates.CredentialsRejected: return "error"; default: return "default"; } }
{}
function
kubev2v/migration-planner-ui
f085c396-8ef8-41d3-8f90-eb14819ea8e2
useViewModel
[{'import_name': ['useState', 'useRef', 'useCallback', 'useMemo'], 'import_path': 'react'}, {'import_name': ['useAsync', 'useMount', 'useTitle'], 'import_path': 'react-use'}, {'import_name': ['useNavigate'], 'import_path': 'react-router-dom'}, {'import_name': ['AlertVariant'], 'import_path': '@patternfly/react-core'}, {'import_name': ['SourceStatus', 'Credentials'], 'import_path': '@migration-planner-ui/agent-client/models'}, {'import_name': ['AgentApiInterface'], 'import_path': '@migration-planner-ui/agent-client/apis'}, {'import_name': ['useInjection'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['newAbortSignal'], 'import_path': '#/common/AbortSignal'}, {'import_name': ['DATA_SHARING_ALLOWED_DEFAULT_STATE', 'REQUEST_TIMEOUT_SECONDS'], 'import_path': '#/login-form/Constants'}, {'import_name': ['FormStates'], 'import_path': '#/login-form/FormStates'}, {'import_name': ['FormControlValidatedStateVariant'], 'import_path': '#/login-form/Aliases'}, {'import_name': ['Symbols'], 'import_path': '#/main/Symbols'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/login-form/hooks/UseViewModel.ts
(): LoginFormViewModelInterface => { useTitle("Login"); const navigateTo = useNavigate(); const [formState, setFormState] = useState<FormStates>( FormStates.CheckingStatus ); const formRef = useRef<HTMLFormElement>(); const agentApi = useInjection<AgentApiInterface>(Symbols.AgentApi); const [isDataSharingAllowed,setIsDataSharingAllowed] = useState<boolean>(DATA_SHARING_ALLOWED_DEFAULT_STATE); useMount(() => { const form = formRef.current; if (!form) { return; } form["isDataSharingAllowed"].checked = isDataSharingAllowed; }); useAsync(async () => { const res = await agentApi.getStatus(); switch (res.status) { case SourceStatus.SourceStatusWaitingForCredentials: setFormState(FormStates.WaitingForCredentials); break; case SourceStatus.SourceStatusGatheringInitialInventory: setFormState(FormStates.GatheringInventory); break; case SourceStatus.SourceStatusUpToDate: setFormState(FormStates.CredentialsAccepted); break; default: break; } }); return { formState, formRef, urlControlStateVariant: useMemo<FormControlValidatedStateVariant>(() => { switch (formState) { case FormStates.CredentialsAccepted: return "success"; case FormStates.InvalidCredentials: return "success"; case FormStates.CredentialsRejected: return "error"; default: return "default"; } }, [formState]), usernameControlStateVariant: _computeFormControlVariant(formState), passwordControlStateVariant: _computeFormControlVariant(formState), shouldDisableFormControl: useMemo( () => [ FormStates.CheckingStatus, FormStates.Submitting, FormStates.CredentialsAccepted, ].includes(formState), [formState] ), alertVariant: useMemo(() => { switch (formState) { case FormStates.CredentialsAccepted: return AlertVariant.success; case FormStates.InvalidCredentials: case FormStates.CredentialsRejected: return AlertVariant.danger; } }, [formState]), alertTitle: useMemo(() => { switch (formState) { case FormStates.CredentialsAccepted: return "Connected"; case FormStates.InvalidCredentials: return "Invalid Credentials"; case FormStates.CredentialsRejected: return "Error"; } }, [formState]), alertDescriptionList: useMemo(() => { switch (formState) { case FormStates.CredentialsAccepted: return [ { id: 1, text: "The migration discovery VM is connected to your VMware environment", }, ]; case FormStates.InvalidCredentials: return [ { id: 1, text: "Please double-check your entry for any typos." }, { id: 2, text: "Verify your account has not been temporarily locked for security reasons.", }, ]; case FormStates.CredentialsRejected: return [ { id: 1, text: "Please double-check the URL is correct and reachable from within the VM.", }, ]; } }, [formState]), shouldDisplayAlert: useMemo( () => ![ FormStates.CheckingStatus, FormStates.WaitingForCredentials, FormStates.Submitting, FormStates.GatheringInventory ].includes(formState), [formState] ), handleSubmit: useCallback<React.FormEventHandler<HTMLFormElement>>( async (event) => { event.preventDefault(); const form = formRef.current; if (!form) { return; } const ok = form.reportValidity(); if (ok) { setFormState(FormStates.Submitting); } else { return; } const credentials: Credentials = { url: form["url"].value, username: form["username"].value, password: form["password"].value, isDataSharingAllowed: form["isDataSharingAllowed"].checked, }; const signal = newAbortSignal( REQUEST_TIMEOUT_SECONDS, "The server didn't respond in a timely fashion." ); const [statusCodeOK, error] = await agentApi.putCredentials( credentials, { signal, } ); const status = statusCodeOK ?? error.code; switch (status) { case 204: setFormState(FormStates.CredentialsAccepted); break; case 400: setFormState(FormStates.CredentialsRejected); break; case 401: setFormState(FormStates.InvalidCredentials); break; case 422: setFormState(FormStates.CredentialsRejected); break; default: navigateTo(`/error/${error!.code}`, { state: { message: error!.message }, }); break; } }, [agentApi, navigateTo] ), handleReturnToAssistedMigration: useCallback(async () => { const serviceUrl = await agentApi.getServiceUiUrl() || "http://localhost:3000/migrate/wizard"; window.open(serviceUrl, '_blank', 'noopener,noreferrer'); }, []), handleChangeDataSharingAllowed: useCallback((checked)=>{ console.log(checked); setIsDataSharingAllowed(checked); },[]), isDataSharingChecked: isDataSharingAllowed }; }
{}
file
kubev2v/migration-planner-ui
6481427a-470f-4595-874b-3607b9d56ff4
Root.tsx
[{'import_name': ['RouterProvider'], 'import_path': 'react-router-dom'}, {'import_name': ['Configuration'], 'import_path': '@migration-planner-ui/api-client/runtime'}, {'import_name': ['AgentApi'], 'import_path': '@migration-planner-ui/agent-client/apis'}, {'import_name': ['Spinner'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Container', 'Provider', 'DependencyInjectionProvider'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['router'], 'import_path': './Router'}, {'import_name': ['Symbols'], 'import_path': './Symbols'}, {'import_name': ['AgentUIVersion'], 'import_path': '#/common/AgentUIVersion'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/main/Root.tsx
import "@patternfly/react-core/dist/styles/base.css"; import React from "react"; import ReactDOM from "react-dom/client"; import { RouterProvider } from "react-router-dom"; import { Configuration } from "@migration-planner-ui/api-client/runtime"; import { AgentApi } from "@migration-planner-ui/agent-client/apis"; import { Spinner } from "@patternfly/react-core"; import { Container, Provider as DependencyInjectionProvider, } from "@migration-planner-ui/ioc"; import { router } from "./Router"; import { Symbols } from "./Symbols"; import { AgentUIVersion } from "#/common/AgentUIVersion"; export const getConfigurationBasePath = (): string => { if (import.meta.env.PROD) { return `${window.location.origin}/api/v1`; } return `${window.location.origin}/agent/api/v1`; }; function getConfiguredContainer(): Container { const agentApiConfig = new Configuration({ basePath: getConfigurationBasePath(), }); const container = new Container(); container.register(Symbols.AgentApi, new AgentApi(agentApiConfig)); return container; } function main(): void { const root = document.getElementById("root"); if (root) { root.style.height = "inherit"; const container = getConfiguredContainer(); ReactDOM.createRoot(root).render( <React.StrictMode> <DependencyInjectionProvider container={container}> <React.Suspense fallback={<Spinner />}> <AgentUIVersion /> <RouterProvider router={router} /> </React.Suspense> </DependencyInjectionProvider> </React.StrictMode> ); } } main();
null
function
kubev2v/migration-planner-ui
c0bfaae1-663a-44fb-8f83-8cfc607d3d3e
getConfigurationBasePath
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/main/Root.tsx
(): string => { if (import.meta.env.PROD) { return `${window.location.origin}/api/v1`; } return `${window.location.origin}/agent/api/v1`; }
{}
function
kubev2v/migration-planner-ui
2f6d26d9-35b7-42a2-b9e5-ecb49b697eb3
getConfiguredContainer
[{'import_name': ['Configuration'], 'import_path': '@migration-planner-ui/api-client/runtime'}, {'import_name': ['AgentApi'], 'import_path': '@migration-planner-ui/agent-client/apis'}, {'import_name': ['Container'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['Symbols'], 'import_path': './Symbols'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/main/Root.tsx
function getConfiguredContainer(): Container { const agentApiConfig = new Configuration({ basePath: getConfigurationBasePath(), }); const container = new Container(); container.register(Symbols.AgentApi, new AgentApi(agentApiConfig)); return container; }
{}
function
kubev2v/migration-planner-ui
3dd705c3-b703-4d7a-94cf-b9a7cb6affa6
main
[{'import_name': ['RouterProvider'], 'import_path': 'react-router-dom'}, {'import_name': ['Spinner'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Container', 'Provider', 'DependencyInjectionProvider'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['router'], 'import_path': './Router'}, {'import_name': ['AgentUIVersion'], 'import_path': '#/common/AgentUIVersion'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/main/Root.tsx
function main(): void { const root = document.getElementById("root"); if (root) { root.style.height = "inherit"; const container = getConfiguredContainer(); ReactDOM.createRoot(root).render( <React.StrictMode> <DependencyInjectionProvider container={container}> <React.Suspense fallback={<Spinner />}> <AgentUIVersion /> <RouterProvider router={router} /> </React.Suspense> </DependencyInjectionProvider> </React.StrictMode> ); } }
{}
file
kubev2v/migration-planner-ui
ad56bbc1-21fc-41ca-96b6-8735ea6ee419
Router.tsx
[{'import_name': ['createBrowserRouter', 'Navigate'], 'import_path': 'react-router-dom'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/main/Router.tsx
/* eslint-disable @typescript-eslint/explicit-function-return-type */ import { createBrowserRouter, Navigate } from "react-router-dom"; export const router = createBrowserRouter([ { path: "/", index: true, element: <Navigate to="/login" />, }, { path: "/login", lazy: async () => { const { default: AgentLoginPage } = await import( "#/pages/AgentLoginPage" ); return { Component: AgentLoginPage, }; }, }, { path: "/error/:code", lazy: async () => { const { default: ErrorPage } = await import("#/pages/ErrorPage"); return { Component: ErrorPage, }; }, }, { path: "*", lazy: async () => { const { default: ErrorPage } = await import("#/pages/ErrorPage"); return { element: ( <ErrorPage code="404" message="We lost that page" actions={[ { children: "Go back", component: "a", onClick: (_event): void => { history.back(); }, }, ]} /> ), }; }, }, ]);
null
file
kubev2v/migration-planner-ui
f82eaa0e-cc90-43ad-86b1-a9489c050151
Symbols.ts
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/main/Symbols.ts
/** Symbols used by the DI container */ export const Symbols = Object.freeze({ AgentApi: Symbol.for("AgentApi"), });
null
file
kubev2v/migration-planner-ui
ea2f7a85-e63a-46d6-8ca7-ac1eacfa812b
AgentLoginPage.tsx
[{'import_name': ['Bullseye', 'Backdrop'], 'import_path': '@patternfly/react-core'}, {'import_name': ['LoginForm'], 'import_path': '#/login-form/LoginForm'}, {'import_name': ['useViewModel'], 'import_path': '#/login-form/hooks/UseViewModel'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/pages/AgentLoginPage.tsx
import React from "react"; import { Bullseye, Backdrop } from "@patternfly/react-core"; import { LoginForm } from "#/login-form/LoginForm"; import { useViewModel } from "#/login-form/hooks/UseViewModel"; const AgentLoginPage: React.FC = () => { const vm = useViewModel(); return ( <> <Backdrop style={{ zIndex: 0 }} /> <Bullseye> <LoginForm vm={vm} /> </Bullseye> </> ); }; AgentLoginPage.displayName = "AgentLoginPage"; export default AgentLoginPage;
null
function
kubev2v/migration-planner-ui
e93253bd-982c-4843-a1f4-9570e8eead21
AgentLoginPage
[{'import_name': ['Bullseye', 'Backdrop'], 'import_path': '@patternfly/react-core'}, {'import_name': ['LoginForm'], 'import_path': '#/login-form/LoginForm'}, {'import_name': ['useViewModel'], 'import_path': '#/login-form/hooks/UseViewModel'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/pages/AgentLoginPage.tsx
() => { const vm = useViewModel(); return ( <> <Backdrop style={{ zIndex: 0 }} /> <Bullseye> <LoginForm vm={vm} /> </Bullseye> </> ); }
{}
file
kubev2v/migration-planner-ui
3488ee98-669d-43b6-a8d9-f58d79c341d0
ErrorPage.tsx
[{'import_name': ['css', 'keyframes'], 'import_path': '@emotion/css'}, {'import_name': ['Bullseye', 'Card', 'Button', 'TextContent', 'Text', 'ButtonProps', 'Backdrop', 'EmptyStateIcon', 'EmptyState', 'EmptyStateBody', 'EmptyStateActions', 'EmptyStateFooter'], 'import_path': '@patternfly/react-core'}, {'import_name': ['WarningTriangleIcon', 'ErrorCircleOIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['useLocation', 'useParams'], 'import_path': 'react-router-dom'}]
https://github.com/kubev2v/migration-planner-ui/apps/agent/src/pages/ErrorPage.tsx
import React from "react"; import { css, keyframes } from "@emotion/css"; import { Bullseye, Card, Button, TextContent, Text, ButtonProps, Backdrop, EmptyStateIcon, EmptyState, EmptyStateBody, EmptyStateActions, EmptyStateFooter, } from "@patternfly/react-core"; import { WarningTriangleIcon, ErrorCircleOIcon } from "@patternfly/react-icons"; import globalWarningColor100 from "@patternfly/react-tokens/dist/esm/global_warning_color_100"; import globalDangerColor100 from "@patternfly/react-tokens/dist/esm/global_danger_color_100"; import { useLocation, useParams } from "react-router-dom"; const bounce = keyframes` from, 20%, 53%, 80%, to { transform: translate3d(0,0,0); } 40%, 43% { transform: translate3d(0, -30px, 0); } 70% { transform: translate3d(0, -15px, 0); } 90% { transform: translate3d(0,-4px,0); } `; const classes = { icon: css({ fontSize: "6rem", animation: `${bounce} 1s ease infinite`, transformOrigin: "center bottom", }), } as const; type Props = { code?: string; message?: string; additionalDetails?: string; /** A list of actions, the first entry is considered primary and the rest are secondary. */ actions?: Array<Omit<ButtonProps, "variant">>; }; const ErrorPage: React.FC<Props> = (props) => { const params = useParams(); const location = useLocation(); const { code = params.code ?? "500", message = location.state?.message ?? "That's on us...", additionalDetails, actions = [], } = props; const [primaryAction, ...otherActions] = actions; return ( <> <Backdrop style={{ zIndex: 0 }} /> <Bullseye> <Card style={{ width: "36rem", height: "38rem", justifyContent: "center" }} isFlat isRounded > <EmptyState> <EmptyStateBody> <EmptyStateIcon className={classes.icon} icon={ parseInt(code) < 500 ? WarningTriangleIcon : ErrorCircleOIcon } color={ parseInt(code) < 500 ? globalWarningColor100.value : globalDangerColor100.value } /> <TextContent> <Text component="h1">{code}</Text> <Text component="h2">{message}</Text> {additionalDetails ?? <Text>{additionalDetails}</Text>} </TextContent> </EmptyStateBody> {actions.length > 0 && ( <EmptyStateFooter> <EmptyStateActions> <Button variant="primary" {...primaryAction} /> </EmptyStateActions> <EmptyStateActions> {otherActions.map(({ key, ...props }) => ( <Button key={key} variant="secondary" {...props} /> ))} </EmptyStateActions> </EmptyStateFooter> )} </EmptyState> </Card> </Bullseye> </> ); }; ErrorPage.displayName = "ErrorPage"; export default ErrorPage;
null
file
kubev2v/migration-planner-ui
b96660dd-c449-4468-8f96-8a9d43fc3f08
vite.config.ts
[{'import_name': ['defineConfig'], 'import_path': 'vite'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/vite.config.ts
import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import tsconfigPaths from "vite-tsconfig-paths"; import dotenv from 'dotenv'; // https://vitejs.dev/config/ export default defineConfig((_env) => { return { define: { 'process.env': dotenv.config().parsed }, plugins: [tsconfigPaths(), react()], server: { proxy: { "/planner/api": { target: "http://172.17.0.3:3443", changeOrigin: true, rewrite: (path): string => path.replace(/^\/planner/, ""), }, "/agent/api/v1": { target: "http://172.17.0.3:3333", changeOrigin: true, rewrite: (path): string => path.replace(/^\/agent/, ""), }, }, }, }; });
null
file
kubev2v/migration-planner-ui
61ff0d2f-ebff-49b9-867b-e7a62cf0e076
vite-env.d.ts
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/@types/vite-env.d.ts
/// <reference types="vite/client" />
null
file
kubev2v/migration-planner-ui
7b8e8870-b9ae-44c4-b463-c3be3423201e
MockAgentApi.ts
[{'import_name': ['AgentApiInterface', 'DeleteAgentRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Agent'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse', 'ConfigurationParameters'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockAgentApi.ts
import { AgentApiInterface, DeleteAgentRequest } from "@migration-planner-ui/api-client/apis"; import { Agent } from "@migration-planner-ui/api-client/models"; import { InitOverrideFunction, ApiResponse, ConfigurationParameters } from "@migration-planner-ui/api-client/runtime"; export class MockAgentApi implements AgentApiInterface { constructor(_configuration: ConfigurationParameters) { console.warn("#### CAUTION: Using MockAgentApi ####"); } deleteAgentRaw(_requestParameters: DeleteAgentRequest, _initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<Agent>> { throw new Error("Method not implemented."); } deleteAgent(_requestParameters: DeleteAgentRequest, _initOverrides?: RequestInit | InitOverrideFunction): Promise<Agent> { throw new Error("Method not implemented."); } listAgentsRaw(_initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<Array<Agent>>> { throw new Error("Method not implemented."); } async listAgents(_initOverrides?: RequestInit | InitOverrideFunction): Promise<Array<Agent>> { const { default: json } = await import("./responses/agents.json"); return json as unknown as Array<Agent>; } }
null
function
kubev2v/migration-planner-ui
d65186d2-1471-40fb-ba0d-d910da00e8f3
constructor
[{'import_name': ['Agent'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['ConfigurationParameters'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockAgentApi.ts
constructor(_configuration: ConfigurationParameters) { console.warn("#### CAUTION: Using MockAgentApi ####"); }
{'type': 'class_declaration', 'name': 'MockAgentApi'}
function
kubev2v/migration-planner-ui
add807fb-9395-41a2-919b-1af6feff325c
deleteAgentRaw
[{'import_name': ['DeleteAgentRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Agent'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockAgentApi.ts
deleteAgentRaw(_requestParameters: DeleteAgentRequest, _initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<Agent>> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockAgentApi'}
function
kubev2v/migration-planner-ui
2e5a1726-b6db-4b0b-88af-6b6770597e74
deleteAgent
[{'import_name': ['DeleteAgentRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Agent'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockAgentApi.ts
deleteAgent(_requestParameters: DeleteAgentRequest, _initOverrides?: RequestInit | InitOverrideFunction): Promise<Agent> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockAgentApi'}
function
kubev2v/migration-planner-ui
db573cd6-8ba5-4b9e-8466-fafcc41e0e69
listAgentsRaw
[{'import_name': ['Agent'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockAgentApi.ts
listAgentsRaw(_initOverrides?: RequestInit | InitOverrideFunction): Promise<ApiResponse<Array<Agent>>> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockAgentApi'}
function
kubev2v/migration-planner-ui
8db28a7a-6255-4b49-8307-a39537a4ecc4
listAgents
[{'import_name': ['Agent'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockAgentApi.ts
async listAgents(_initOverrides?: RequestInit | InitOverrideFunction): Promise<Array<Agent>> { const { default: json } = await import("./responses/agents.json"); return json as unknown as Array<Agent>; }
{'type': 'class_declaration', 'name': 'MockAgentApi'}
file
kubev2v/migration-planner-ui
95068e37-26fc-4658-bcf1-e86d3035322c
MockSourceApi.ts
[{'import_name': ['DeleteSourceRequest', 'GetImageRequest', 'ReadSourceRequest', 'SourceApiInterface'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Source', 'Status'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse', 'ConfigurationParameters'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
// import { sleep, Time } from "#/common/Time"; import { DeleteSourceRequest, GetImageRequest, ReadSourceRequest, SourceApiInterface, } from "@migration-planner-ui/api-client/apis"; import { Source, Status } from "@migration-planner-ui/api-client/models"; import { InitOverrideFunction, ApiResponse, ConfigurationParameters, } from "@migration-planner-ui/api-client/runtime"; export class MockSourceApi implements SourceApiInterface { constructor(_configuration: ConfigurationParameters) { console.warn("#### CAUTION: Using MockSourceApi ####"); } async deleteSourceRaw( _requestParameters: DeleteSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Source>> { throw new Error("Method not implemented."); } async deleteSource( _requestParameters: DeleteSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Source> { throw new Error("Method not implemented."); } async deleteSourcesRaw( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Status>> { throw new Error("Method not implemented."); } async deleteSources( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Status> { throw new Error("Method not implemented."); } async getSourceImageRaw( _requestParameters: GetImageRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Blob>> { throw new Error("Method not implemented."); } async getSourceImage( _requestParameters: GetImageRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Blob> { throw new Error("Method not implemented."); } async listSourcesRaw( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Array<Source>>> { throw new Error("Method not implemented."); } async listSources( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Array<Source>> { // await sleep(3 * Time.Second); const { default: json } = await import("./responses/up-to-date.json"); return json as unknown as Array<Source>; } async readSourceRaw( _requestParameters: ReadSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Source>> { throw new Error("Method not implemented."); } async readSource( _requestParameters: ReadSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Source> { throw new Error("Method not implemented."); } async headSourceImage( _requestParameters: { id: string }, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Response> { // Different scenarios const errorScenarios = [ { status: 404, statusText: "Not Found" }, { status: 500, statusText: "Internal Server Error" }, { status: 403, statusText: "Forbidden" }, { status: 401, statusText: "Unautorized" }, ]; // Choose one option randomly const randomError = errorScenarios[Math.floor(Math.random() * errorScenarios.length)]; // Simulation of error response return new Response(null, { status: randomError.status, statusText: randomError.statusText, }); } }
null
function
kubev2v/migration-planner-ui
2289d11a-12e9-4af2-a6f9-9880b89ad76e
constructor
[{'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['ConfigurationParameters'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
constructor(_configuration: ConfigurationParameters) { console.warn("#### CAUTION: Using MockSourceApi ####"); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
15166422-d5d7-4407-aa84-86dc59039ea6
deleteSourceRaw
[{'import_name': ['DeleteSourceRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async deleteSourceRaw( _requestParameters: DeleteSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Source>> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
c8b45395-082c-450f-a810-27e073bc698d
deleteSource
[{'import_name': ['DeleteSourceRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async deleteSource( _requestParameters: DeleteSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Source> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
137d0ce8-97bb-41f3-a918-410cd79e6a36
deleteSourcesRaw
[{'import_name': ['Source', 'Status'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async deleteSourcesRaw( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Status>> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
97ea83f5-a2c8-4dfb-93cf-7999bd5840a2
deleteSources
[{'import_name': ['Source', 'Status'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async deleteSources( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Status> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
293f9334-98e4-487d-b1d6-e467d5995e2d
getSourceImageRaw
[{'import_name': ['GetImageRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async getSourceImageRaw( _requestParameters: GetImageRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Blob>> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
1dc6557e-9e30-437b-9fc5-c3db197ecef3
getSourceImage
[{'import_name': ['GetImageRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async getSourceImage( _requestParameters: GetImageRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Blob> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
7200381f-dcd7-42d8-8db1-43b0906146a4
listSourcesRaw
[{'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async listSourcesRaw( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Array<Source>>> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
f6620d66-9a67-48d4-9bd5-5c1821e35bce
listSources
[{'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async listSources( _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Array<Source>> { // await sleep(3 * Time.Second); const { default: json } = await import("./responses/up-to-date.json"); return json as unknown as Array<Source>; }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
39e3f3f4-53ec-42c3-8b74-bb0018770799
readSourceRaw
[{'import_name': ['ReadSourceRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction', 'ApiResponse'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async readSourceRaw( _requestParameters: ReadSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<ApiResponse<Source>> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
01bf9a4c-a122-496b-84e5-793ade0ceccb
readSource
[{'import_name': ['ReadSourceRequest'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async readSource( _requestParameters: ReadSourceRequest, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Source> { throw new Error("Method not implemented."); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
function
kubev2v/migration-planner-ui
81884ad6-4973-46fe-a936-916742e3bd34
headSourceImage
[{'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['InitOverrideFunction'], 'import_path': '@migration-planner-ui/api-client/runtime'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/apis/MockSourceApi.ts
async headSourceImage( _requestParameters: { id: string }, _initOverrides?: RequestInit | InitOverrideFunction ): Promise<Response> { // Different scenarios const errorScenarios = [ { status: 404, statusText: "Not Found" }, { status: 500, statusText: "Internal Server Error" }, { status: 403, statusText: "Forbidden" }, { status: 401, statusText: "Unautorized" }, ]; // Choose one option randomly const randomError = errorScenarios[Math.floor(Math.random() * errorScenarios.length)]; // Simulation of error response return new Response(null, { status: randomError.status, statusText: randomError.statusText, }); }
{'type': 'class_declaration', 'name': 'MockSourceApi'}
file
kubev2v/migration-planner-ui
dd206108-d6e5-4a2d-8abb-c567106cb7a4
Time.ts
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/common/Time.ts
export type Duration = number; export const enum Time { Millisecond = 1, Second = 1000 * Millisecond, Minute = 60 * Second, Hour = 60 * Minute, Day = 24 * Hour, Week = 7 * Day, } export const sleep = (delayMs: Duration): Promise<void> => new Promise((resolve) => { setTimeout(resolve, delayMs); });
null
function
kubev2v/migration-planner-ui
cfeb8bce-30e2-4dfc-b3e0-68b7183d8622
sleep
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/common/Time.ts
(delayMs: Duration): Promise<void> => new Promise((resolve) => { setTimeout(resolve, delayMs); })
{}
file
kubev2v/migration-planner-ui
fc2042ef-5348-4be7-92e8-03a0b87033e1
version.ts
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/common/version.ts
import buildManifest from 'demo/package.json'; /** * The function returns the build-time generated version. * It can be overriden via the MIGRATION_PLANNER_UI_VERSION environment variable. */ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type export const getMigrationPlannerUiVersion = () => { return process.env.MIGRATION_PLANNER_UI_VERSION || buildManifest.version; };
null
function
kubev2v/migration-planner-ui
1fd9a80e-7877-4ee1-9a8f-05a80eb86b4c
getMigrationPlannerUiVersion
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/common/version.ts
() => { return process.env.MIGRATION_PLANNER_UI_VERSION || buildManifest.version; }
{}
file
kubev2v/migration-planner-ui
ddc3dcb6-6459-453e-b3f1-d40037bea8de
AppPage.tsx
[{'import_name': ['Divider', 'PageSection', 'PageBreadcrumb', 'Breadcrumb', 'BreadcrumbItem', 'BreadcrumbItemProps', 'TextContent', 'Text', 'Page'], 'import_path': '@patternfly/react-core'}, {'import_name': ['PageHeader', 'PageHeaderTitle'], 'import_path': '@redhat-cloud-services/frontend-components/PageHeader'}, {'import_name': ['getMigrationPlannerUiVersion'], 'import_path': '#/common/version'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/components/AppPage.tsx
import React from "react"; import { Divider, PageSection, PageBreadcrumb, Breadcrumb, BreadcrumbItem, BreadcrumbItemProps, TextContent, Text, Page, } from "@patternfly/react-core"; import { PageHeader, PageHeaderTitle, } from "@redhat-cloud-services/frontend-components/PageHeader"; import { getMigrationPlannerUiVersion } from "#/common/version"; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace AppPage { export type Props = { title: React.ReactNode; caption?: React.ReactNode; breadcrumbs?: Array<BreadcrumbItemProps>; }; } export const AppPage: React.FC<React.PropsWithChildren<AppPage.Props>> = ( props ) => { const { title, caption, breadcrumbs, children } = props; return ( <Page> <div id="base-page__header"> <PageBreadcrumb> <Breadcrumb> {breadcrumbs?.map(({ key, children, ...bcProps }) => ( <BreadcrumbItem key={key} {...bcProps}> {children} </BreadcrumbItem> ))} </Breadcrumb> <div data-testid="migration-planner-ui-version" hidden> {getMigrationPlannerUiVersion()} </div> </PageBreadcrumb> <PageHeader> <PageHeaderTitle title={title} /> <TextContent style={{ paddingBlockStart: "var(--pf-v5-global--spacer--md)" }} > <Text component="small">{caption}</Text> </TextContent> </PageHeader> <Divider /> </div> <PageSection>{children}</PageSection> </Page> ); }; AppPage.displayName = "BasePage";
null
file
kubev2v/migration-planner-ui
eca7a90e-177e-434f-818a-3706a883b4ef
ConfirmationModal.tsx
[{'import_name': ['Button'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Modal', 'ModalBody', 'ModalFooter', 'ModalHeader'], 'import_path': '@patternfly/react-core/next'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/components/ConfirmationModal.tsx
import React from "react"; import { Button } from "@patternfly/react-core"; import { Modal, ModalBody, ModalFooter, ModalHeader, } from "@patternfly/react-core/next"; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace ConfirmationModal { export type Props = { onClose?: (event: KeyboardEvent | React.MouseEvent) => void; onCancel?: React.MouseEventHandler<HTMLButtonElement> | undefined; onConfirm?: React.MouseEventHandler<HTMLButtonElement> | undefined; isOpen?: boolean; isDisabled?: boolean; titleIconVariant?: "warning" | "success" | "danger" | "info" | "custom"; variant?: "default" | "small" | "medium" | "large"; primaryButtonVariant?: | "warning" | "danger" | "link" | "primary" | "secondary" | "tertiary" | "plain" | "control"; title: string; }; } export const ConfirmationModal: React.FC< React.PropsWithChildren<ConfirmationModal.Props> > = (props) => { const { isOpen = false, isDisabled = false, onClose, onConfirm, onCancel, variant = "small", titleIconVariant = "info", primaryButtonVariant = "primary", title, children, } = props; return ( <Modal width="24rem" isOpen={isOpen} variant={variant} aria-describedby="modal-title-icon-description" aria-labelledby="title-icon-modal-title" onClose={onClose} > <ModalHeader title={title} titleIconVariant={titleIconVariant} labelId="title-icon-modal-title" /> <ModalBody>{children}</ModalBody> <ModalFooter> <Button key="confirm" variant={primaryButtonVariant} isDisabled={isDisabled} onClick={onConfirm} > Confirm </Button> {onCancel && ( <Button key="cancel" variant="link" onClick={onCancel}> Cancel </Button> )} </ModalFooter> </Modal> ); }; ConfirmationModal.displayName = "ConfirmationModal";
null
file
kubev2v/migration-planner-ui
37f8b826-128a-45b0-8e8c-61040b0a7fe4
CustomEnterpriseIcon.tsx
[{'import_name': ['SVGIcon'], 'import_path': '#/components/SVGIcon'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/components/CustomEnterpriseIcon.tsx
import React from "react"; import { SVGIcon } from "#/components/SVGIcon"; export const CustomEnterpriseIcon: React.FC = () => ( <SVGIcon viewBox="0 0 54 54"> <path d="M22.7165 0L0 5.78496V46.5275L30.2835 54H34.0722L53 46.285V5.78496L26.5052 0H22.7165ZM3.78867 43.5111V10.5943L29.8125 16.4848V49.7971L26.4793 48.9902V43.2105L6.6457 38.3221V44.1809L3.78867 43.5111ZM33.125 17.2441L49.6875 10.7104V43.4637L46.3698 44.8084V40.2627L36.4375 44.2652V48.8584L33.125 50.2295V17.2441ZM6.6457 22.8973L26.4793 27.6961V19.865L6.6457 15.3404V22.8973ZM36.4375 21.1201V28.8352L46.375 24.8379V17.1281L36.4375 21.1201ZM6.6457 34.4672L26.4793 39.2977V31.5193L6.6457 26.7521V34.4672ZM36.4375 32.6953V40.4104L46.3802 36.4131V28.698L36.4375 32.6953Z" /> <ellipse cx="43" cy="41" rx="13" ry="13" fill="#F0F0F0" /> <path d="M52.8258 51.7238L53.7655 50.7665C54.0776 50.4485 54.0776 49.9344 53.7688 49.6164L50.4582 46.2439C50.3088 46.0917 50.1062 46.0071 49.8937 46.0071H49.3525C50.2689 44.8131 50.8135 43.3112 50.8135 41.6774C50.8135 37.7907 47.7221 34.6415 43.9068 34.6415C40.0914 34.6415 37 37.7907 37 41.6774C37 45.564 40.0914 48.7132 43.9068 48.7132C45.5106 48.7132 46.9849 48.1585 48.1571 47.2249V47.7762C48.1571 47.9928 48.2401 48.1991 48.3895 48.3513L51.7001 51.7238C52.0122 52.0418 52.517 52.0418 52.8258 51.7238ZM43.9068 46.0071C41.5591 46.0071 39.6564 44.0723 39.6564 41.6774C39.6564 39.2859 41.5558 37.3476 43.9068 37.3476C46.2544 37.3476 48.1571 39.2825 48.1571 41.6774C48.1571 44.0689 46.2577 46.0071 43.9068 46.0071Z" /> </SVGIcon> ); CustomEnterpriseIcon.displayName = "CustomEnterpriseIcon";
null
function
kubev2v/migration-planner-ui
d36e5aa2-eee0-48c4-837b-23acd9efd98f
CustomEnterpriseIcon
[{'import_name': ['SVGIcon'], 'import_path': '#/components/SVGIcon'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/components/CustomEnterpriseIcon.tsx
() => ( <SVGIcon viewBox="0 0 54 54"> <path d="M22.7165 0L0 5.78496V46.5275L30.2835 54H34.0722L53 46.285V5.78496L26.5052 0H22.7165ZM3.78867 43.5111V10.5943L29.8125 16.4848V49.7971L26.4793 48.9902V43.2105L6.6457 38.3221V44.1809L3.78867 43.5111ZM33.125 17.2441L49.6875 10.7104V43.4637L46.3698 44.8084V40.2627L36.4375 44.2652V48.8584L33.125 50.2295V17.2441ZM6.6457 22.8973L26.4793 27.6961V19.865L6.6457 15.3404V22.8973ZM36.4375 21.1201V28.8352L46.375 24.8379V17.1281L36.4375 21.1201ZM6.6457 34.4672L26.4793 39.2977V31.5193L6.6457 26.7521V34.4672ZM36.4375 32.6953V40.4104L46.3802 36.4131V28.698L36.4375 32.6953Z" /> <ellipse cx="43" cy="41" rx="13" ry="13" fill="#F0F0F0" /> <path d="M52.8258 51.7238L53.7655 50.7665C54.0776 50.4485 54.0776 49.9344 53.7688 49.6164L50.4582 46.2439C50.3088 46.0917 50.1062 46.0071 49.8937 46.0071H49.3525C50.2689 44.8131 50.8135 43.3112 50.8135 41.6774C50.8135 37.7907 47.7221 34.6415 43.9068 34.6415C40.0914 34.6415 37 37.7907 37 41.6774C37 45.564 40.0914 48.7132 43.9068 48.7132C45.5106 48.7132 46.9849 48.1585 48.1571 47.2249V47.7762C48.1571 47.9928 48.2401 48.1991 48.3895 48.3513L51.7001 51.7238C52.0122 52.0418 52.517 52.0418 52.8258 51.7238ZM43.9068 46.0071C41.5591 46.0071 39.6564 44.0723 39.6564 41.6774C39.6564 39.2859 41.5558 37.3476 43.9068 37.3476C46.2544 37.3476 48.1571 39.2825 48.1571 41.6774C48.1571 44.0689 46.2577 46.0071 43.9068 46.0071Z" /> </SVGIcon> )
{}
file
kubev2v/migration-planner-ui
4e6f69e7-cdc6-45cb-932c-647137520cfd
ErrorPage.tsx
[{'import_name': ['css', 'keyframes'], 'import_path': '@emotion/css'}, {'import_name': ['Bullseye', 'Card', 'Button', 'TextContent', 'Text', 'ButtonProps', 'Backdrop', 'EmptyStateIcon', 'EmptyState', 'EmptyStateBody', 'EmptyStateActions', 'EmptyStateFooter'], 'import_path': '@patternfly/react-core'}, {'import_name': ['WarningTriangleIcon', 'ErrorCircleOIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['useLocation', 'useParams'], 'import_path': 'react-router-dom'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/components/ErrorPage.tsx
import React from "react"; import { css, keyframes } from "@emotion/css"; import { Bullseye, Card, Button, TextContent, Text, ButtonProps, Backdrop, EmptyStateIcon, EmptyState, EmptyStateBody, EmptyStateActions, EmptyStateFooter, } from "@patternfly/react-core"; import { WarningTriangleIcon, ErrorCircleOIcon } from "@patternfly/react-icons"; import globalWarningColor100 from "@patternfly/react-tokens/dist/esm/global_warning_color_100"; import globalDangerColor100 from "@patternfly/react-tokens/dist/esm/global_danger_color_100"; import { useLocation, useParams } from "react-router-dom"; const bounce = keyframes` from, 20%, 53%, 80%, to { transform: translate3d(0,0,0); } 40%, 43% { transform: translate3d(0, -30px, 0); } 70% { transform: translate3d(0, -15px, 0); } 90% { transform: translate3d(0,-4px,0); } `; const classes = { icon: css({ fontSize: "6rem", animation: `${bounce} 1s ease infinite`, transformOrigin: "center bottom", }), } as const; type Props = { code?: string; message?: string; additionalDetails?: string; /** A list of actions, the first entry is considered primary and the rest are secondary. */ actions?: Array<Omit<ButtonProps, "variant">>; }; const ErrorPage: React.FC<Props> = (props) => { const params = useParams(); const location = useLocation(); const { code = params.code ?? "500", message = location.state?.message ?? "That's on us...", additionalDetails, actions = [], } = props; const [primaryAction, ...otherActions] = actions; return ( <> <Backdrop style={{ zIndex: 0 }} /> <Bullseye> <Card style={{ width: "36rem", height: "38rem", justifyContent: "center" }} isFlat isRounded > <EmptyState> <EmptyStateBody> <EmptyStateIcon className={classes.icon} icon={ parseInt(code) < 500 ? WarningTriangleIcon : ErrorCircleOIcon } color={ parseInt(code) < 500 ? globalWarningColor100.value : globalDangerColor100.value } /> <TextContent> <Text component="h1">{code}</Text> <Text component="h2">{message}</Text> {additionalDetails ?? <Text>{additionalDetails}</Text>} </TextContent> </EmptyStateBody> {actions.length > 0 && ( <EmptyStateFooter> <EmptyStateActions> <Button variant="primary" {...primaryAction} /> </EmptyStateActions> <EmptyStateActions> {otherActions.map(({ key, ...props }) => ( <Button key={key} variant="secondary" {...props} /> ))} </EmptyStateActions> </EmptyStateFooter> )} </EmptyState> </Card> </Bullseye> </> ); }; ErrorPage.displayName = "ErrorPage"; export default ErrorPage;
null
file
kubev2v/migration-planner-ui
9d8b897c-0428-4323-a3b0-b3d88bcc4c79
SVGIcon.tsx
[{'import_name': ['PropsWithChildren', 'useEffect'], 'import_path': 'react'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/components/SVGIcon.tsx
import React, { PropsWithChildren, useEffect } from "react"; export type SVGIconProps = PropsWithChildren< Omit<React.SVGProps<SVGElement>, "ref" | "role"> > & { title?: string; className?: string; }; type SVGIconState = { title: `svg-icon-title-${number}`; }; let currentId = 0; export const SVGIcon = React.forwardRef<SVGSVGElement, SVGIconProps>( (props, ref) => { const { current: state } = React.useRef<SVGIconState>({ title: `svg-icon-title-${currentId}`, }); const { children, className, title, viewBox = "0 0 1024 1024" } = props; const hasTitle = Boolean(title); const classes = className ? `pf-v5-svg ${className}` : "pf-v5-svg"; useEffect(() => { currentId++; }, []); return ( <svg ref={ref} role="img" width="1em" height="1em" fill="currentColor" viewBox={viewBox} className={classes} {...(hasTitle && { ["aria-labelledby"]: title })} {...(!hasTitle && { ["aria-hidden"]: "true" })} {...props} > {hasTitle && <title id={state.title}>{title}</title>} {children} </svg> ); } ); SVGIcon.displayName = `SVGIcon`;
null
file
kubev2v/migration-planner-ui
8a3532e8-f096-424d-9005-3bffcb8db117
Root.tsx
[{'import_name': ['RouterProvider'], 'import_path': 'react-router-dom'}, {'import_name': ['Configuration'], 'import_path': '@migration-planner-ui/api-client/runtime'}, {'import_name': ['AgentApi', 'SourceApi'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Spinner'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Container', 'Provider', 'DependencyInjectionProvider'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['router'], 'import_path': './Router'}, {'import_name': ['Symbols'], 'import_path': './Symbols'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/main/Root.tsx
import "@patternfly/react-core/dist/styles/base.css"; import React from "react"; import ReactDOM from "react-dom/client"; import { RouterProvider } from "react-router-dom"; import { Configuration } from "@migration-planner-ui/api-client/runtime"; import { AgentApi, SourceApi } from "@migration-planner-ui/api-client/apis"; import { Spinner } from "@patternfly/react-core"; import { Container, Provider as DependencyInjectionProvider, } from "@migration-planner-ui/ioc"; import { router } from "./Router"; import { Symbols } from "./Symbols"; function getConfiguredContainer(): Container { const plannerApiConfig = new Configuration({ basePath: `/planner` }); const container = new Container(); container.register(Symbols.SourceApi, new SourceApi(plannerApiConfig)); container.register(Symbols.AgentApi, new AgentApi(plannerApiConfig)); //For UI testing we can use the mock Apis //container.register(Symbols.SourceApi, new MockSourceApi(plannerApiConfig)); //container.register(Symbols.AgentApi, new MockAgentApi(plannerApiConfig)); return container; } function main(): void { const root = document.getElementById("root"); if (root) { root.style.height = "inherit"; const container = getConfiguredContainer(); ReactDOM.createRoot(root).render( <React.StrictMode> <DependencyInjectionProvider container={container}> <React.Suspense fallback={<Spinner />}> <RouterProvider router={router} /> </React.Suspense> </DependencyInjectionProvider> </React.StrictMode> ); } } main();
null
function
kubev2v/migration-planner-ui
2b1f9c1d-731d-4114-b006-478239623221
getConfiguredContainer
[{'import_name': ['Configuration'], 'import_path': '@migration-planner-ui/api-client/runtime'}, {'import_name': ['AgentApi', 'SourceApi'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['Container'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['Symbols'], 'import_path': './Symbols'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/main/Root.tsx
function getConfiguredContainer(): Container { const plannerApiConfig = new Configuration({ basePath: `/planner` }); const container = new Container(); container.register(Symbols.SourceApi, new SourceApi(plannerApiConfig)); container.register(Symbols.AgentApi, new AgentApi(plannerApiConfig)); //For UI testing we can use the mock Apis //container.register(Symbols.SourceApi, new MockSourceApi(plannerApiConfig)); //container.register(Symbols.AgentApi, new MockAgentApi(plannerApiConfig)); return container; }
{}
function
kubev2v/migration-planner-ui
7b134b4e-5c43-4ee9-8ad8-a946973965eb
main
[{'import_name': ['RouterProvider'], 'import_path': 'react-router-dom'}, {'import_name': ['Spinner'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Container', 'Provider', 'DependencyInjectionProvider'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['router'], 'import_path': './Router'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/main/Root.tsx
function main(): void { const root = document.getElementById("root"); if (root) { root.style.height = "inherit"; const container = getConfiguredContainer(); ReactDOM.createRoot(root).render( <React.StrictMode> <DependencyInjectionProvider container={container}> <React.Suspense fallback={<Spinner />}> <RouterProvider router={router} /> </React.Suspense> </DependencyInjectionProvider> </React.StrictMode> ); } }
{}
file
kubev2v/migration-planner-ui
dd18169b-330a-4cdc-8103-f2d843a70573
Router.tsx
[{'import_name': ['createBrowserRouter', 'Navigate'], 'import_path': 'react-router-dom'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/main/Router.tsx
/* eslint-disable @typescript-eslint/explicit-function-return-type */ import { createBrowserRouter, Navigate } from "react-router-dom"; export const router = createBrowserRouter([ { path: "/", index: true, element: <Navigate to="/migrate" />, }, { path: "/migrate", lazy: async () => { const { default: MigrationAssessmentPage } = await import( "#/pages/MigrationAssessmentPage" ); return { Component: MigrationAssessmentPage, }; }, }, { path: "/migrate/wizard", lazy: async () => { const { default: MigrationWizardPage } = await import( "#/pages/MigrationWizardPage" ); return { Component: MigrationWizardPage, }; }, }, { path: "/ocm", lazy: async () => { const { default: OcmPreviewPage } = await import( "#/pages/OcmPreviewPage" ); return { Component: OcmPreviewPage, }; }, }, { path: "/error/:code", lazy: async () => { const { default: ErrorPage } = await import("../components/ErrorPage"); return { Component: ErrorPage, }; }, }, { path: "*", lazy: async () => { const { default: ErrorPage } = await import("../components/ErrorPage"); return { element: ( <ErrorPage code="404" message="We lost that page" actions={[ { children: "Go back", component: "a", onClick: (_event): void => { history.back(); }, }, ]} /> ), }; }, }, ]);
null
file
kubev2v/migration-planner-ui
e914179f-10fc-4e4a-ba39-7271a4541a23
Symbols.ts
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/main/Symbols.ts
/** Symbols used by the DI container */ export const Symbols = Object.freeze({ AgentApi: Symbol.for("AgentApi"), ImageApi: Symbol.for("ImageApi"), SourceApi: Symbol.for("SourceApi"), });
null
file
kubev2v/migration-planner-ui
4ba9aee3-7070-41f3-abdc-bf7804e4990b
MigrationWizard.tsx
[{'import_name': ['Button', 'useWizardContext', 'Wizard', 'WizardFooterWrapper', 'WizardStep'], 'import_path': '@patternfly/react-core'}, {'import_name': ['ConnectStep'], 'import_path': './steps/connect/ConnectStep'}, {'import_name': ['DiscoveryStep'], 'import_path': './steps/discovery/DiscoveryStep'}, {'import_name': ['useComputedHeightFromPageHeader'], 'import_path': './hooks/UseComputedHeightFromPageHeader'}, {'import_name': ['useDiscoverySources'], 'import_path': './contexts/discovery-sources/Context'}, {'import_name': ['PrepareMigrationStep'], 'import_path': './steps/prepare-migration/PrepareMigrationStep'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/MigrationWizard.tsx
import React from "react"; import { Button, useWizardContext, Wizard, WizardFooterWrapper, WizardStep, } from "@patternfly/react-core"; import { ConnectStep } from "./steps/connect/ConnectStep"; import { DiscoveryStep } from "./steps/discovery/DiscoveryStep"; import { useComputedHeightFromPageHeader } from "./hooks/UseComputedHeightFromPageHeader"; import { useDiscoverySources } from "./contexts/discovery-sources/Context"; import { PrepareMigrationStep } from "./steps/prepare-migration/PrepareMigrationStep"; const openAssistedInstaller = (): void => { window.open( "https://console.dev.redhat.com/openshift/assisted-installer/clusters/~new?source=assisted_migration", "_blank" ); }; type CustomWizardFooterPropType = { isCancelHidden?: boolean; isNextDisabled?: boolean; isBackDisabled?: boolean; nextButtonText?: string; onNext?: () => void; }; export const CustomWizardFooter: React.FC<CustomWizardFooterPropType> = ({ isCancelHidden, isBackDisabled, isNextDisabled, nextButtonText, onNext, }): JSX.Element => { const { goToNextStep, goToPrevStep, goToStepById } = useWizardContext(); return ( <> <WizardFooterWrapper> <Button ouiaId="wizard-back-btn" variant="secondary" onClick={goToPrevStep} isDisabled={isBackDisabled} > Back </Button> <Button ouiaId="wizard-next-btn" variant="primary" onClick={() => { if (onNext) { onNext(); } else { goToNextStep(); } }} isDisabled={isNextDisabled} > {nextButtonText ?? "Next"} </Button> {!isCancelHidden && ( <Button ouiaId="wizard-cancel-btn" variant="link" onClick={() => goToStepById("connect-step")} > Cancel </Button> )} </WizardFooterWrapper> </> ); }; export const MigrationWizard: React.FC = () => { const computedHeight = useComputedHeightFromPageHeader(); const discoverSourcesContext = useDiscoverySources(); const isDiscoverySourceUpToDate = discoverSourcesContext.agentSelected?.status === "up-to-date"; return ( <Wizard height={computedHeight}> <WizardStep name="Connect" id="connect-step" footer={ <CustomWizardFooter isCancelHidden={true} isNextDisabled={ !isDiscoverySourceUpToDate || discoverSourcesContext.sourceSelected === null } isBackDisabled={true} /> } > <ConnectStep /> </WizardStep> <WizardStep name="Discover" id="discover-step" footer={<CustomWizardFooter isCancelHidden={true} />} isDisabled={ discoverSourcesContext.agentSelected?.status !== "up-to-date" || discoverSourcesContext.sourceSelected === null } > <DiscoveryStep /> </WizardStep> <WizardStep name="Plan" id="plan-step" footer={ <CustomWizardFooter nextButtonText={"Let's create a new cluster"} onNext={openAssistedInstaller} /> } isDisabled={ discoverSourcesContext.agentSelected?.status !== "up-to-date" || discoverSourcesContext.sourceSelected === null } > <PrepareMigrationStep /> </WizardStep> </Wizard> ); }; MigrationWizard.displayName = "MigrationWizard";
null
function
kubev2v/migration-planner-ui
26195598-2a5d-426b-84eb-02a8dde4af2f
openAssistedInstaller
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/MigrationWizard.tsx
(): void => { window.open( "https://console.dev.redhat.com/openshift/assisted-installer/clusters/~new?source=assisted_migration", "_blank" ); }
{}
function
kubev2v/migration-planner-ui
cf790c57-ea63-405a-88a9-cddb06423319
CustomWizardFooter
[{'import_name': ['Button', 'useWizardContext', 'Wizard', 'WizardFooterWrapper'], 'import_path': '@patternfly/react-core'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/MigrationWizard.tsx
({ isCancelHidden, isBackDisabled, isNextDisabled, nextButtonText, onNext, }): JSX.Element => { const { goToNextStep, goToPrevStep, goToStepById } = useWizardContext(); return ( <> <WizardFooterWrapper> <Button ouiaId="wizard-back-btn" variant="secondary" onClick={goToPrevStep} isDisabled={isBackDisabled} > Back </Button> <Button ouiaId="wizard-next-btn" variant="primary" onClick={() => { if (onNext) { onNext(); } else { goToNextStep(); } }
{}
function
kubev2v/migration-planner-ui
170ca39d-babb-4d8d-911d-9d15be09a8cf
MigrationWizard
[{'import_name': ['Button', 'Wizard', 'WizardStep'], 'import_path': '@patternfly/react-core'}, {'import_name': ['ConnectStep'], 'import_path': './steps/connect/ConnectStep'}, {'import_name': ['DiscoveryStep'], 'import_path': './steps/discovery/DiscoveryStep'}, {'import_name': ['useComputedHeightFromPageHeader'], 'import_path': './hooks/UseComputedHeightFromPageHeader'}, {'import_name': ['useDiscoverySources'], 'import_path': './contexts/discovery-sources/Context'}, {'import_name': ['PrepareMigrationStep'], 'import_path': './steps/prepare-migration/PrepareMigrationStep'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/MigrationWizard.tsx
() => { const computedHeight = useComputedHeightFromPageHeader(); const discoverSourcesContext = useDiscoverySources(); const isDiscoverySourceUpToDate = discoverSourcesContext.agentSelected?.status === "up-to-date"; return ( <Wizard height={computedHeight}> <WizardStep name="Connect" id="connect-step" footer={ <CustomWizardFooter isCancelHidden={true} isNextDisabled={ !isDiscoverySourceUpToDate || discoverSourcesContext.sourceSelected === null } isBackDisabled={true} /> } > <ConnectStep /> </WizardStep> <WizardStep name="Discover" id="discover-step" footer={<CustomWizardFooter isCancelHidden={true} />} isDisabled={ discoverSourcesContext.agentSelected?.status !== "up-to-date" || discoverSourcesContext.sourceSelected === null } > <DiscoveryStep /> </WizardStep> <WizardStep name="Plan" id="plan-step" footer={ <CustomWizardFooter nextButtonText={"Let's create a new cluster"} onNext={openAssistedInstaller} /> } isDisabled={ discoverSourcesContext.agentSelected?.status !== "up-to-date" || discoverSourcesContext.sourceSelected === null } > <PrepareMigrationStep /> </WizardStep> </Wizard> ); }
{}
file
kubev2v/migration-planner-ui
a5d53c63-8584-4786-83ab-df515c354774
Context.ts
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/contexts/discovery-sources/Context.ts
import React from "react"; export const Context = React.createContext<DiscoverySources.Context | null>( null ); export function useDiscoverySources(): DiscoverySources.Context { const ctx = React.useContext(Context); if (!ctx) { throw new Error( "useDiscoverySources must be used within a <DiscoverySourceProvider />" ); } return ctx; }
null
function
kubev2v/migration-planner-ui
94fb68ed-adc4-4a7a-b907-afaa6a30f0be
useDiscoverySources
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/contexts/discovery-sources/Context.ts
function useDiscoverySources(): DiscoverySources.Context { const ctx = React.useContext(Context); if (!ctx) { throw new Error( "useDiscoverySources must be used within a <DiscoverySourceProvider />" ); } return ctx; }
{}
file
kubev2v/migration-planner-ui
53631520-7d13-4aaa-8755-4cf8997c3b80
Provider.tsx
[{'import_name': ['useCallback', 'useState', 'PropsWithChildren'], 'import_path': 'react'}, {'import_name': ['useAsyncFn', 'useInterval'], 'import_path': 'react-use'}, {'import_name': ['SourceApiInterface', 'AgentApiInterface'], 'import_path': '@migration-planner-ui/api-client/apis'}, {'import_name': ['useInjection'], 'import_path': '@migration-planner-ui/ioc'}, {'import_name': ['Symbols'], 'import_path': '#/main/Symbols'}, {'import_name': ['Context'], 'import_path': './Context'}, {'import_name': ['Agent', 'Source'], 'import_path': '@migration-planner-ui/api-client/models'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/contexts/discovery-sources/Provider.tsx
import React, { useCallback, useState, type PropsWithChildren, } from "react"; import { useAsyncFn, useInterval } from "react-use"; import { type SourceApiInterface, type AgentApiInterface } from "@migration-planner-ui/api-client/apis"; import { useInjection } from "@migration-planner-ui/ioc"; import { Symbols } from "#/main/Symbols"; import { Context } from "./Context"; import { Agent, Source } from "@migration-planner-ui/api-client/models"; export const Provider: React.FC<PropsWithChildren> = (props) => { const { children } = props; const [sourceSelected, setSourceSelected] = useState<Source | null>(null) const [agentSelected, setAgentSelected] = useState<Agent | null>(null) const sourceApi = useInjection<SourceApiInterface>(Symbols.SourceApi); const agentsApi = useInjection<AgentApiInterface>(Symbols.AgentApi); const [listAgentsState, listAgents] = useAsyncFn(async () => { const agents = await agentsApi.listAgents(); return agents; }); const [listSourcesState, listSources] = useAsyncFn(async () => { const sources = await sourceApi.listSources(); return sources; }); const [deleteSourceState, deleteSource] = useAsyncFn(async (id: string) => { const deletedSource = await sourceApi.deleteSource({ id }); return deletedSource; }); const [downloadSourceState, downloadSource] = useAsyncFn( async (sshKey:string): Promise<void> => { const anchor = document.createElement("a"); anchor.download = 'image.ova'; const imageUrl = `/planner/api/v1/image${sshKey ? '?sshKey=' + sshKey : ''}`; const response = await fetch(imageUrl, { method: 'HEAD' }); if (!response.ok) { const error: Error = new Error(`Error downloading source: ${response.status} ${response.statusText}`); downloadSourceState.error = error; console.error("Error downloading source:", error); throw error; } else { downloadSourceState.loading = true; } // TODO(jkilzi): See: ECOPROJECT-2192. // Then don't forget to remove the '/planner/' prefix in production. // const image = await sourceApi.getSourceImage({ id: newSource.id }); // This API is useless in production // anchor.href = URL.createObjectURL(image); // Don't do this... anchor.href = imageUrl; document.body.appendChild(anchor); anchor.click(); anchor.remove(); } ); const [isPolling, setIsPolling] = useState(false); const [pollingDelay, setPollingDelay] = useState<number | null>(null); const startPolling = useCallback( (delay: number) => { if (!isPolling) { setPollingDelay(delay); setIsPolling(true); } }, [isPolling] ); const stopPolling = useCallback(() => { if (isPolling) { setPollingDelay(null); setIsPolling(false); } }, [isPolling]); useInterval(() => { listSources(); listAgents(); }, pollingDelay); const selectSource = useCallback((source: Source|null) => { setSourceSelected(source); }, []); const selectSourceById = useCallback((sourceId: string) => { const source = listSourcesState.value?.find(source => source.id === sourceId); setSourceSelected(source||null); }, [listSourcesState.value]); const selectAgent = useCallback(async (agent: Agent) => { setAgentSelected(agent); if (agent && agent.sourceId!==null) await selectSourceById(agent.sourceId ?? ''); }, [selectSourceById]); const [deleteAgentState, deleteAgent] = useAsyncFn(async (agent: Agent) => { if (agent && agent.sourceId !== null) { await deleteSource(agent.sourceId ?? ''); selectSource(null); } const deletedAgent = await agentsApi.deleteAgent({id: agent.id}); return deletedAgent; }); const ctx: DiscoverySources.Context = { sources: listSourcesState.value ?? [], isLoadingSources: listSourcesState.loading, errorLoadingSources: listSourcesState.error, isDeletingSource: deleteSourceState.loading, errorDeletingSource: deleteSourceState.error, isDownloadingSource: downloadSourceState.loading, errorDownloadingSource: downloadSourceState.error, isPolling, listSources, deleteSource, downloadSource, startPolling, stopPolling, sourceSelected: sourceSelected, selectSource, agents: listAgentsState.value ?? [], isLoadingAgents: listAgentsState.loading, errorLoadingAgents: listAgentsState.error, listAgents, deleteAgent, isDeletingAgent: deleteAgentState.loading, errorDeletingAgent: deleteAgentState.error, selectAgent, agentSelected: agentSelected, selectSourceById }; return <Context.Provider value={ctx}>{children}</Context.Provider>; }; Provider.displayName = "DiscoverySourcesProvider";
null
file
kubev2v/migration-planner-ui
b18521ec-ed20-4805-a595-c3e840e46623
DiscoverySources.d.ts
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/contexts/discovery-sources/@types/DiscoverySources.d.ts
declare namespace DiscoverySources { type Context = { sources: Source[]; isLoadingSources: boolean; errorLoadingSources?: Error; isDeletingSource: boolean; errorDeletingSource?: Error; isDownloadingSource: boolean; errorDownloadingSource?: Error; isPolling: boolean; sourceSelected: Source; listSources: () => Promise<Source[]>; deleteSource: (id: string) => Promise<Source>; downloadSource: (sourceSshKey: string) => Promise<void>; startPolling: (delay: number) => void; stopPolling: () => void; selectSource: (source:Source) => void; agents: Agent[]|undefined; isLoadingAgents: boolean; errorLoadingAgents?: Error; listAgents: () => Promise<Agent[]>; deleteAgent: (agent: Agent) => Promise<Agent>; isDeletingAgent: boolean; errorDeletingAgent?: Error; selectAgent: (agent:Agent) => void; agentSelected: Agent; selectSourceById: (sourceId:string)=>void; }; }
null
file
kubev2v/migration-planner-ui
531c1dcf-1fcd-4f1b-8ef9-b07d063852c2
UseComputedHeightFromPageHeader.ts
[{'import_name': ['useState', 'useEffect'], 'import_path': 'react'}, {'import_name': ['useWindowSize'], 'import_path': 'react-use'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/hooks/UseComputedHeightFromPageHeader.ts
import { useState, useEffect } from "react"; import { useWindowSize } from "react-use"; const DEFAULT_HEIGHT = 635; function getMainPageSectionVerticalPadding(pageMainSection: Element): number { const { paddingTop, paddingBottom } = getComputedStyle(pageMainSection); const value = parseFloat(paddingTop.slice(0, -2)) + parseFloat(paddingBottom.slice(0, -2)); return value; } export function useComputedHeightFromPageHeader(): number { const { height: windowInnerHeight } = useWindowSize(); const [height, setHeight] = useState(DEFAULT_HEIGHT); useEffect(() => { const basePageHeader = document.getElementById("base-page__header"); if (basePageHeader) { const pageMainSection = basePageHeader.nextElementSibling; if (pageMainSection) { const mainPageSectionVerticalPadding = getMainPageSectionVerticalPadding(pageMainSection); const { height: basePageHeaderHeight } = basePageHeader.getBoundingClientRect(); setHeight( windowInnerHeight - basePageHeaderHeight - mainPageSectionVerticalPadding ); } } }, [windowInnerHeight]); return height; }
null
function
kubev2v/migration-planner-ui
22e53c4b-62c7-4602-8fd4-948a79ffb1d3
getMainPageSectionVerticalPadding
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/hooks/UseComputedHeightFromPageHeader.ts
function getMainPageSectionVerticalPadding(pageMainSection: Element): number { const { paddingTop, paddingBottom } = getComputedStyle(pageMainSection); const value = parseFloat(paddingTop.slice(0, -2)) + parseFloat(paddingBottom.slice(0, -2)); return value; }
{}
function
kubev2v/migration-planner-ui
2b50400c-d7fe-4841-ab9c-724397f4acaf
useComputedHeightFromPageHeader
[{'import_name': ['useState', 'useEffect'], 'import_path': 'react'}, {'import_name': ['useWindowSize'], 'import_path': 'react-use'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/hooks/UseComputedHeightFromPageHeader.ts
function useComputedHeightFromPageHeader(): number { const { height: windowInnerHeight } = useWindowSize(); const [height, setHeight] = useState(DEFAULT_HEIGHT); useEffect(() => { const basePageHeader = document.getElementById("base-page__header"); if (basePageHeader) { const pageMainSection = basePageHeader.nextElementSibling; if (pageMainSection) { const mainPageSectionVerticalPadding = getMainPageSectionVerticalPadding(pageMainSection); const { height: basePageHeaderHeight } = basePageHeader.getBoundingClientRect(); setHeight( windowInnerHeight - basePageHeaderHeight - mainPageSectionVerticalPadding ); } } }, [windowInnerHeight]); return height; }
{}
file
kubev2v/migration-planner-ui
512c81b1-8ca2-4567-9c88-49fb5778613c
ConnectStep.tsx
[{'import_name': ['useCallback', 'useEffect', 'useState'], 'import_path': 'react'}, {'import_name': ['Stack', 'StackItem', 'TextContent', 'Text', 'Panel', 'PanelMain', 'PanelHeader', 'List', 'OrderType', 'ListItem', 'Icon', 'Alert', 'Button'], 'import_path': '@patternfly/react-core'}, {'import_name': ['chart_color_blue_300', 'blueColor'], 'import_path': '@patternfly/react-tokens/dist/esm/chart_color_blue_300'}, {'import_name': ['ClusterIcon', 'PlusCircleIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['SourcesTable'], 'import_path': '#/migration-wizard/steps/connect/sources-table/SourcesTable'}, {'import_name': ['useDiscoverySources'], 'import_path': '#/migration-wizard/contexts/discovery-sources/Context'}, {'import_name': ['DiscoverySourceSetupModal'], 'import_path': './sources-table/empty-state/DiscoverySourceSetupModal'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/ConnectStep.tsx
import React, { useCallback, useEffect, useState } from "react"; import { Stack, StackItem, TextContent, Text, Panel, PanelMain, PanelHeader, List, OrderType, ListItem, Icon, Alert, Button, } from "@patternfly/react-core"; import { chart_color_blue_300 as blueColor } from "@patternfly/react-tokens/dist/esm/chart_color_blue_300"; import { ClusterIcon, PlusCircleIcon } from "@patternfly/react-icons"; import { SourcesTable } from "#/migration-wizard/steps/connect/sources-table/SourcesTable"; import { useDiscoverySources } from "#/migration-wizard/contexts/discovery-sources/Context"; import { DiscoverySourceSetupModal } from "./sources-table/empty-state/DiscoverySourceSetupModal"; export const ConnectStep: React.FC = () => { const discoverySourcesContext = useDiscoverySources(); const [ shouldShowDiscoverySourceSetupModal, setShouldShowDiscoverySetupModal, ] = useState(false); const toggleDiscoverySourceSetupModal = useCallback((): void => { setShouldShowDiscoverySetupModal((lastState) => !lastState); }, []); const hasAgents = discoverySourcesContext.agents && discoverySourcesContext.agents.length > 0; const [firstAgent, ..._otherAgents] = discoverySourcesContext.agents || []; useEffect(() => { if (!discoverySourcesContext.agentSelected && firstAgent) { discoverySourcesContext.selectAgent(firstAgent); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [firstAgent]); return ( <Stack hasGutter> <StackItem> <TextContent> <Text component="h2">Connect your VMware environment</Text> </TextContent> </StackItem> <StackItem> <TextContent style={{ paddingBlock: "1rem" }}> <Text component="h4"> Follow these steps to connect your environment and start the discovery process </Text> <List component="ol" type={OrderType.number} style={{ marginInlineStart: 0 }} > <ListItem> To add a new source download and import a discovery OVA file to your VMware environment. </ListItem> <ListItem> A link will appear below once the VM is running. Use this link to enter credentials and connect your environment. </ListItem> <ListItem> When the connection is established, you will be able to proceed and see the discovery report. </ListItem> </List> </TextContent> </StackItem> <StackItem> <Panel variant="bordered"> <PanelMain> <PanelHeader style={{ paddingBlockEnd: 0 }}> <TextContent> <Text component="h3"> <Icon isInline style={{ marginRight: "1rem" }}> <ClusterIcon /> </Icon> Environment </Text> </TextContent> </PanelHeader> <SourcesTable /> </PanelMain> </Panel> </StackItem> <StackItem> {hasAgents && ( <Button variant="secondary" onClick={toggleDiscoverySourceSetupModal} style={{ marginTop: "1rem" }} icon={<PlusCircleIcon color={blueColor.value} />} > Add source </Button> )} {shouldShowDiscoverySourceSetupModal && ( <DiscoverySourceSetupModal isOpen={shouldShowDiscoverySourceSetupModal} onClose={toggleDiscoverySourceSetupModal} isDisabled={discoverySourcesContext.isDownloadingSource} onSubmit={async (event) => { const form = event.currentTarget; const sshKey = form["discoverySourceSshKey"].value as string; await discoverySourcesContext.downloadSource(sshKey); toggleDiscoverySourceSetupModal(); //await discoverySourcesContext.listSources(); await discoverySourcesContext.listAgents(); }} /> )} </StackItem> <StackItem> {discoverySourcesContext.isDownloadingSource && ( <Alert isInline variant="info" title="Download OVA image"> The OVA image is downloading </Alert> )} </StackItem> <StackItem> {discoverySourcesContext.errorDownloadingSource && ( <Alert isInline variant="danger" title="Download Source error"> {discoverySourcesContext.errorDownloadingSource.message} </Alert> )} </StackItem> </Stack> ); }; ConnectStep.displayName = "ConnectStep";
null
file
kubev2v/migration-planner-ui
1a6688d7-19c3-4fbb-bfe0-a03ca9d8f98b
Columns.ts
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/Columns.ts
export const enum Columns { CredentialsUrl = "Credentials URL", Status = "Status", Hosts = "Hosts", VMs = "VMs", Networks = "Networks", Datastores = "Datastores", Actions = "Actions", }
null
file
kubev2v/migration-planner-ui
de377a6a-ec2e-4759-9398-e8612eff5fb9
Constants.ts
[{'import_name': ['Time'], 'import_path': '#/common/Time'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/Constants.ts
import { Time } from "#/common/Time"; export const VALUE_NOT_AVAILABLE = "-"; export const DEFAULT_POLLING_DELAY = 3 * Time.Second;
null
file
kubev2v/migration-planner-ui
b44e42bf-4a31-4693-983f-59f4b7e3b1d9
SourceStatusView.tsx
[{'import_name': ['useMemo'], 'import_path': 'react'}, {'import_name': ['Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['Button', 'Icon', 'Popover', 'Spinner', 'Split', 'SplitItem', 'TextContent', 'Text'], 'import_path': '@patternfly/react-core'}, {'import_name': ['DisconnectedIcon', 'ExclamationCircleIcon', 'CheckCircleIcon', 'InfoCircleIcon'], 'import_path': '@patternfly/react-icons'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/SourceStatusView.tsx
import React, { useMemo } from "react"; import type { Source } from "@migration-planner-ui/api-client/models"; import { Button, Icon, Popover, Spinner, Split, SplitItem, TextContent, Text, } from "@patternfly/react-core"; import { DisconnectedIcon, ExclamationCircleIcon, CheckCircleIcon, InfoCircleIcon, } from "@patternfly/react-icons"; import globalDangerColor200 from "@patternfly/react-tokens/dist/esm/global_danger_color_200"; import globalInfoColor100 from "@patternfly/react-tokens/dist/esm/global_info_color_100"; import globalSuccessColor100 from "@patternfly/react-tokens/dist/esm/global_success_color_100"; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace SourceStatusView { export type Props = { status: Source["status"]; statusInfo?: Source["statusInfo"]; }; } export const SourceStatusView: React.FC<SourceStatusView.Props> = (props) => { const { status, statusInfo } = props; const statusView = useMemo(() => { // eslint-disable-next-line prefer-const let fake: Source['status'] | null = null; // fake = "not-connected"; // fake = "waiting-for-credentials"; // fake = "gathering-initial-inventory"; // fake = "up-to-date"; // fake = "error"; switch (fake ?? status) { case "not-connected": return { icon: ( <Icon isInline> <DisconnectedIcon /> </Icon> ), text: "Not connected", }; case "waiting-for-credentials": return { icon: ( <Icon size="md" isInline> <InfoCircleIcon color={globalInfoColor100.value} /> </Icon> ), text: "Waiting for credentials", }; case "gathering-initial-inventory": return { icon: ( <Icon size="md" isInline> <Spinner /> </Icon> ), text: "Gathering inventory", }; case "error": return { icon: ( <Icon size="md" isInline> <ExclamationCircleIcon color={globalDangerColor200.value} /> </Icon> ), text: "Error", }; case "up-to-date": return { icon: ( <Icon size="md" isInline> <CheckCircleIcon color={globalSuccessColor100.value} /> </Icon> ), text: "Up to date", }; } }, [status]); return ( <Split hasGutter style={{ gap: "0.66rem" }}> <SplitItem>{statusView.icon}</SplitItem> <SplitItem> {statusInfo ? ( <Popover aria-label={statusView.text} headerContent={statusView.text} headerComponent="h1" bodyContent={ <TextContent> <Text>{statusInfo}</Text> </TextContent> } > <Button variant="link" isInline> {statusView.text} </Button> </Popover> ) : ( statusView.text )} </SplitItem> </Split> ); }; SourceStatusView.displayName = "SourceStatusView";
null
file
kubev2v/migration-planner-ui
bf364668-430c-421d-8fad-49c737ffabb6
SourcesTable.tsx
[{'import_name': ['useEffect'], 'import_path': 'react'}, {'import_name': ['useMount', 'useUnmount'], 'import_path': 'react-use'}, {'import_name': ['Table', 'Thead', 'Tr', 'Th', 'Tbody', 'Td'], 'import_path': '@patternfly/react-table'}, {'import_name': ['EmptyState'], 'import_path': './empty-state/EmptyState'}, {'import_name': ['RemoveSourceAction'], 'import_path': './actions/RemoveSourceAction'}, {'import_name': ['Columns'], 'import_path': './Columns'}, {'import_name': ['DEFAULT_POLLING_DELAY', 'VALUE_NOT_AVAILABLE'], 'import_path': './Constants'}, {'import_name': ['SourceStatusView'], 'import_path': './SourceStatusView'}, {'import_name': ['useDiscoverySources'], 'import_path': '#/migration-wizard/contexts/discovery-sources/Context'}, {'import_name': ['Radio', 'Spinner'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Link'], 'import_path': 'react-router-dom'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/SourcesTable.tsx
import React, { useEffect } from "react"; import { useMount, useUnmount } from "react-use"; import { Table, Thead, Tr, Th, Tbody, Td } from "@patternfly/react-table"; import { EmptyState } from "./empty-state/EmptyState"; import { RemoveSourceAction } from "./actions/RemoveSourceAction"; import { Columns } from "./Columns"; import { DEFAULT_POLLING_DELAY, VALUE_NOT_AVAILABLE } from "./Constants"; import { SourceStatusView } from "./SourceStatusView"; import { useDiscoverySources } from "#/migration-wizard/contexts/discovery-sources/Context"; import { Radio, Spinner } from "@patternfly/react-core"; import { Link } from "react-router-dom"; export const SourcesTable: React.FC = () => { const discoverySourcesContext = useDiscoverySources(); const hasAgents = discoverySourcesContext.agents && discoverySourcesContext.agents.length > 0; const [firstAgent, ..._otherAgents] = discoverySourcesContext.agents ?? []; useMount(async () => { if (!discoverySourcesContext.isPolling) { await Promise.all([ discoverySourcesContext.listSources(), discoverySourcesContext.listAgents() ]); } }); useUnmount(() => { discoverySourcesContext.stopPolling(); }); useEffect(() => { if ( ["error", "up-to-date"].includes( discoverySourcesContext.agentSelected?.status ) ) { discoverySourcesContext.stopPolling(); return; } else { discoverySourcesContext.startPolling(DEFAULT_POLLING_DELAY); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [discoverySourcesContext.agentSelected?.status]); if ( (discoverySourcesContext.agentSelected === undefined || discoverySourcesContext.sourceSelected === undefined) && !(discoverySourcesContext.agentSelected?.length === 0 || discoverySourcesContext.sourceSelected?.length === 0) ) { return <Spinner />; // Loading agent and source } return ( <Table aria-label="Sources table" variant="compact" borders={false}> {hasAgents && ( <Thead> <Tr> <Th>{Columns.CredentialsUrl}</Th> <Th>{Columns.Status}</Th> <Th>{Columns.Hosts}</Th> <Th>{Columns.VMs}</Th> <Th>{Columns.Networks}</Th> <Th>{Columns.Datastores}</Th> <Th>{Columns.Actions}</Th> </Tr> </Thead> )} <Tbody> {hasAgents ? ( discoverySourcesContext.agents && discoverySourcesContext.agents.map((agent) => { const source = discoverySourcesContext.sourceSelected; return( <Tr key={agent.id}> <Td dataLabel={Columns.CredentialsUrl}> {" "} <Radio id={agent.id} name="source-selection" label={ agent.credentialUrl !== "Example report" ? ( <Link to={agent.credentialUrl} target="_blank"> {agent.credentialUrl} </Link> ) : ( agent.credentialUrl ) } isChecked={ discoverySourcesContext.agentSelected ? discoverySourcesContext.agentSelected?.id === agent.id : firstAgent.id === agent.id } onChange={() => discoverySourcesContext.selectAgent(agent)} /> </Td> <Td dataLabel={Columns.Status}> <SourceStatusView status={agent.status} statusInfo={agent.statusInfo} /> </Td> <Td dataLabel={Columns.Hosts}> {source!==null && source.inventory?.infra.totalHosts || VALUE_NOT_AVAILABLE} </Td> <Td dataLabel={Columns.VMs}> {source!==null && source.inventory?.vms.total || VALUE_NOT_AVAILABLE} </Td> <Td dataLabel={Columns.Networks}> {((source!==null && source.inventory?.infra.networks) ?? []).length || VALUE_NOT_AVAILABLE} </Td> <Td dataLabel={Columns.Datastores}> {((source!==null && source.inventory?.infra.datastores) ?? []).length || VALUE_NOT_AVAILABLE} </Td> <Td dataLabel={Columns.Actions}> {agent.credentialUrl !== "Example report" && (<RemoveSourceAction sourceId={agent.id} isDisabled={discoverySourcesContext.isDeletingSource} onConfirm={async (event) => { event.stopPropagation(); await discoverySourcesContext.deleteAgent(agent); event.dismissConfirmationModal(); await discoverySourcesContext.listAgents(); await discoverySourcesContext.listSources(); }} />)} </Td> </Tr> )}) ) : ( <Tr> <Td colSpan={12}> <EmptyState /> </Td> </Tr> )} </Tbody> </Table> ); }; SourcesTable.displayName = "SourcesTable";
null
file
kubev2v/migration-planner-ui
0a92d9a2-9079-4cd9-aa60-833a804dcdf8
RemoveSourceAction.tsx
[{'import_name': ['useCallback', 'useState'], 'import_path': 'react'}, {'import_name': ['Tooltip', 'Button', 'Icon', 'TextContent', 'Text'], 'import_path': '@patternfly/react-core'}, {'import_name': ['TrashIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['ConfirmationModal'], 'import_path': '#/components/ConfirmationModal'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/actions/RemoveSourceAction.tsx
import React, { useCallback, useState } from "react"; import { Tooltip, Button, Icon, TextContent, Text, } from "@patternfly/react-core"; import { TrashIcon } from "@patternfly/react-icons"; import { ConfirmationModal } from "#/components/ConfirmationModal"; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace RemoveSourceAction { export type ConfirmEventHandler = ( event: React.MouseEvent<HTMLButtonElement, MouseEvent> & { dismissConfirmationModal: () => void; showConfirmationModal: () => void; } ) => void; export type Props = { sourceId: string; isDisabled: boolean; onConfirm?: ConfirmEventHandler; }; } export const RemoveSourceAction: React.FC<RemoveSourceAction.Props> = ( props ) => { const { sourceId, isDisabled = false, onConfirm } = props; const [shouldShowConfirmationModal, setShouldShowConfirmationModal] = useState(false); const dismissConfirmationModal = useCallback((): void => { setShouldShowConfirmationModal(false); }, []); const showConfirmationModal = useCallback((): void => { setShouldShowConfirmationModal(true); }, []); const handleConfirm = useCallback<RemoveSourceAction.ConfirmEventHandler>( (event) => { if (onConfirm) { event.dismissConfirmationModal = dismissConfirmationModal; onConfirm(event); } }, [dismissConfirmationModal, onConfirm] ); return ( <> <Tooltip content="Remove"> <Button data-source-id={sourceId} variant="plain" isDisabled={isDisabled} onClick={showConfirmationModal} > <Icon size="md" isInline> <TrashIcon /> </Icon> </Button> </Tooltip> {onConfirm && shouldShowConfirmationModal && ( <ConfirmationModal title="Remove discovery source?" titleIconVariant="warning" primaryButtonVariant="danger" isOpen={shouldShowConfirmationModal} isDisabled={isDisabled} onCancel={dismissConfirmationModal} onConfirm={handleConfirm} > <TextContent> <Text id="confirmation-modal-description"> The discovery information will be lost. </Text> </TextContent> </ConfirmationModal> )} </> ); }; RemoveSourceAction.displayName = "RemoveSourceAction";
null
file
kubev2v/migration-planner-ui
3da3597c-dd30-4696-829f-0a2b21f1402a
DiscoverySourceSetupModal.tsx
[{'import_name': ['useCallback', 'useState'], 'import_path': 'react'}, {'import_name': ['Button', 'Form', 'FormGroup', 'FormHelperText', 'HelperText', 'HelperTextItem', 'TextArea'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Modal', 'ModalBody', 'ModalFooter', 'ModalHeader'], 'import_path': '@patternfly/react-core/next'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/empty-state/DiscoverySourceSetupModal.tsx
import React, { useCallback, useState } from "react"; import { Button, Form, FormGroup, FormHelperText, HelperText, HelperTextItem, TextArea, } from "@patternfly/react-core"; import { Modal, ModalBody, ModalFooter, ModalHeader, } from "@patternfly/react-core/next"; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace DiscoverySourceSetupModal { export type Props = { isOpen?: boolean; isDisabled?: boolean; onClose?: ((event: KeyboardEvent | React.MouseEvent) => void) | undefined; onSubmit: React.FormEventHandler<HTMLFormElement> | undefined; }; } export const DiscoverySourceSetupModal: React.FC< DiscoverySourceSetupModal.Props > = (props) => { const { isOpen = false, isDisabled = false, onClose, onSubmit } = props; const [sshKey, setSshKey] = useState(""); const [sshKeyError, setSshKeyError] = useState<string | null>(null); const validateSshKey = useCallback((key: string): string | null => { // SSH key validation regex patterns const SSH_KEY_PATTERNS = { RSA: /^ssh-rsa\s+[A-Za-z0-9+/]+[=]{0,2}(\s+.*)?$/, ED25519: /^ssh-ed25519\s+[A-Za-z0-9+/]+[=]{0,2}(\s+.*)?$/, ECDSA: /^ssh-(ecdsa|sk-ecdsa)-sha2-nistp[0-9]+\s+[A-Za-z0-9+/]+[=]{0,2}(\s+.*)?$/, }; // Optional field, so empty is valid if (!key) return null; // Check if the key matches any of the known SSH key formats const isValidKey = Object.values(SSH_KEY_PATTERNS).some(pattern => pattern.test(key.trim())); return isValidKey ? null : "Invalid SSH key format. Please provide a valid SSH public key."; }, []); const handleSshKeyChange = (value: string): void => { setSshKey(value); setSshKeyError(validateSshKey(value)); }; const handleSubmit = useCallback<React.FormEventHandler<HTMLFormElement>>( (event) => { event.preventDefault(); // Validate SSH key before submission const keyValidationError = validateSshKey(sshKey); if (keyValidationError) { setSshKeyError(keyValidationError); return; } if (onSubmit) { onSubmit(event); } }, [onSubmit, sshKey, validateSshKey] ); return ( <Modal variant="small" isOpen={isOpen} onClose={onClose} ouiaId="DiscoverySourceSetupModal" aria-labelledby="discovery-source-setup-modal-title" aria-describedby="modal-box-body-discovery-source-setup" > <ModalHeader title="Discovery source setup" labelId="discovery-source-setup-modal-title" /> <ModalBody id="modal-box-body-discovery-source-setup"> <Form noValidate={false} id="discovery-source-setup-form" onSubmit={handleSubmit} > <FormGroup label="SSH Key" fieldId="discovery-source-sshkey-form-control" > <TextArea id="discovery-source-sshkey-form-control" name="discoverySourceSshKey" value={sshKey} onChange={(_, value) => handleSshKeyChange(value)} type="text" placeholder="Example: ssh-rsa AAAAB3NzaC1yc2E..." aria-describedby="sshkey-helper-text" validated={sshKeyError ? 'error' : 'default'} /> <FormHelperText> <HelperText> <HelperTextItem variant={sshKeyError ? 'error' : 'default'} id="sshkey-helper-text"> {sshKeyError || "Enter your SSH public key for the 'core' user to enable SSH access to the OVA image."} </HelperTextItem> </HelperText> </FormHelperText> </FormGroup> </Form> </ModalBody> <ModalFooter> <Button form="discovery-source-setup-form" type="submit" key="confirm" variant="primary" isDisabled={isDisabled || !!sshKeyError} > Download OVA Image </Button> </ModalFooter> </Modal> ); }; DiscoverySourceSetupModal.displayName = "DiscoverySourceSetupModal";
null
function
kubev2v/migration-planner-ui
de415566-16d0-465f-a5f9-de5c932733f1
DiscoverySourceSetupModal
[{'import_name': ['useCallback', 'useState'], 'import_path': 'react'}, {'import_name': ['Button', 'Form', 'FormGroup', 'FormHelperText', 'HelperText', 'HelperTextItem', 'TextArea'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Modal', 'ModalBody', 'ModalFooter', 'ModalHeader'], 'import_path': '@patternfly/react-core/next'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/empty-state/DiscoverySourceSetupModal.tsx
(props) => { const { isOpen = false, isDisabled = false, onClose, onSubmit } = props; const [sshKey, setSshKey] = useState(""); const [sshKeyError, setSshKeyError] = useState<string | null>(null); const validateSshKey = useCallback((key: string): string | null => { // SSH key validation regex patterns const SSH_KEY_PATTERNS = { RSA: /^ssh-rsa\s+[A-Za-z0-9+/]+[=]{0,2}(\s+.*)?$/, ED25519: /^ssh-ed25519\s+[A-Za-z0-9+/]+[=]{0,2}(\s+.*)?$/, ECDSA: /^ssh-(ecdsa|sk-ecdsa)-sha2-nistp[0-9]+\s+[A-Za-z0-9+/]+[=]{0,2}(\s+.*)?$/, }; // Optional field, so empty is valid if (!key) return null; // Check if the key matches any of the known SSH key formats const isValidKey = Object.values(SSH_KEY_PATTERNS).some(pattern => pattern.test(key.trim())); return isValidKey ? null : "Invalid SSH key format. Please provide a valid SSH public key."; }, []); const handleSshKeyChange = (value: string): void => { setSshKey(value); setSshKeyError(validateSshKey(value)); }; const handleSubmit = useCallback<React.FormEventHandler<HTMLFormElement>>( (event) => { event.preventDefault(); // Validate SSH key before submission const keyValidationError = validateSshKey(sshKey); if (keyValidationError) { setSshKeyError(keyValidationError); return; } if (onSubmit) { onSubmit(event); } }, [onSubmit, sshKey, validateSshKey] ); return ( <Modal variant="small" isOpen={isOpen} onClose={onClose} ouiaId="DiscoverySourceSetupModal" aria-labelledby="discovery-source-setup-modal-title" aria-describedby="modal-box-body-discovery-source-setup" > <ModalHeader title="Discovery source setup" labelId="discovery-source-setup-modal-title" /> <ModalBody id="modal-box-body-discovery-source-setup"> <Form noValidate={false} id="discovery-source-setup-form" onSubmit={handleSubmit} > <FormGroup label="SSH Key" fieldId="discovery-source-sshkey-form-control" > <TextArea id="discovery-source-sshkey-form-control" name="discoverySourceSshKey" value={sshKey} onChange={(_, value) => handleSshKeyChange(value)} type="text" placeholder="Example: ssh-rsa AAAAB3NzaC1yc2E..." aria-describedby="sshkey-helper-text" validated={sshKeyError ? 'error' : 'default'} /> <FormHelperText> <HelperText> <HelperTextItem variant={sshKeyError ? 'error' : 'default'} id="sshkey-helper-text"> {sshKeyError || "Enter your SSH public key for the 'core' user to enable SSH access to the OVA image."} </HelperTextItem> </HelperText> </FormHelperText> </FormGroup> </Form> </ModalBody> <ModalFooter> <Button form="discovery-source-setup-form" type="submit" key="confirm" variant="primary" isDisabled={isDisabled || !!sshKeyError} > Download OVA Image </Button> </ModalFooter> </Modal> ); }
{}
file
kubev2v/migration-planner-ui
a2d958bd-e832-4f0f-abc9-a24cb4694c12
EmptyState.tsx
[{'import_name': ['useCallback', 'useState'], 'import_path': 'react'}, {'import_name': ['Button', 'EmptyState', 'PFEmptyState', 'EmptyStateActions', 'EmptyStateBody', 'EmptyStateFooter', 'EmptyStateHeader', 'EmptyStateIcon'], 'import_path': '@patternfly/react-core'}, {'import_name': ['ExclamationCircleIcon', 'SearchIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['useDiscoverySources'], 'import_path': '#/migration-wizard/contexts/discovery-sources/Context'}, {'import_name': ['DiscoverySourceSetupModal'], 'import_path': './DiscoverySourceSetupModal'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/connect/sources-table/empty-state/EmptyState.tsx
import React, { useCallback, useState } from "react"; import { Button, EmptyState as PFEmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter, EmptyStateHeader, EmptyStateIcon, } from "@patternfly/react-core"; import { ExclamationCircleIcon, SearchIcon } from "@patternfly/react-icons"; import globalDangerColor200 from "@patternfly/react-tokens/dist/esm/global_danger_color_200"; import { useDiscoverySources } from "#/migration-wizard/contexts/discovery-sources/Context"; import { DiscoverySourceSetupModal } from "./DiscoverySourceSetupModal"; export const EmptyState: React.FC = () => { const discoverySourcesContext = useDiscoverySources(); const [ shouldShowDiscoverySourceSetupModal, setShouldShowDiscoverySetupModal, ] = useState(false); const toggleDiscoverySourceSetupModal = useCallback((): void => { setShouldShowDiscoverySetupModal((lastState) => !lastState); }, []); const handleTryAgain = useCallback(() => { if (!discoverySourcesContext.isLoadingAgents) { //discoverySourcesContext.listSources(); discoverySourcesContext.listAgents(); } }, [discoverySourcesContext]); let emptyStateNode: React.ReactNode = ( <PFEmptyState variant="sm"> <EmptyStateHeader titleText="No discovery source found" headingLevel="h4" icon={<EmptyStateIcon icon={SearchIcon} />} /> <EmptyStateBody> Begin by creating a discovery source. Then download and import the OVA file into your VMware environment. </EmptyStateBody> <EmptyStateFooter> <EmptyStateActions> <Button variant="secondary" onClick={toggleDiscoverySourceSetupModal} > Create </Button> </EmptyStateActions> </EmptyStateFooter> </PFEmptyState> ); if (discoverySourcesContext.errorLoadingSources) { emptyStateNode = ( <PFEmptyState variant="sm"> <EmptyStateHeader titleText="Something went wrong..." headingLevel="h4" icon={ <EmptyStateIcon icon={ExclamationCircleIcon} color={globalDangerColor200.value} /> } /> <EmptyStateBody> An error occurred while attempting to detect existing discovery sources </EmptyStateBody> <EmptyStateFooter> <EmptyStateActions> <Button variant="link" onClick={handleTryAgain}> Try again </Button> </EmptyStateActions> </EmptyStateFooter> </PFEmptyState> ); } return ( <> {emptyStateNode} {shouldShowDiscoverySourceSetupModal && ( <DiscoverySourceSetupModal isOpen={shouldShowDiscoverySourceSetupModal} onClose={toggleDiscoverySourceSetupModal} isDisabled={discoverySourcesContext.isDownloadingSource} onSubmit={async (event) => { const form = event.currentTarget; const sshKey = form["discoverySourceSshKey"].value as string; await discoverySourcesContext.downloadSource(sshKey); toggleDiscoverySourceSetupModal(); await discoverySourcesContext.listAgents(); }} /> )} </> ); }; EmptyState.displayName = "SourcesTableEmptyState";
null
file
kubev2v/migration-planner-ui
1d459358-0817-4b8f-80b4-90ae95c998d1
DiscoveryStep.tsx
[{'import_name': ['Stack', 'StackItem', 'Icon', 'Text', 'TextContent', 'TreeView', 'TreeViewDataItem', 'Badge', 'Flex', 'FlexItem', 'Progress'], 'import_path': '@patternfly/react-core'}, {'import_name': ['CogsIcon', 'DatabaseIcon', 'ExclamationCircleIcon', 'ExclamationTriangleIcon', 'HddIcon', 'InfrastructureIcon', 'MicrochipIcon', 'NetworkIcon', 'VirtualMachineIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['InfraDatastoresInner', 'InfraNetworksInner', 'MigrationIssuesInner', 'Source'], 'import_path': '@migration-planner-ui/api-client/models'}, {'import_name': ['useDiscoverySources'], 'import_path': '#/migration-wizard/contexts/discovery-sources/Context'}, {'import_name': ['ReportTable'], 'import_path': './ReportTable'}, {'import_name': ['ReportPieChart'], 'import_path': './ReportPieChart'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/DiscoveryStep.tsx
import React from "react"; import Humanize from "humanize-plus"; import { Stack, StackItem, Icon, Text, TextContent, TreeView, TreeViewDataItem, Badge, Flex, FlexItem, Progress, } from "@patternfly/react-core"; import { CogsIcon, DatabaseIcon, ExclamationCircleIcon, ExclamationTriangleIcon, HddIcon, InfrastructureIcon, MicrochipIcon, NetworkIcon, VirtualMachineIcon, } from "@patternfly/react-icons"; import globalWarningColor100 from "@patternfly/react-tokens/dist/esm/global_warning_color_100"; import globalDangerColor100 from "@patternfly/react-tokens/dist/esm/global_danger_color_100"; import type { InfraDatastoresInner, InfraNetworksInner, MigrationIssuesInner, Source, } from "@migration-planner-ui/api-client/models"; import { useDiscoverySources } from "#/migration-wizard/contexts/discovery-sources/Context"; import { ReportTable } from "./ReportTable"; import { ReportPieChart } from "./ReportPieChart"; export const DiscoveryStep: React.FC = () => { const discoverSourcesContext = useDiscoverySources(); const { inventory } = discoverSourcesContext.sourceSelected as Source; const { infra, vms } = inventory!; const { datastores, networks, } = infra; const { cpuCores, ramGB, diskCount, diskGB, os } = vms; const operatingSystems = Object.entries(os).map(([name, count]) => ({ name, count, })); const totalDistributedSwitches = networks.filter( (net) => net.type === "distributed" ).length; const infrastructureViewData: TreeViewDataItem = { title: "Infrastructure", icon: <InfrastructureIcon />, name: ( <> We found {infra.totalClusters}{" "} {Humanize.pluralize(infra.totalClusters, "cluster")} with{" "} {infra.totalHosts} {Humanize.pluralize(infra.totalHosts, "host")}. The hosts have a total of {cpuCores.total} CPU cores and{" "} {Humanize.fileSize(ramGB.total * 1024 ** 3, 0)} of memory. </> ), id: "infra", }; const computeStatsViewData: TreeViewDataItem = { title: "Compute per VM", icon: <MicrochipIcon />, id: "compute", name: "", children: [ { title: "Details", id: "compute-details", name: ( <Flex fullWidth={{ default: "fullWidth" }} spaceItems={{ default: "spaceItems4xl" }} > <FlexItem> <ReportPieChart histogram={cpuCores.histogram} title="CPU Cores" legendLabel="CPU Cores" /> </FlexItem> <FlexItem> <ReportPieChart histogram={ramGB.histogram} title="Memory" legendLabel="GB" /> </FlexItem> </Flex> ), }, ], }; const diskStatsViewData: TreeViewDataItem = { title: "Disk size per VM", icon: <HddIcon />, name: ( <> The size of the virtual machine disk (VMDK) impacts the migration process duration due to the time required to copy the file to the OpenShift cluster and the time needed for disk format conversion. </> ), id: "disk-size", children: [ { title: "Details", id: "infra-details", name: ( <Flex fullWidth={{ default: "fullWidth" }} spaceItems={{ default: "spaceItems4xl" }} > <FlexItem> <ReportPieChart histogram={diskGB.histogram} title="Disk capacity" legendLabel="GB" /> </FlexItem> <FlexItem> <ReportPieChart histogram={diskCount.histogram} title="Number of disks" legendLabel="Disks" /> </FlexItem> </Flex> ), }, ], }; const virtualMachinesViewData: TreeViewDataItem = { title: "Virtual machines", icon: <VirtualMachineIcon />, name: ( <> This environment consists of {vms.total} virtual machines,{" "} {vms.total === (vms.totalMigratableWithWarnings ?? 0) ? "All" : vms.totalMigratableWithWarnings}{" "} of them are potentially migratable to a new OpenShift cluster. </> ), id: "vms", children: [ { name: ( <TextContent> <Text> Warnings{" "} <Badge isRead> {vms.migrationWarnings .map(({ count }) => count) .reduce((sum, n) => sum + n, 0)} </Badge> </Text> </TextContent> ), icon: ( <Icon style={{ color: globalWarningColor100.value }}> <ExclamationTriangleIcon /> </Icon> ), id: "migration-warnings", children: [ { name: ( <ReportTable<MigrationIssuesInner> data={vms.migrationWarnings} columns={["Total", "Description"]} fields={["count", "assessment"]} /> ), id: "migration-warnings-details", }, ], }, vms.notMigratableReasons.length > 0 ? { name: ( <TextContent> <Text> Not migratable reasons{" "} <Badge isRead> {vms.migrationWarnings .map(({ count }) => count) .reduce((sum, n) => sum + n, 0)} </Badge> </Text> </TextContent> ), icon: ( <Icon style={{ color: globalDangerColor100.value }}> <ExclamationCircleIcon /> </Icon> ), id: "not-migratable", children: [ { name: ( <ReportTable<MigrationIssuesInner> data={vms.notMigratableReasons} columns={["Total", "Description"]} fields={["count", "assessment"]} /> ), id: "not-migratable-details", }, ], } : null, computeStatsViewData, diskStatsViewData, ].filter(Boolean) as TreeViewDataItem[], }; const networksViewData: TreeViewDataItem = { title: "Networks", icon: <NetworkIcon />, name: ( <> We found {networks.length} networks.{" "} {networks.length === totalDistributedSwitches ? "All" : totalDistributedSwitches}{" "} of them are connected to a distibuted switch. </> ), id: "networks", children: [ { title: "Details", name: ( <ReportTable<InfraNetworksInner> data={networks} columns={["Name", "Type", "VlanId"]} fields={["name", "type", "vlanId"]} /> ), id: "networks-details", } ], }; const storageViewData: TreeViewDataItem = { title: "Storage", icon: <DatabaseIcon />, name: ( <> The environment consists of {datastores.length} datastores with a total capacity of{" "} {Humanize.fileSize( datastores .map((ds) => ds.totalCapacityGB) .reduce((sum, next) => sum + next, 0) * 1024 ** 3 )} . </> ), id: "storage", children: [ { title: "Datastores", name: ( <ReportTable< InfraDatastoresInner & { usage: JSX.Element; } > data={datastores.map((ds) => ({ ...ds, usage: ( <div style={{ width: "200px" }}> <Progress value={(ds.freeCapacityGB / ds.totalCapacityGB) * 100} size="sm" /> </div> ), }))} columns={["Total", "Free", "Type", "Usage %"]} fields={["totalCapacityGB", "freeCapacityGB", "type", "usage"]} /> ), id: "datastores", }, ], }; const operatingSystemsViewData: TreeViewDataItem = { title: "Operating systems", icon: <CogsIcon />, name: ( <>These are the operating systems running on your virtual machines.</> ), id: "os", children: [ { title: "Details", name: ( <ReportTable<{ name: string; count: number }> data={operatingSystems} columns={["Count", "Name"]} fields={["count", "name"]} style={{ width: "25rem" }} /> ), id: "os-details", }, ], }; const treeViewData: Array<TreeViewDataItem> = [ infrastructureViewData, virtualMachinesViewData, networksViewData, storageViewData, operatingSystemsViewData, ]; return ( <Stack hasGutter> <StackItem> <TextContent> <Text component="h2">Discovery report</Text> <Text component="p"> Review the information collected during the discovery process </Text> </TextContent> </StackItem> <StackItem> <TreeView aria-label="Discovery report" variant="compactNoBackground" data={treeViewData} /> </StackItem> </Stack> ); }; DiscoveryStep.displayName = "DiscoveryStep";
null
file
kubev2v/migration-planner-ui
c7869d23-9879-4378-8f29-2d6663837824
ReportBarChart.tsx
[{'import_name': ['Chart', 'ChartVoronoiContainer', 'ChartAxis', 'ChartGroup', 'ChartBar'], 'import_path': '@patternfly/react-charts'}, {'import_name': ['TextContent', 'Text'], 'import_path': '@patternfly/react-core'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportBarChart.tsx
import React from "react"; import { Chart, ChartVoronoiContainer, ChartAxis, ChartGroup, ChartBar, } from "@patternfly/react-charts"; import { TextContent, Text } from "@patternfly/react-core"; type ChartBarDataEntry = { name: string; x: string; y: number; }; function histogramToBarChartData( histogram: ReportBarChart.Histogram, name: string, units: string = "" ): ChartBarDataEntry[] { const { minValue, step, data } = histogram; return data.map((y, idx) => { const lo = step * idx + minValue; const hi = lo + step - 1; return { name, x: `${lo}-${hi}${units}`, y, }; }); } function getMax(histogram: ReportBarChart.Histogram): number { const [head, ..._] = histogram.data; return histogram.data.reduce((prev, next) => Math.max(prev, next), head); } // eslint-disable-next-line @typescript-eslint/no-namespace export namespace ReportBarChart { export type Histogram = { data: number[]; minValue: number; step: number; }; export type Props = { histogram: Histogram; title: string; }; } export function ReportBarChart(props: ReportBarChart.Props): React.ReactNode { const { title, histogram } = props; return ( <> <TextContent style={{ textAlign: "center" }}> <Text>{title}</Text> </TextContent> <Chart name={title.toLowerCase().split(" ").join("-")} ariaDesc={title + " chart"} ariaTitle={title + " chart"} containerComponent={ <ChartVoronoiContainer responsive labels={({ datum }) => `${datum.name}: ${datum.y}`} constrainToVisibleArea /> } domain={{ y: [0, getMax(histogram)], }} domainPadding={{ x: [10, 10] }} legendOrientation="horizontal" legendPosition="bottom-left" padding={75} width={600} height={250} > <ChartAxis /> <ChartAxis dependentAxis showGrid /> <ChartGroup> <ChartBar data={histogramToBarChartData(histogram, "Count")} /> </ChartGroup> </Chart> </> ); }
null
function
kubev2v/migration-planner-ui
e0e1f6be-6191-40a8-9904-cbccb0c269ad
histogramToBarChartData
[{'import_name': ['Chart', 'ChartBar'], 'import_path': '@patternfly/react-charts'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportBarChart.tsx
function histogramToBarChartData( histogram: ReportBarChart.Histogram, name: string, units: string = "" ): ChartBarDataEntry[] { const { minValue, step, data } = histogram; return data.map((y, idx) => { const lo = step * idx + minValue; const hi = lo + step - 1; return { name, x: `${lo}-${hi}${units}`, y, }; }); }
{}
function
kubev2v/migration-planner-ui
809d50a4-02c0-4e15-a57e-da5385fd1b97
getMax
[{'import_name': ['Chart'], 'import_path': '@patternfly/react-charts'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportBarChart.tsx
function getMax(histogram: ReportBarChart.Histogram): number { const [head, ..._] = histogram.data; return histogram.data.reduce((prev, next) => Math.max(prev, next), head); }
{}
file
kubev2v/migration-planner-ui
195833fe-409e-4561-a90d-8536ada34bac
ReportPieChart.tsx
[{'import_name': ['ChartPie'], 'import_path': '@patternfly/react-charts'}, {'import_name': ['TextContent', 'Text'], 'import_path': '@patternfly/react-core'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportPieChart.tsx
import React from "react"; import { ChartPie } from "@patternfly/react-charts"; import { TextContent, Text } from "@patternfly/react-core"; type ChartBarDataEntry = { name: string; x: string; y: number; }; function histogramToPieChartData( histogram: ReportPieChart.Histogram, legendLabel: string, ): ChartBarDataEntry[] { const { data } = histogram; return data .filter(y => y > 0) // Filtrar valores mayores que 0 .map((y, idx) => ({ name: legendLabel, x: `${idx + 1} ${legendLabel}`, // Cambia esto según tus necesidades y, })).sort((a, b) => a.y - b.y); } function getLegendData( histogram: ReportPieChart.Histogram,legendLabel:string): { name: string; }[] { return histogramToPieChartData(histogram, '').map(d => ({ name: `${d.x} ${legendLabel}: ${d.y} VM` })) } // eslint-disable-next-line @typescript-eslint/no-namespace export namespace ReportPieChart { export type Histogram = { data: number[]; minValue: number; step: number; }; export type Props = { histogram: Histogram; title: string; legendLabel: string; }; } export function ReportPieChart(props: ReportPieChart.Props): React.ReactNode { const { title, histogram,legendLabel } = props; return ( <> <TextContent style={{ textAlign: "center" }}> <Text>{title}</Text> </TextContent> <ChartPie name={title.toLowerCase().split(" ").join("-")} ariaDesc={title + " chart"} ariaTitle={title + " chart"} constrainToVisibleArea data={histogramToPieChartData(histogram, legendLabel)} height={230} labels={({ datum }) => `${datum.x}: ${datum.y}`} legendData={getLegendData(histogram,legendLabel)} legendOrientation="vertical" legendPosition="right" padding={{ bottom: 20, left: 20, right: 140, // Adjusted to accommodate legend top: 20, }} width={450} colorScale={['#73BCF7','#73C5C5','#F9E0A2','#BDE5B8','#D2D2D2','#F4B678','#CBC1FF','#FF7468','#7CDBF3','#E4F5BC']}/> </> ); }
null
function
kubev2v/migration-planner-ui
166426df-0b3b-477a-8094-181e83051d1a
histogramToPieChartData
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportPieChart.tsx
function histogramToPieChartData( histogram: ReportPieChart.Histogram, legendLabel: string, ): ChartBarDataEntry[] { const { data } = histogram; return data .filter(y => y > 0) // Filtrar valores mayores que 0 .map((y, idx) => ({ name: legendLabel, x: `${idx + 1} ${legendLabel}`, // Cambia esto según tus necesidades y, })).sort((a, b) => a.y - b.y); }
{}
function
kubev2v/migration-planner-ui
ffd98946-dc69-4e8a-8816-f95b4766619c
getLegendData
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportPieChart.tsx
function getLegendData( histogram: ReportPieChart.Histogram,legendLabel:string): { name: string; }[] { return histogramToPieChartData(histogram, '').map(d => ({ name: `${d.x} ${legendLabel}: ${d.y} VM` })) }
{}
function
kubev2v/migration-planner-ui
cefe1bf2-09ec-40ef-b9c1-f5c3d79412fc
histogramToPieChartData
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportPieChart.tsx
histogramToPieChartData(histogram, legendLabel)} height={230}
{}
file
kubev2v/migration-planner-ui
f6e013a0-8003-4480-a649-360dce9995bc
ReportTable.tsx
[{'import_name': ['Table', 'Thead', 'Tr', 'Th', 'Tbody', 'Td'], 'import_path': '@patternfly/react-table'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportTable.tsx
import { Table, Thead, Tr, Th, Tbody, Td } from "@patternfly/react-table"; import React from "react"; // eslint-disable-next-line @typescript-eslint/no-namespace export namespace ReportTable { export type Props<DataList extends Array<unknown>> = { columns: string[]; data: DataList; fields: Array<keyof DataList[0]>; style?: React.CSSProperties; }; } export function ReportTable<DataItem>( props: ReportTable.Props<DataItem[]> ): React.ReactNode { const { columns, data, fields, style } = props; return ( <Table variant="compact" borders={true} style={{ border: "1px solid lightgray", borderRight: "none", ...style }} > <Thead> <Tr> {columns.map((name) => ( <Th hasRightBorder>{name}</Th> ))} </Tr> </Thead> <Tbody> {data.map((item, idx) => ( <Tr key={idx}> {fields.map((f) => ( <Td hasRightBorder> {item[f] === "" ? "-" : (item[f] as React.ReactNode)}</Td> ))} </Tr> ))} </Tbody> </Table> ); } ReportTable.displayName = "ReportTable";
null
function
kubev2v/migration-planner-ui
b99bd0e9-17d6-49a3-8e3b-128d9751b810
ReportTable
[{'import_name': ['Table', 'Thead', 'Tr', 'Th', 'Tbody', 'Td'], 'import_path': '@patternfly/react-table'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/discovery/ReportTable.tsx
function ReportTable<DataItem>( props: ReportTable.Props<DataItem[]> ): React.ReactNode { const { columns, data, fields, style } = props; return ( <Table variant="compact" borders={true} style={{ border: "1px solid lightgray", borderRight: "none", ...style }} > <Thead> <Tr> {columns.map((name) => ( <Th hasRightBorder>{name}</Th> ))} </Tr> </Thead> <Tbody> {data.map((item, idx) => ( <Tr key={idx}> {fields.map((f) => ( <Td hasRightBorder> {item[f] === "" ? "-" : (item[f] as React.ReactNode)}</Td> ))} </Tr> ))} </Tbody> </Table> ); } ReportTable.displayName = "ReportTable";
{}
file
kubev2v/migration-planner-ui
45b6eadc-2ef7-45df-9a1b-1fed858a29e1
PrepareMigrationStep.tsx
[{'import_name': ['Stack', 'StackItem', 'TextContent', 'Text', 'Radio'], 'import_path': '@patternfly/react-core'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/migration-wizard/steps/prepare-migration/PrepareMigrationStep.tsx
import React from "react"; import { Stack, StackItem, TextContent, Text, Radio, } from "@patternfly/react-core"; export const PrepareMigrationStep: React.FC = () => { return ( <Stack hasGutter> <StackItem> <TextContent> <Text component="h2">Prepare for Migration</Text> </TextContent> </StackItem> <StackItem> <TextContent> <Text component="h3">Migration goal</Text> </TextContent> </StackItem> <StackItem> <Radio id="lets-try" label="Let's try" name="lets-try" description="Starting with a minimal cluster to try our migration flows and OpenShift Virtualization. (20 VMs or up to cluster capacity limitations)" checked /> </StackItem> <StackItem> <Radio id="feel-good" label="Feeling good" name="feel-good" description="Create a cluster that can support a medium migration scale (500 VMs or up to cluster capacity limitations)" isDisabled /> </StackItem> <StackItem> <Radio id="got-this" label="I got this" name="got-this" description="Create a cluster that can support a big migration scale (5000 VMs or up to cluster capacity limitations)" isDisabled /> </StackItem> <StackItem> <TextContent style={{ paddingBlock: "1rem" }}> <Text component="h3">Target cluster</Text> </TextContent> </StackItem> <StackItem> <Radio id="new-cluster" label="New cluster" name="new-cluster" description="Let's use our OpenShift assisted installer to create a new bare metal cluster" checked /> </StackItem> <StackItem> <Radio id="use-existing-cluster" label="Use existing cluster" name="use-existing-cluster" description="Choose one of your OpenShift cluster" isDisabled /> </StackItem> <StackItem> <Radio id="use-sandbox" label="Use OpenShift developer sandbox (Coming Soon)" name="use-sandabox" description="" isDisabled /> </StackItem> </Stack> ); }; PrepareMigrationStep.displayName = "PrepareMigrationStep";
null
file
kubev2v/migration-planner-ui
3ddef2c9-c153-4e97-a629-14af77a8bddf
OpenShiftIcon.tsx
[{'import_name': ['SVGIcon'], 'import_path': '#/components/SVGIcon'}, {'import_name': ['css'], 'import_path': '@emotion/css'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/ocm/OpenShiftIcon.tsx
import React from "react"; import { SVGIcon } from "#/components/SVGIcon"; import { css } from "@emotion/css"; const classes = { root: css({ width: "3rem", height: "3rem", }), }; export const OpenShiftIcon: React.FC = () => ( <SVGIcon className={classes.root} viewBox="0 0 38 38"> <path d="M28,1H10a9,9,0,0,0-9,9V28a9,9,0,0,0,9,9H28a9,9,0,0,0,9-9V10a9,9,0,0,0-9-9Z" /> <path fill="#fff" d="M10.09863,22.18994a.625.625,0,0,1-.25488-1.1958l2.74072-1.22021a.62492.62492,0,1,1,.50879,1.1416l-2.74072,1.22021A.619.619,0,0,1,10.09863,22.18994Z" /> <path fill="#fff" d="M8.832,25.49072a.625.625,0,0,1-.25488-1.1958l2.74023-1.22021a.62492.62492,0,1,1,.50879,1.1416L9.08594,25.43652A.61731.61731,0,0,1,8.832,25.49072Z" /> <path fill="#fff" d="M26.42773,14.91943a.62473.62473,0,0,1-.2539-1.1958L28.915,12.50342a.62472.62472,0,1,1,.50781,1.1416l-2.74121,1.22021A.61563.61563,0,0,1,26.42773,14.91943Z" /> <path fill="#fff" d="M25.16113,18.22021a.62473.62473,0,0,1-.2539-1.1958l2.74023-1.22021a.62472.62472,0,1,1,.50781,1.1416L25.415,18.166A.61581.61581,0,0,1,25.16113,18.22021Z" /> <path fill="#e00" d="M18.95166,28.63379A9.593,9.593,0,0,1,12.8291,26.4165a.625.625,0,0,1,.7959-.96386,8.37943,8.37943,0,0,0,13.71289-6.1045.61006.61006,0,0,1,.65039-.59814.6249.6249,0,0,1,.59766.65088,9.65521,9.65521,0,0,1-9.63428,9.23291Z" /> <path fill="#e00" d="M9.97461,19.22607l-.02881-.00048a.62539.62539,0,0,1-.59619-.65284A9.6291,9.6291,0,0,1,25.10547,11.5835a.62531.62531,0,0,1-.79688.96386,8.37815,8.37815,0,0,0-13.71,6.082A.62532.62532,0,0,1,9.97461,19.22607Z" /> </SVGIcon> ); OpenShiftIcon.displayName = "OpenShiftIcon";
null
function
kubev2v/migration-planner-ui
aa34122a-84c6-42b0-b4d9-df202d7ea97a
OpenShiftIcon
[{'import_name': ['SVGIcon'], 'import_path': '#/components/SVGIcon'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/ocm/OpenShiftIcon.tsx
() => ( <SVGIcon className={classes.root} viewBox="0 0 38 38"> <path d="M28,1H10a9,9,0,0,0-9,9V28a9,9,0,0,0,9,9H28a9,9,0,0,0,9-9V10a9,9,0,0,0-9-9Z" /> <path fill="#fff" d="M10.09863,22.18994a.625.625,0,0,1-.25488-1.1958l2.74072-1.22021a.62492.62492,0,1,1,.50879,1.1416l-2.74072,1.22021A.619.619,0,0,1,10.09863,22.18994Z" /> <path fill="#fff" d="M8.832,25.49072a.625.625,0,0,1-.25488-1.1958l2.74023-1.22021a.62492.62492,0,1,1,.50879,1.1416L9.08594,25.43652A.61731.61731,0,0,1,8.832,25.49072Z" /> <path fill="#fff" d="M26.42773,14.91943a.62473.62473,0,0,1-.2539-1.1958L28.915,12.50342a.62472.62472,0,1,1,.50781,1.1416l-2.74121,1.22021A.61563.61563,0,0,1,26.42773,14.91943Z" /> <path fill="#fff" d="M25.16113,18.22021a.62473.62473,0,0,1-.2539-1.1958l2.74023-1.22021a.62472.62472,0,1,1,.50781,1.1416L25.415,18.166A.61581.61581,0,0,1,25.16113,18.22021Z" /> <path fill="#e00" d="M18.95166,28.63379A9.593,9.593,0,0,1,12.8291,26.4165a.625.625,0,0,1,.7959-.96386,8.37943,8.37943,0,0,0,13.71289-6.1045.61006.61006,0,0,1,.65039-.59814.6249.6249,0,0,1,.59766.65088,9.65521,9.65521,0,0,1-9.63428,9.23291Z" /> <path fill="#e00" d="M9.97461,19.22607l-.02881-.00048a.62539.62539,0,0,1-.59619-.65284A9.6291,9.6291,0,0,1,25.10547,11.5835a.62531.62531,0,0,1-.79688.96386,8.37815,8.37815,0,0,0-13.71,6.082A.62532.62532,0,0,1,9.97461,19.22607Z" /> </SVGIcon> )
{}
file
kubev2v/migration-planner-ui
9a6b2911-3ba2-46b4-872b-75dffff413f3
VMwareMigrationCard.tsx
[{'import_name': ['Card', 'CardHeader', 'Split', 'SplitItem', 'Label', 'CardBody', 'Title', 'Text', 'TextContent', 'CardFooter', 'Flex', 'FlexItem', 'Button'], 'import_path': '@patternfly/react-core'}, {'import_name': ['css'], 'import_path': '@emotion/css'}, {'import_name': ['Link'], 'import_path': 'react-router-dom'}, {'import_name': ['OpenShiftIcon'], 'import_path': './OpenShiftIcon'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/ocm/VMwareMigrationCard.tsx
import React from "react"; import { Card, CardHeader, Split, SplitItem, Label, CardBody, Title, Text, TextContent, CardFooter, Flex, FlexItem, Button, } from "@patternfly/react-core"; import { css } from "@emotion/css"; import { Link } from "react-router-dom"; import { OpenShiftIcon } from "./OpenShiftIcon"; const classes = { cardRoot: css({ width: "22em", height: "22em" }), }; export const VMwareMigrationCard: React.FC = () => { return ( <Card className={classes.cardRoot}> <CardHeader> <Split hasGutter> <SplitItem> <OpenShiftIcon /> </SplitItem> <SplitItem isFilled /> <SplitItem> <Label color="blue">Self-managed service</Label> </SplitItem> </Split> </CardHeader> <CardBody> <Title headingLevel="h2">VMware to OpenShift migration</Title> </CardBody> <CardBody> <TextContent> <Text> Start your migration journey to OpenShift Virtualization. We will create a migration assessment report and help you create a migration plan. </Text> </TextContent> </CardBody> <CardFooter> <Flex> <FlexItem> <Link to="/migrate/wizard"> <Button variant="secondary">Start your migration journey</Button> </Link> </FlexItem> </Flex> </CardFooter> </Card> ); }; VMwareMigrationCard.displayName = "VMwareMigrationCard";
null
function
kubev2v/migration-planner-ui
e608ccd5-ed5a-4daa-bd4e-3933f716fc5e
VMwareMigrationCard
[{'import_name': ['Card', 'CardHeader', 'Split', 'SplitItem', 'Label', 'CardBody', 'Title', 'Text', 'TextContent', 'CardFooter', 'Flex', 'FlexItem', 'Button'], 'import_path': '@patternfly/react-core'}, {'import_name': ['Link'], 'import_path': 'react-router-dom'}, {'import_name': ['OpenShiftIcon'], 'import_path': './OpenShiftIcon'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/ocm/VMwareMigrationCard.tsx
() => { return ( <Card className={classes.cardRoot}> <CardHeader> <Split hasGutter> <SplitItem> <OpenShiftIcon /> </SplitItem> <SplitItem isFilled /> <SplitItem> <Label color="blue">Self-managed service</Label> </SplitItem> </Split> </CardHeader> <CardBody> <Title headingLevel="h2">VMware to OpenShift migration</Title> </CardBody> <CardBody> <TextContent> <Text> Start your migration journey to OpenShift Virtualization. We will create a migration assessment report and help you create a migration plan. </Text> </TextContent> </CardBody> <CardFooter> <Flex> <FlexItem> <Link to="/migrate/wizard"> <Button variant="secondary">Start your migration journey</Button> </Link> </FlexItem> </Flex> </CardFooter> </Card> ); }
{}
file
kubev2v/migration-planner-ui
4e317cc2-5186-4280-9566-6da5b7d7e5e0
MigrationAssessmentPage.tsx
[{'import_name': ['Link'], 'import_path': 'react-router-dom'}, {'import_name': ['Bullseye', 'Button', 'Card', 'CardBody', 'CardHeader', 'Flex', 'FlexItem', 'Icon', 'Stack', 'StackItem', 'Text', 'TextContent'], 'import_path': '@patternfly/react-core'}, {'import_name': ['ClusterIcon', 'MigrationIcon'], 'import_path': '@patternfly/react-icons'}, {'import_name': ['AppPage'], 'import_path': '#/components/AppPage'}, {'import_name': ['CustomEnterpriseIcon'], 'import_path': '#/components/CustomEnterpriseIcon'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/pages/MigrationAssessmentPage.tsx
import React from "react"; import { Link } from "react-router-dom"; import { Bullseye, Button, Card, CardBody, CardHeader, Flex, FlexItem, Icon, Stack, StackItem, Text, TextContent, } from "@patternfly/react-core"; import { ClusterIcon, MigrationIcon } from "@patternfly/react-icons"; import globalActiveColor300 from "@patternfly/react-tokens/dist/esm/global_active_color_300"; import { AppPage } from "#/components/AppPage"; import { CustomEnterpriseIcon } from "#/components/CustomEnterpriseIcon"; const cards: React.ReactElement[] = [ <Card isFullHeight isPlain key="card-1"> <CardHeader> <TextContent style={{ textAlign: "center" }}> <Icon size="xl" style={{ color: globalActiveColor300.var }}> <CustomEnterpriseIcon /> </Icon> <Text component="h2">Discover your VMware environment</Text> </TextContent> </CardHeader> <CardBody> <TextContent style={{ textAlign: "center" }}> <Text> Run the discovery process and create a full evaluation report including recommendations for your migration journey. <a href="/example_report.pdf" download> <Button size="sm" variant="link"> See an example report. </Button> </a> </Text> </TextContent> </CardBody> </Card>, <Card isFullHeight isPlain key="card-2"> <CardHeader> <TextContent style={{ textAlign: "center" }}> <Icon size="xl" style={{ color: globalActiveColor300.var }}> <ClusterIcon /> </Icon> <Text component="h2">Select a target cluster</Text> </TextContent> </CardHeader> <CardBody> <TextContent style={{ textAlign: "center" }}> <Text> Select your target OpenShift Cluster to fit your migration goals. </Text> </TextContent> </CardBody> </Card>, <Card isFullHeight isPlain key="card-3"> <CardHeader> <TextContent style={{ textAlign: "center" }}> <Icon size="xl" style={{ color: globalActiveColor300.var }}> <MigrationIcon /> </Icon> <Text component="h2">Create a migration plan</Text> </TextContent> </CardHeader> <CardBody> <TextContent style={{ textAlign: "center" }}> <Text> Select your VMs, create a network and storage mapping and schedule your migration timeline </Text> </TextContent> </CardBody> </Card>, ]; const MigrationAssessmentPage: React.FC = () => ( <AppPage breadcrumbs={[ { key: 1, to: "#", children: "Migration assessment", isActive: true, }, ]} title="Welcome, let's start your migration journey from VMware to OpenShift." > <Bullseye> <Stack hasGutter style={{ justifyContent: "space-evenly" }}> <StackItem> <Flex> {cards.map((card) => ( <FlexItem flex={{ default: "flex_1" }} key={card.key}> {card} </FlexItem> ))} </Flex> </StackItem> <StackItem style={{ alignSelf: "center" }}> <Link to="/migrate/wizard"> <Button>Start your migration journey</Button> </Link> </StackItem> </Stack> </Bullseye> </AppPage> ); MigrationAssessmentPage.displayName = "MigrationAssessmentPage"; export default MigrationAssessmentPage;
null
file
kubev2v/migration-planner-ui
2c389453-042f-4cbd-b2d1-837775bdc854
MigrationWizardPage.tsx
[{'import_name': ['AppPage'], 'import_path': '#/components/AppPage'}, {'import_name': ['MigrationWizard'], 'import_path': '#/migration-wizard/MigrationWizard'}, {'import_name': ['Provider', 'DiscoverySourcesProvider'], 'import_path': '#/migration-wizard/contexts/discovery-sources/Provider'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/pages/MigrationWizardPage.tsx
import React from "react"; import { AppPage } from "#/components/AppPage"; import { MigrationWizard } from "#/migration-wizard/MigrationWizard"; import { Provider as DiscoverySourcesProvider } from "#/migration-wizard/contexts/discovery-sources/Provider"; const MigrationWizardPage: React.FC = () => { return ( <AppPage breadcrumbs={[ { key: 1, to: "/migrate", children: "Migration assessment" }, { key: 2, to: "#", children: "Guide", isActive: true }, ]} title="Welcome, let's start your migration journey from VMware to OpenShift." > <DiscoverySourcesProvider> <MigrationWizard /> </DiscoverySourcesProvider> </AppPage> ); }; MigrationWizardPage.displayName = "MigrationWizardPage"; export default MigrationWizardPage;
null
file
kubev2v/migration-planner-ui
b7a41dcb-89c3-4519-95bd-c02d4e625bab
OcmPreviewPage.tsx
[{'import_name': ['Bullseye'], 'import_path': '@patternfly/react-core'}, {'import_name': ['AppPage'], 'import_path': '#/components/AppPage'}, {'import_name': ['VMwareMigrationCard'], 'import_path': '#/ocm/VMwareMigrationCard'}]
https://github.com/kubev2v/migration-planner-ui/apps/demo/src/pages/OcmPreviewPage.tsx
import React from "react"; import { Bullseye } from "@patternfly/react-core"; import { AppPage } from "#/components/AppPage"; import { VMwareMigrationCard } from "#/ocm/VMwareMigrationCard"; const OcmPreviewPage: React.FC = () => { return ( <AppPage title="VMware Migration Assessment Card for OCM"> <Bullseye> <VMwareMigrationCard /> </Bullseye> </AppPage> ); }; OcmPreviewPage.displayName = "OcmPreviewPage"; export default OcmPreviewPage;
null
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
8