Skip to content

Commit

Permalink
fix missing exhaustive cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizi committed Jan 6, 2025
1 parent a9900e8 commit 06eecc1
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ export function useForm<Schema extends types.TSchema, SubmitResult = void>(
return {
message: getText('arbitraryFieldInvalid'),
}
case 'invalid_literal':
case 'invalid_enum_value':
case 'invalid_union':
case 'unrecognized_keys':
case 'invalid_union_discriminator':
case 'invalid_arguments':
case 'invalid_return_type':
case 'invalid_string':
case 'not_multiple_of':
case 'custom':
case 'invalid_intersection_types':
case 'invalid_date':
case 'not_finite':
default:
return {
message: getText('arbitraryFieldInvalid'),
Expand Down
2 changes: 2 additions & 0 deletions app/gui/src/dashboard/components/SelectionBrush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ function calculateRectangleFromScrollDirection(
bottom: start.bottom - diff.top,
left: start.left - diff.left,
}
case DIRECTION.NONE:
default:
return start
}
Expand Down Expand Up @@ -558,6 +559,7 @@ function calculateNewStartPositionFromScrollDirection(
top: rectangle.bottom,
left: rectangle.left,
}
case DIRECTION.NONE:
default:
return start
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ export default function PermissionSelector(props: PermissionSelectorProps) {
)
break
}
case permissions.Permission.owner:
case permissions.Permission.admin:
case permissions.Permission.edit:
default: {
permissionDisplay = (
<ariaComponents.Button
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function run(props: DashboardProps) {
(breadcrumb) =>
breadcrumb.type === 'http' &&
breadcrumb.category === 'fetch' &&
breadcrumb.data &&
breadcrumb.data != null &&
breadcrumb.data.status_code === HTTP_STATUS_BAD_REQUEST &&
typeof breadcrumb.data.url === 'string' &&
new URL(breadcrumb.data.url).host === API_HOST,
Expand Down
4 changes: 4 additions & 0 deletions app/gui/src/dashboard/layouts/AssetsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,10 @@ function AssetsTable(props: AssetsTableProps) {
)
break
}
case AssetType.file:
case AssetType.specialLoading:
case AssetType.specialEmpty:
case AssetType.specialError:
default: {
break
}
Expand Down
3 changes: 3 additions & 0 deletions app/gui/src/dashboard/layouts/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,9 @@ export default function Chat(props: ChatProps) {
setMessages((oldMessages) => [...newMessages, ...oldMessages])
break
}
case chat.ChatMessageDataType.authenticate:
case chat.ChatMessageDataType.newThread:
case chat.ChatMessageDataType.switchThread:
default: {
setMessages(newMessages)
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function AuthenticationPage<Schema extends TSchema>(
const { isOffline } = useOffline()

const heading =
title ?
title != null ?
<Text.Heading level={1} className="self-center" weight="medium">
{title}
</Text.Heading>
Expand Down
4 changes: 4 additions & 0 deletions app/gui/src/dashboard/pages/authentication/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export default function Login() {
setUser(res.user)
nextStep()
break
case 'CUSTOM_CHALLENGE':
case 'MFA_SETUP':
case 'NEW_PASSWORD_REQUIRED':
case 'SELECT_MFA_TYPE':
default:
throw new Error('Unsupported challenge')
}
Expand Down
1 change: 1 addition & 0 deletions app/gui/src/dashboard/services/LocalBackend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export function extractTypeAndId<Id extends backend.AssetId>(id: Id): AssetTypeA
case backend.AssetType.file: {
return { type: backend.AssetType.file, id: projectManager.Path(idRaw) }
}
case undefined:
default: {
throw new Error(`Invalid type '${typeRaw}'`)
}
Expand Down
1 change: 1 addition & 0 deletions app/gui/src/dashboard/utilities/fileIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import TextIcon from '#/assets/text.svg'

/** Return the appropriate icon given the file name. */
export function fileIcon() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return TextIcon
}
5 changes: 5 additions & 0 deletions app/gui/src/dashboard/utilities/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ const appExtension = (() => {
return '.dmg'
case detect.Platform.windows:
return '.exe'
case detect.Platform.unknown:
case detect.Platform.linux:
case detect.Platform.windowsPhone:
case detect.Platform.iPhoneOS:
case detect.Platform.android:
default:
// assume Unix-like.
return '.AppImage'
Expand Down
8 changes: 7 additions & 1 deletion app/gui/src/dashboard/utilities/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ export function tryCreateOwnerPermission(
case 'team': {
return [{ userGroup: category.team, permission: PermissionAction.own }]
}
case 'cloud':
case 'recent':
case 'trash':
case 'user':
case 'local':
case 'local-directory':
default: {
const isFreeOrSolo =
user.plan == null || user.plan === backend.Plan.free || user.plan === backend.Plan.solo
const owner = isFreeOrSolo ? user : newOwnerFromPath(path, users, userGroups) ?? user
const owner = isFreeOrSolo ? user : (newOwnerFromPath(path, users, userGroups) ?? user)
if ('userId' in owner) {
const { organizationId, userId, name, email } = owner
return [{ user: { organizationId, userId, name, email }, permission: PermissionAction.own }]
Expand Down

0 comments on commit 06eecc1

Please sign in to comment.