Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECOPROJECT-2579: Changes behavior when we have source 'Waiting for credentials' #83

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/demo/src/migration-wizard/steps/connect/ConnectStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Icon,
Alert,
Button,
AlertActionLink,
} 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";
Expand Down Expand Up @@ -121,6 +122,33 @@ export const ConnectStep: React.FC = () => {
</Alert>
)}
</StackItem>
<StackItem>
{discoverySourcesContext.agentSelected?.status ===
"waiting-for-credentials" && (
<Alert
isInline
variant="custom"
title="Discovery VM"
actionLinks={
<AlertActionLink
component="a"
href={discoverySourcesContext.agentSelected?.credentialUrl}
target="_blank"
rel="noopener noreferrer"
>
{discoverySourcesContext.agentSelected?.credentialUrl}
</AlertActionLink>
}
>
<TextContent>
<Text>
Click the link below to connect the Discovery Source to your
VMware environment.
</Text>
</TextContent>
</Alert>
)}
</StackItem>
</Stack>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,43 @@ import {
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";
import { Link } from "react-router-dom";

// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace AgentStatusView {
export type Props = {
status: Agent["status"];
statusInfo?: Agent["statusInfo"];
credentialUrl?: Agent["credentialUrl"];
};
}

const StatusInfoWaitingForCredentials: React.FC<{
credentialUrl?: Agent["credentialUrl"];
}> = ({ credentialUrl }) => {
return (
<>
<TextContent>
<Text>
Click the link below to connect the Discovery Source to your VMware
environment.
</Text>
</TextContent>
{credentialUrl && (
<Link to={credentialUrl} target="_blank">
{credentialUrl}
</Link>
)}
</>
);
};

export const AgentStatusView: React.FC<AgentStatusView.Props> = (props) => {
const { status, statusInfo } = props;
const { status, statusInfo, credentialUrl } = props;

const statusView = useMemo(() => {
// eslint-disable-next-line prefer-const
let fake: Agent['status'] | null = null;
let fake: Agent["status"] | null = null;
// fake = "not-connected";
// fake = "waiting-for-credentials";
// fake = "gathering-initial-inventory";
Expand Down Expand Up @@ -92,15 +114,21 @@ export const AgentStatusView: React.FC<AgentStatusView.Props> = (props) => {
<Split hasGutter style={{ gap: "0.66rem" }}>
<SplitItem>{statusView && statusView.icon}</SplitItem>
<SplitItem>
{statusInfo ? (
{statusInfo || statusView && statusView.text==='Waiting for credentials' ? (
<Popover
aria-label={statusView && statusView.text}
headerContent={statusView && statusView.text}
headerComponent="h1"
bodyContent={
<TextContent>
<Text>{statusInfo}</Text>
</TextContent>
statusView && statusView.text !== "Waiting for credentials" ? (
<TextContent>
<Text>{statusInfo}</Text>
</TextContent>
) : (
<StatusInfoWaitingForCredentials
credentialUrl={credentialUrl}
/>
)
}
>
<Button variant="link" isInline>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const SourcesTable: React.FC = () => {
/>
</Td>
<Td dataLabel={Columns.Status}>
<AgentStatusView status={agent.status} statusInfo={agent.statusInfo} />
<AgentStatusView status={agent.status} statusInfo={agent.statusInfo} credentialUrl={agent.credentialUrl}/>
</Td>
<Td dataLabel={Columns.Hosts}>
{(source?.inventory?.infra.totalHosts ?? VALUE_NOT_AVAILABLE)}
Expand All @@ -184,6 +184,7 @@ export const SourcesTable: React.FC = () => {
discoverySourcesContext.listAgents(),
discoverySourcesContext.listSources(),
]);
discoverySourcesContext.selectAgent(firstAgent);
}}
/>
)}
Expand Down