Browse Source

Fix blocing enum on user config page

pull/31/head
Sacha Weatherstone 4 years ago
parent
commit
1dd239ca09
No known key found for this signature in database GPG Key ID: 7AB2D7E206124B31
  1. 2
      package.json
  2. 532
      pnpm-lock.yaml
  3. 14
      src/components/PageComponents/Config/User.tsx
  4. 11
      src/validation/config/user.ts

2
package.json

@ -48,7 +48,7 @@
"devDependencies": { "devDependencies": {
"@types/chrome": "^0.0.193", "@types/chrome": "^0.0.193",
"@types/geodesy": "^2.2.3", "@types/geodesy": "^2.2.3",
"@types/node": "^18.6.3", "@types/node": "^18.6.4",
"@types/react": "^18.0.15", "@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6", "@types/react-dom": "^18.0.6",
"@types/w3c-web-serial": "^1.0.2", "@types/w3c-web-serial": "^1.0.2",

532
pnpm-lock.yaml

File diff suppressed because it is too large

14
src/components/PageComponents/Config/User.tsx

@ -51,14 +51,6 @@ export const User = (): JSX.Element => {
return ( return (
<Form loading={loading} dirty={isDirty} onSubmit={onSubmit}> <Form loading={loading} dirty={isDirty} onSubmit={onSubmit}>
{JSON.stringify(errors.antAzimuth?.message)}
{JSON.stringify(errors.antGainDbi?.message)}
{JSON.stringify(errors.hwModel?.message)}
{JSON.stringify(errors.id?.message)}
{JSON.stringify(errors.isLicensed?.message)}
{JSON.stringify(errors.longName?.message)}
{JSON.stringify(errors.shortName?.message)}
{JSON.stringify(errors.txPowerDbm?.message)}
<TextInputField <TextInputField
label="Device ID" label="Device ID"
description="Preset unique identifier for this device." description="Preset unique identifier for this device."
@ -88,16 +80,12 @@ export const User = (): JSX.Element => {
.match(/.{1,2}/g) .match(/.{1,2}/g)
?.join(":") ?? "" ?.join(":") ?? ""
} }
readOnly
/> />
<SelectField <SelectField
label="Hardware" label="Hardware"
description="This is a description." description="This is a description."
disabled disabled
isInvalid={!!errors.hwModel?.message} value={myNode?.data.user?.hwModel}
validationMessage={errors.hwModel?.message}
{...register("hwModel", { valueAsNumber: true })}
// readOnly
> >
{renderOptions(Protobuf.HardwareModel)} {renderOptions(Protobuf.HardwareModel)}
</SelectField> </SelectField>

11
src/validation/config/user.ts

@ -1,8 +1,10 @@
import { IsBoolean, IsEnum, IsInt, Length } from "class-validator"; import { IsBoolean, IsInt, Length } from "class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs"; import type { Protobuf } from "@meshtastic/meshtasticjs";
export class UserValidation implements Omit<Protobuf.User, "macaddr"> { export class UserValidation
implements Omit<Protobuf.User, "macaddr" | "hwModel">
{
@Length(2, 30) @Length(2, 30)
id: string; id: string;
@ -12,9 +14,6 @@ export class UserValidation implements Omit<Protobuf.User, "macaddr"> {
@Length(1, 4) @Length(1, 4)
shortName: string; shortName: string;
@IsEnum(Protobuf.HardwareModel)
hwModel: Protobuf.HardwareModel;
@IsBoolean() @IsBoolean()
isLicensed: boolean; isLicensed: boolean;

Loading…
Cancel
Save