Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use generated types
  • Loading branch information
Emyrk committed Sep 28, 2023
commit 41f562b7688d3149573e04b3abfc230262056b39
9 changes: 0 additions & 9 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,15 +1016,6 @@ export const getDeploymentSSHConfig =
return response.data;
};

// The Deployment types are not generated on from the Go generator yet because
// it does not know how to generate OptionSet
export interface DeploymentGroup {
readonly name: string;
readonly parent?: DeploymentGroup;
readonly description: string;
readonly children: DeploymentGroup[];
}

export type DeploymentConfig = {
readonly config: TypesGen.DeploymentValues;
readonly options: TypesGen.ClibaseOption[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { FC } from "react";
import { optionValue } from "./optionValue";
import Box from "@mui/material/Box";
import { ClibaseOption } from "api/typesGenerated";

const OptionsTable: FC<{
options: ClibaseOption[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DeploymentOption } from "api/api";
import { optionValue } from "./optionValue";
import { ClibaseOption } from "api/typesGenerated";

const defaultOption: DeploymentOption = {
const defaultOption: ClibaseOption = {
name: "",
description: "",
flag: "",
Expand All @@ -12,7 +12,7 @@ const defaultOption: DeploymentOption = {

describe("optionValue", () => {
it.each<{
option: DeploymentOption;
option: ClibaseOption;
expected: unknown;
}>([
{
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/DeploySettingsLayout/optionValue.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DeploymentOption } from "api/api";
import { ClibaseOption } from "api/typesGenerated";
import { intervalToDuration, formatDuration } from "date-fns";

// optionValue is a helper function to format the value of a specific deployment options
export function optionValue(option: DeploymentOption) {
export function optionValue(option: ClibaseOption) {
switch (option.name) {
case "Max Token Lifetime":
case "Session Duration":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Box from "@mui/material/Box";
import { DAUsResponse } from "api/typesGenerated";
import { ClibaseOption, DAUsResponse } from "api/typesGenerated";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { DAUChart, DAUTitle } from "components/DAUChart/DAUChart";
import { Header } from "components/DeploySettingsLayout/Header";
Expand All @@ -8,10 +8,9 @@ import { Stack } from "components/Stack/Stack";
import { ChartSection } from "./ChartSection";
import { useDeploymentOptions } from "utils/deployOptions";
import { docs } from "utils/docs";
import { DeploymentOption } from "api/api";

export type GeneralSettingsPageViewProps = {
deploymentOptions: DeploymentOption[];
deploymentOptions: ClibaseOption[];
deploymentDAUs?: DAUsResponse;
deploymentDAUsError: unknown;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeploymentOption } from "api/api";
import { ClibaseOption } from "api/typesGenerated";
import {
Badges,
DisabledBadge,
Expand All @@ -15,7 +15,7 @@ import {
import { docs } from "utils/docs";

export type SecuritySettingsPageViewProps = {
options: DeploymentOption[];
options: ClibaseOption[];
featureAuditLogEnabled: boolean;
featureBrowserOnlyEnabled: boolean;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DeploymentOption } from "api/api";
import { ClibaseOption } from "api/typesGenerated";
import {
Badges,
DisabledBadge,
Expand All @@ -14,7 +14,7 @@ import {
import { docs } from "utils/docs";

export type UserAuthSettingsPageViewProps = {
options: DeploymentOption[];
options: ClibaseOption[];
};

export const UserAuthSettingsPageView = ({
Expand Down
15 changes: 8 additions & 7 deletions site/src/utils/deployOptions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { DeploymentOption, DeploymentGroup } from "api/api";
import { DeploymentGroup } from "api/api";
import { ClibaseGroup, ClibaseOption } from "api/typesGenerated";
import { useMemo } from "react";

const deploymentOptions = (
options: DeploymentOption[],
options: ClibaseOption[],
...names: string[]
): DeploymentOption[] => {
const found: DeploymentOption[] = [];
): ClibaseOption[] => {
const found: ClibaseOption[] = [];
for (const name of names) {
const option = options.find((o) => o.name === name);
if (option) {
Expand All @@ -18,14 +19,14 @@ const deploymentOptions = (
};

export const useDeploymentOptions = (
options: DeploymentOption[],
options: ClibaseOption[],
...names: string[]
): DeploymentOption[] => {
): ClibaseOption[] => {
return useMemo(() => deploymentOptions(options, ...names), [options, names]);
};

export const deploymentGroupHasParent = (
group: DeploymentGroup | undefined,
group: ClibaseGroup | undefined,
parent: string,
): boolean => {
if (!group) {
Expand Down