Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
Display user agent instead of version
Sebastian Martinez committed 1 year ago
commit f21a80167c80477593697f5a822a7244e7055cbb
parent ce842b0
6 files changed +20 -10
modified http-client/index.ts
@@ -94,7 +94,7 @@ export type Node = z.infer<typeof nodeSchema>;

const nodeSchema = object({
  id: string(),
-
  version: string(),
+
  agent: string(),
  config: nodeConfigSchema.nullable(),
  state: union([literal("running"), literal("stopped")]),
});
modified src/lib/utils.ts
@@ -21,6 +21,11 @@ export function formatShortSeedingPolicy(
    : "restrictive";
}

+
// Removes the first and last character which are always `/`.
+
export function formatUserAgent(agent: string): string {
+
  return agent.slice(1, -1);
+
}
+

export function parseNodeId(
  nid: string,
): { prefix: string; pubkey: string } | undefined {
modified src/views/nodes/View.svelte
@@ -8,6 +8,7 @@
  import {
    baseUrlToString,
    formatShortSeedingPolicy,
+
    formatUserAgent,
    isLocal,
    truncateId,
  } from "@app/lib/utils";
@@ -28,8 +29,8 @@
  export let nid: string;
  export let stats: NodeStats;
  export let externalAddresses: string[];
-
  export let version: string;
  export let seedingPolicy: DefaultSeedingPolicy | undefined = undefined;
+
  export let agent: string;

  $: shortScope = formatShortSeedingPolicy(seedingPolicy);
  $: hostname = isLocal(baseUrl.hostname) ? "Local Node" : baseUrl.hostname;
@@ -73,7 +74,7 @@
    display: flex;
    justify-content: space-between;
  }
-
  .version {
+
  .agent {
    color: var(--color-fill-gray);
    font-family: var(--font-family-monospace);
    font-size: var(--font-size-small);
@@ -147,9 +148,13 @@
              </div>
            {/each}
          </div>
-
          <Id ariaLabel="version" id={version} shorten={false} style="none">
-
            <div class="version">
-
              {version}
+
          <Id
+
            ariaLabel="agent"
+
            id={formatUserAgent(agent)}
+
            shorten={false}
+
            style="none">
+
            <div class="agent">
+
              {formatUserAgent(agent)}
            </div>
          </Id>
        </div>
modified src/views/nodes/router.ts
@@ -22,7 +22,7 @@ export interface NodesLoadedRoute {
  resource: "nodes";
  params: {
    baseUrl: BaseUrl;
-
    version: string;
+
    agent: string;
    externalAddresses: string[];
    nid: string;
    stats: NodeStats;
@@ -54,8 +54,8 @@ export async function loadNodeRoute(
        nid: node.id,
        stats,
        externalAddresses: node.config?.externalAddresses ?? [],
-
        version: node.version,
        seedingPolicy: node.config?.seedingPolicy,
+
        agent: node.agent,
      },
    };
  } catch (error) {
modified tests/e2e/landingPage.spec.ts
@@ -94,7 +94,7 @@ test("stored custom preferred seeds in local storage", async ({ page }) => {

const nodeInfo = {
  id: "z6MkkGfMNQmjrp66Po2n4snzcSyTFRFw1m1fbYhCURxLxZpD",
-
  version: "1.0.0-rc.9-d56d619f",
+
  agent: "/radicle:1.0.0-rc.11/",
  config: {
    alias: "rhizoma",
    listen: [],
modified tests/e2e/node.spec.ts
@@ -17,7 +17,7 @@ test("node metadata", async ({ page, peerManager }) => {
  await expect(
    page.getByText(`${shortNodeRemote}@seed.radicle.test:8123`),
  ).toBeVisible();
-
  await expect(page.getByText("pre-release")).toBeVisible();
+
  await expect(page.getByText("radicle:1.0.0-rc.11")).toBeVisible();
});

test("node projects", async ({ page }) => {