Skip to content

Commit 73a6899

Browse files
authored
chore: miscellaneous cleanup (#11785)
1 parent 79568bf commit 73a6899

File tree

5 files changed

+29
-36
lines changed

5 files changed

+29
-36
lines changed

site/src/utils/entitlements.ts renamed to site/src/modules/dashboard/entitlements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Entitlements, Feature, FeatureName } from "api/typesGenerated";
1+
import type { Entitlements, Feature, FeatureName } from "api/typesGenerated";
22

33
/**
44
* @param hasLicense true if Enterprise edition

site/src/modules/dashboard/useFeatureVisibility.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FeatureName } from "api/typesGenerated";
2+
import { selectFeatureVisibility } from "./entitlements";
23
import { useDashboard } from "./useDashboard";
3-
import { selectFeatureVisibility } from "utils/entitlements";
44

55
export const useFeatureVisibility = (): Record<FeatureName, boolean> => {
66
const { entitlements } = useDashboard();

site/src/pages/CliAuthPage/CliAuthPage.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
import { useEffect, useState, FC, PropsWithChildren } from "react";
1+
import { type FC } from "react";
22
import { Helmet } from "react-helmet-async";
3+
import { useQuery } from "react-query";
34
import { getApiKey } from "api/api";
45
import { pageTitle } from "utils/page";
56
import { CliAuthPageView } from "./CliAuthPageView";
67

7-
export const CliAuthenticationPage: FC<PropsWithChildren<unknown>> = () => {
8-
const [apiKey, setApiKey] = useState<string | null>(null);
9-
10-
useEffect(() => {
11-
getApiKey()
12-
.then(({ key }) => {
13-
setApiKey(key);
14-
})
15-
.catch((error) => {
16-
console.error(error);
17-
});
18-
}, []);
8+
export const CliAuthenticationPage: FC = () => {
9+
const { data } = useQuery({
10+
queryFn: () => getApiKey(),
11+
});
1912

2013
return (
2114
<>
2215
<Helmet>
2316
<title>{pageTitle("CLI Auth")}</title>
2417
</Helmet>
25-
<CliAuthPageView sessionToken={apiKey} />
18+
<CliAuthPageView sessionToken={data?.key} />
2619
</>
2720
);
2821
};
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Button from "@mui/material/Button";
2-
import { useTheme } from "@emotion/react";
2+
import { type Interpolation, type Theme } from "@emotion/react";
33
import { type FC } from "react";
44
import { Link as RouterLink } from "react-router-dom";
55
import { CodeExample } from "components/CodeExample/CodeExample";
@@ -8,12 +8,10 @@ import { Welcome } from "components/Welcome/Welcome";
88
import { FullScreenLoader } from "components/Loader/FullScreenLoader";
99

1010
export interface CliAuthPageViewProps {
11-
sessionToken: string | null;
11+
sessionToken?: string;
1212
}
1313

1414
export const CliAuthPageView: FC<CliAuthPageViewProps> = ({ sessionToken }) => {
15-
const theme = useTheme();
16-
1715
if (!sessionToken) {
1816
return <FullScreenLoader />;
1917
}
@@ -22,15 +20,7 @@ export const CliAuthPageView: FC<CliAuthPageViewProps> = ({ sessionToken }) => {
2220
<SignInLayout>
2321
<Welcome>Session token</Welcome>
2422

25-
<p
26-
css={{
27-
fontSize: 16,
28-
color: theme.palette.text.secondary,
29-
marginBottom: 32,
30-
textAlign: "center",
31-
lineHeight: "160%",
32-
}}
33-
>
23+
<p css={styles.instructions}>
3424
Copy the session token below and{" "}
3525
<strong css={{ whiteSpace: "nowrap" }}>
3626
paste it in your terminal
@@ -40,17 +30,27 @@ export const CliAuthPageView: FC<CliAuthPageViewProps> = ({ sessionToken }) => {
4030

4131
<CodeExample code={sessionToken} secret />
4232

43-
<div
44-
css={{
45-
display: "flex",
46-
justifyContent: "flex-end",
47-
paddingTop: 8,
48-
}}
49-
>
33+
<div css={styles.backButton}>
5034
<Button component={RouterLink} size="large" to="/workspaces" fullWidth>
5135
Go to workspaces
5236
</Button>
5337
</div>
5438
</SignInLayout>
5539
);
5640
};
41+
42+
const styles = {
43+
instructions: (theme) => ({
44+
fontSize: 16,
45+
color: theme.palette.text.secondary,
46+
marginBottom: 32,
47+
textAlign: "center",
48+
lineHeight: "160%",
49+
}),
50+
51+
backButton: {
52+
display: "flex",
53+
justifyContent: "flex-end",
54+
paddingTop: 8,
55+
},
56+
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy