Skip to content

Commit

Permalink
Enhancing feature error msg in manual filter (#3839)
Browse files Browse the repository at this point in the history
* Enhancing feature error msg in manual filter

* Fix error message text structure

* Enhancing error message by adding NetworkFeatures enum

* Removing ipv4 from NetworkFeatures

* Filtering ipv4 from missing features as ip is already added

* Reverting to using or
  • Loading branch information
maayarosama authored Feb 10, 2025
1 parent 412670a commit 884ab23
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { gridProxyClient } from "../../clients";
import { useAsync, useWatchDeep } from "../../hooks";
import { ValidatorStatus } from "../../hooks/form_validator";
import { useGrid } from "../../stores";
import { NetworkFeatures } from "../../types";
import type { SelectedMachine, SelectionDetailsFilters } from "../../types/nodeSelector";
import { normalizeError } from "../../utils/helpers";
import {
Expand Down Expand Up @@ -136,7 +137,7 @@ export default {
placeholderNode.value = node;
const features = getFeatures(gridStore, filters.value);
const missingFeatures = features.filter(value => !node.features.includes(value as Features));
let missingFeatures = features.filter(value => !node.features.includes(value as Features));
if (node === undefined || node === null) {
throw `Node ${nodeId} is not on the grid`;
}
Expand Down Expand Up @@ -177,7 +178,14 @@ export default {
case props.filters.ipv4 && farms[0].publicIps.every(p => p.contract_id !== 0):
throw `Node ${nodeId} is not assigned to a PublicIP`;
case missingFeatures.length > 0:
throw `Node ${nodeId} doesn't support [ ${missingFeatures} ] features`;
missingFeatures = missingFeatures.filter(feature => feature !== "ipv4");
throw `Node ${nodeId} does not support ${missingFeatures
.slice(0, -1)
.map(feature => NetworkFeatures[feature as keyof typeof NetworkFeatures])
.join(", ")}${missingFeatures.length > 1 ? " or " : ""}${
NetworkFeatures[missingFeatures[missingFeatures.length - 1] as keyof typeof NetworkFeatures]
} Feature${missingFeatures.length > 1 ? "s" : ""}. Please check compatibility or upgrade the node.`;
}
const args = [nodeId, "proxy", gridStore.client.config.proxyURL] as const;
Expand Down
7 changes: 7 additions & 0 deletions packages/playground/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export type InputFilterType = {
type: string;
};

export enum NetworkFeatures {
ip = "IP",
mycelium = "Mycelium",
wireguard = "Wireguard",
yggdrasil = "Planetary",
}

export type CPUBenchmark = {
multi: number;
single: number;
Expand Down

0 comments on commit 884ab23

Please sign in to comment.