Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Replace NIDs in `AssigneeInput` with found alias.
Merged did:key:z6MkkfM3...sVz5 opened 1 year ago
  • Add alias tauri command
    • Returns either null or string for a lookup of an alias.

checkcheck-e2e

👉 Workflow runs 👉 Branch on GitHub

6 files changed +40 -14 4f046343 3109e1d2
modified crates/radicle-tauri/src/commands/profile.rs
@@ -1,3 +1,4 @@
+
use radicle::node::NodeId;
use radicle_types::config::Config;
use radicle_types::traits::Profile;

@@ -7,3 +8,8 @@ use crate::AppState;
pub fn config(ctx: tauri::State<AppState>) -> Config {
    ctx.config()
}
+

+
#[tauri::command]
+
pub fn alias(ctx: tauri::State<AppState>, nid: NodeId) -> Option<radicle::node::Alias> {
+
    ctx.alias(nid)
+
}
modified crates/radicle-tauri/src/lib.rs
@@ -95,6 +95,7 @@ pub fn run() {
            thread::create_issue_comment,
            thread::create_patch_comment,
            profile::config,
+
            profile::alias,
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
modified crates/radicle-types/src/traits.rs
@@ -1,3 +1,5 @@
+
use radicle::node::{AliasStore, NodeId};
+

use crate::config::Config;

pub mod auth;
@@ -19,6 +21,13 @@ pub trait Profile {
            seeding_policy: p.config.node.seeding_policy,
        }
    }
+

+
    fn alias(&self, nid: NodeId) -> Option<radicle::node::Alias> {
+
        let p = self.profile();
+
        let aliases = p.aliases();
+

+
        aliases.alias(&nid)
+
    }
}

#[cfg(test)]
modified src/components/AssigneeInput.svelte
@@ -1,7 +1,12 @@
<script lang="ts">
  import type { Author } from "@bindings/cob/Author";

-
  import { authorForNodeId, parseNodeId } from "@app/lib/utils";
+
  import {
+
    authorForNodeId,
+
    parseNodeId,
+
    publicKeyFromDid,
+
  } from "@app/lib/utils";
+
  import { invoke } from "@app/lib/invoke";

  import Icon from "@app/components/Icon.svelte";
  import NodeId from "@app/components/NodeId.svelte";
@@ -11,12 +16,12 @@
    allowedToEdit: boolean;
    assignees: Author[];
    submitInProgress: boolean;
-
    save: (updatedAssignees: string[]) => void;
+
    save: (updatedAssignees: Author[]) => void;
  }

  const {
    allowedToEdit = false,
-
    assignees,
+
    assignees = $bindable(),
    submitInProgress = false,
    save,
  }: Props = $props();
@@ -64,11 +69,17 @@
    }
  });

-
  function addAssignee() {
+
  async function addAssignee() {
    if (valid && assignee) {
-
      updatedAssignees = [...updatedAssignees, { did: assignee }];
+
      const alias = await invoke<string | null>("alias", {
+
        nid: publicKeyFromDid(assignee),
+
      });
+
      updatedAssignees = [
+
        ...updatedAssignees,
+
        { did: assignee, alias: alias ?? undefined },
+
      ];
      inputValue = "";
-
      save($state.snapshot(updatedAssignees.map(x => x.did)));
+
      save($state.snapshot(updatedAssignees));
      showInput = false;
    }
  }
@@ -77,7 +88,7 @@
    updatedAssignees = updatedAssignees.filter(
      ({ did }) => did !== assignee.did,
    );
-
    save($state.snapshot(updatedAssignees.map(x => x.did)));
+
    save($state.snapshot(updatedAssignees));
    showInput = false;
  }
</script>
modified src/views/repo/CreateIssue.svelte
@@ -1,4 +1,5 @@
<script lang="ts">
+
  import type { Author } from "@bindings/cob/Author";
  import type { Config } from "@bindings/config/Config";
  import type { Issue } from "@bindings/cob/issue/Issue";
  import type { RepoInfo } from "@bindings/repo/RepoInfo";
@@ -41,7 +42,7 @@

  const embeds: { name: string; content: string }[] = [];

-
  let assignees: string[] = $state([]);
+
  let assignees: Author[] = $state([]);
  let labels: string[] = $state([]);

  async function createIssue() {
@@ -51,7 +52,7 @@
        title,
        description,
        labels: $state.snapshot(labels),
-
        assignees: $state.snapshot(assignees),
+
        assignees: $state.snapshot(assignees.map(a => a.did)),
        embeds,
      },
      opts: { announce: $nodeRunning && $announce },
@@ -161,9 +162,7 @@
        <div class="metadata-section" style:flex="1">
          <AssigneeInput
            allowedToEdit={true}
-
            assignees={assignees.map(assignee => {
-
              return { did: assignee };
-
            })}
+
            bind:assignees
            submitInProgress={false}
            save={newAssignees => {
              assignees = newAssignees;
modified src/views/repo/Issue.svelte
@@ -103,7 +103,7 @@
    }
  }

-
  async function saveAssignees(assignees: string[]) {
+
  async function saveAssignees(assignees: Author[]) {
    try {
      assigneesSaveInProgress = true;
      await invoke("edit_issue", {
@@ -111,7 +111,7 @@
        cobId: issue.id,
        action: {
          type: "assign",
-
          assignees,
+
          assignees: assignees.map(a => a.did),
        },
        opts: { announce: $nodeRunning && $announce },
      });