Skip to content

Commit

Permalink
fix: add commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Cahllagerfeld committed Nov 15, 2024
1 parent 7384908 commit 60121ca
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions src/app/settings/service-accounts/[service-account-id]/Success.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Copy from "@/assets/icons/copy.svg?react";
import { Codesnippet } from "@/components/CodeSnippet";
import { InfoBox } from "@/components/Infobox";
import { Tick } from "@/components/Tick";
import { Button } from "@zenml-io/react-component-library/components/server";
import { useServerInfo } from "@/data/server/info-query";
import { Button, Skeleton } from "@zenml-io/react-component-library/components/server";
import { useState } from "react";

type Props = {
Expand Down Expand Up @@ -32,23 +34,16 @@ export function ApiKeySuccess({ value }: Props) {
Learn More
</a>
</div>
{/* TODO figure the value for oss out */}
{/* <p className="text-theme-text-secondary">
<p className="text-theme-text-secondary">
To login to the ZenML server using the generated key, you can run the following CLI
command and enter the API key when prompted:
</p>
<Codesnippet highlightCode wrap code={`zenml login --api-key ${backendUrl}`} />
<LoginCommand />
<p className="text-theme-text-secondary">
Alternatively, you can set the following environment variables to configure workloads
where CLI interaction is not possible:
</p>
<Codesnippet
highlightCode
wrap
code={`ZENML_STORE_URL: ${backendUrl}
ZENML_STORE_API_KEY: ${value}`}
/> */}
<EnvVariableCommand value={value} />
</div>
</div>
);
Expand Down Expand Up @@ -100,3 +95,35 @@ function Hintbox() {
</InfoBox>
);
}

type CommandProps = { value: string };
function EnvVariableCommand({ value }: CommandProps) {
const info = useServerInfo();

if (info.isPending) return <Skeleton className="h-[100px] w-full" />;
if (info.isError) return <p>Failed to fetch Server Info</p>;

return (
<Codesnippet
highlightCode
wrap
code={`ZENML_STORE_URL: ${info.data.server_url || window.location.origin}
ZENML_STORE_API_KEY: ${value}`}
/>
);
}

function LoginCommand() {
const info = useServerInfo();

if (info.isPending) return <Skeleton className="h-9 w-full" />;
if (info.isError) return <p>Failed to fetch Server Info</p>;

return (
<Codesnippet
highlightCode
wrap
code={`zenml login --api-key ${info.data.server_url || window.location.origin}`}
/>
);
}

0 comments on commit 60121ca

Please sign in to comment.