mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore(site): Add type checking (#7441)
This commit is contained in:
@@ -16,3 +16,5 @@ const monaco = {
|
||||
}
|
||||
|
||||
module.exports = monaco
|
||||
|
||||
export {}
|
||||
|
||||
@@ -17,7 +17,7 @@ import { Stack } from "../../Stack/Stack"
|
||||
type Icon = typeof HelpIcon
|
||||
|
||||
type Size = "small" | "medium"
|
||||
interface HelpTooltipProps {
|
||||
export interface HelpTooltipProps {
|
||||
// Useful to test on storybook
|
||||
open?: boolean
|
||||
size?: Size
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Button from "@material-ui/core/Button"
|
||||
import TextField from "@material-ui/core/TextField"
|
||||
import { makeStyles } from "@material-ui/core/styles"
|
||||
import { ApiErrorResponse } from "api/errors"
|
||||
import { AlertBanner } from "components/AlertBanner/AlertBanner"
|
||||
import { Fieldset } from "components/DeploySettingsLayout/Fieldset"
|
||||
import { Header } from "components/DeploySettingsLayout/Header"
|
||||
@@ -15,7 +14,7 @@ import { Link as RouterLink } from "react-router-dom"
|
||||
type AddNewLicenseProps = {
|
||||
onSaveLicenseKey: (license: string) => void
|
||||
isSavingLicense: boolean
|
||||
savingLicenseError?: ApiErrorResponse
|
||||
savingLicenseError?: unknown
|
||||
}
|
||||
|
||||
export const AddNewLicensePageView: FC<AddNewLicenseProps> = ({
|
||||
|
||||
@@ -26,7 +26,6 @@ Example.args = {
|
||||
activeVersion: MockTemplateVersion,
|
||||
data: {
|
||||
resources: [MockWorkspaceResource, MockWorkspaceResource2],
|
||||
versions: [MockTemplateVersion],
|
||||
daus: MockTemplateDAUResponse,
|
||||
},
|
||||
}
|
||||
@@ -37,7 +36,6 @@ NoIcon.args = {
|
||||
activeVersion: MockTemplateVersion,
|
||||
data: {
|
||||
resources: [MockWorkspaceResource, MockWorkspaceResource2],
|
||||
versions: [MockTemplateVersion],
|
||||
daus: MockTemplateDAUResponse,
|
||||
},
|
||||
}
|
||||
@@ -61,7 +59,6 @@ SmallViewport.args = {
|
||||
},
|
||||
data: {
|
||||
resources: [MockWorkspaceResource, MockWorkspaceResource2],
|
||||
versions: [MockTemplateVersion],
|
||||
daus: MockTemplateDAUResponse,
|
||||
},
|
||||
}
|
||||
|
||||
+10
-2
@@ -14,12 +14,20 @@ import i18next from "i18next"
|
||||
|
||||
const { t } = i18next
|
||||
|
||||
const validFormValues = {
|
||||
type FormValues = Required<
|
||||
Omit<UpdateTemplateMeta, "default_ttl_ms" | "max_ttl_ms">
|
||||
>
|
||||
|
||||
const validFormValues: FormValues = {
|
||||
name: "Name",
|
||||
display_name: "A display name",
|
||||
description: "A description",
|
||||
icon: "vscode.png",
|
||||
allow_user_cancel_workspace_jobs: false,
|
||||
allow_user_autostart: false,
|
||||
allow_user_autostop: false,
|
||||
failure_ttl_ms: 0,
|
||||
inactivity_ttl_ms: 0,
|
||||
}
|
||||
|
||||
const renderTemplateSettingsPage = async () => {
|
||||
@@ -36,7 +44,7 @@ const fillAndSubmitForm = async ({
|
||||
description,
|
||||
icon,
|
||||
allow_user_cancel_workspace_jobs,
|
||||
}: Required<Omit<UpdateTemplateMeta, "default_ttl_ms" | "max_ttl_ms">>) => {
|
||||
}: FormValues) => {
|
||||
const label = t("nameLabel", { ns: "templateSettingsPage" })
|
||||
const nameField = await screen.findByLabelText(label)
|
||||
await userEvent.clear(nameField)
|
||||
|
||||
@@ -11,15 +11,16 @@ import { checkAuthorization, getTemplateByName } from "api/api"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { useOrganizationId } from "hooks/useOrganizationId"
|
||||
|
||||
const templatePermissions = (templateId: string) => ({
|
||||
canUpdateTemplate: {
|
||||
object: {
|
||||
resource_type: "template",
|
||||
resource_id: templateId,
|
||||
const templatePermissions = (templateId: string) =>
|
||||
({
|
||||
canUpdateTemplate: {
|
||||
object: {
|
||||
resource_type: "template",
|
||||
resource_id: templateId,
|
||||
},
|
||||
action: "update",
|
||||
},
|
||||
action: "update",
|
||||
},
|
||||
})
|
||||
} as const)
|
||||
|
||||
const fetchTemplateSettings = async (orgId: string, name: string) => {
|
||||
const template = await getTemplateByName(orgId, name)
|
||||
|
||||
@@ -41,7 +41,6 @@ const defaultArgs: TemplateVersionPageViewProps = {
|
||||
tab,
|
||||
templateName: MockTemplate.name,
|
||||
versionName: MockTemplateVersion.name,
|
||||
canEdit: true,
|
||||
context: {
|
||||
templateName: MockTemplate.name,
|
||||
orgId: MockOrganization.id,
|
||||
|
||||
@@ -258,7 +258,7 @@ export const createWorkspaceMachine =
|
||||
},
|
||||
action: "create",
|
||||
},
|
||||
}
|
||||
} as const
|
||||
|
||||
return checkAuthorization({
|
||||
checks: permissionsToCheck,
|
||||
|
||||
@@ -29,16 +29,17 @@ export const checks = {
|
||||
updateWorkspace: "updateWorkspace",
|
||||
} as const
|
||||
|
||||
const permissionsToCheck = (workspace: TypesGen.Workspace) => ({
|
||||
[checks.updateWorkspace]: {
|
||||
object: {
|
||||
resource_type: "workspace",
|
||||
resource_id: workspace.id,
|
||||
owner_id: workspace.owner_id,
|
||||
const permissionsToCheck = (workspace: TypesGen.Workspace) =>
|
||||
({
|
||||
[checks.updateWorkspace]: {
|
||||
object: {
|
||||
resource_type: "workspace",
|
||||
resource_id: workspace.id,
|
||||
owner_id: workspace.owner_id,
|
||||
},
|
||||
action: "update",
|
||||
},
|
||||
action: "update",
|
||||
},
|
||||
})
|
||||
} as const)
|
||||
|
||||
export type WorkspaceScheduleEvent =
|
||||
| {
|
||||
|
||||
Reference in New Issue
Block a user