Skip to content

Commit

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

type Props = {
Expand Down Expand Up @@ -38,12 +37,17 @@ export function ApiKeySuccess({ value }: Props) {
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>
<LoginCommand />
<Codesnippet highlightCode wrap code={`zenml login --api-key ${window.location.origin}`} />
<p className="text-theme-text-secondary">
Alternatively, you can set the following environment variables to configure workloads
where CLI interaction is not possible:
</p>
<EnvVariableCommand value={value} />
<Codesnippet
highlightCode
wrap
code={`ZENML_STORE_URL: ${window.location.origin}
ZENML_STORE_API_KEY: ${value}`}
/>
</div>
</div>
);
Expand Down Expand Up @@ -95,35 +99,3 @@ 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 bd3e55f

Please sign in to comment.