Skip to content

Commit

Permalink
feat: update custom trust list name
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-mader committed Dec 3, 2024
1 parent ccbb283 commit c6739e8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
5 changes: 2 additions & 3 deletions identity-wallet/resources/default_trust_list.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"id": "b01f4a74-3005-4749-a030-c5444bc4dab5",
"display_name": "Impierce (Development)",
"domains": [
"https://agent-dev.impierce.com",
"display_name": "Impierce Demos",
"entries": [
"https://ngdil.com",
"https://selv.iota.org",
"https://thuiswinkel-agent.dev.impierce.com"
Expand Down
2 changes: 1 addition & 1 deletion identity-wallet/src/state/trust_list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct TrustList {
/// Custom true: TrustList's can be created in dev mode at any time.
#[serde(default)]
pub custom: bool,
#[serde(alias = "domains", deserialize_with = "deserialize_domains")]
#[serde(deserialize_with = "deserialize_domains")]
#[ts(type = "Record<string, boolean>")]
pub entries: HashMap<url::Url, bool>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ pub async fn trust_list_edit(state: AppState, action: Action) -> Result<AppState
.get_mut(&action.trust_list_id)
.ok_or_else(|| AppError::TrustListNotFoundError(action.trust_list_id.clone()))?;

let display_name_before = trust_list.display_name.clone();

trust_list.display_name = action.new_display_name.clone();

info!("Edited trust list {}", action.new_display_name);
info!(
"Updated trust list name: `{}` --> `{}`",
display_name_before, action.new_display_name
);

return Ok(AppState {
trust_lists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let newEntryInputElement: HTMLInputElement;
let showNewEntry = false;
let newEntryValue = '';
$: updatedListName = trustList?.display_name;
</script>

<TopNavBar on:back={() => history.back()} title={trustList?.display_name ?? ''}>
Expand Down Expand Up @@ -43,6 +44,30 @@
<div class="content-height flex flex-col bg-silver dark:bg-navy">
<div class="space-y-[15px] px-4 py-5">
<div class="flex flex-col space-y-[10px]">
{#if trustList?.custom}
<p class="text-[14px]/[22px] font-medium text-slate-500 dark:text-slate-300">Update list name</p>
<div class="flex space-x-[10px]">
<input
type="text"
class="h-12 grow rounded-xl border border-slate-200 px-3 text-[13px]/[24px] text-teal disabled:text-slate-400 disabled:opacity-60 dark:border-slate-600 dark:bg-dark"
value={trustList?.display_name}
on:input={(e) => (updatedListName = e.target.value)}
/>
<div class="ml-2 w-[88px]">
<Button
label="Save"
on:click={() => {
dispatch({
type: '[Trust Lists] Edit',
payload: { trust_list_id: $page.params.id, new_display_name: updatedListName },
});
}}
disabled={updatedListName === trustList?.display_name}
/>
</div>
</div>
{/if}
<!-- <div class="h-12 border bg-background-alt"></div> -->
<p class="text-[14px]/[22px] font-medium text-slate-500 dark:text-slate-300">Trusted issuers</p>
<!-- {#each Object.entries(entries) as [domain, active], i (domain)}
<div class="flex flex-row items-center space-x-2">
Expand Down Expand Up @@ -115,7 +140,7 @@
bind:this={newEntryInputElement}
bind:value={newEntryValue}
/>
<button
<!-- <button
class="rounded-full p-2 disabled:opacity-50 disabled:grayscale"
on:click={() => {
dispatch({
Expand All @@ -128,10 +153,22 @@
disabled={!newEntryValue}
>
<PlusBoldIcon class="h-5 w-5 text-primary" />
</button>
</button> -->
<!-- Placeholder with the same dimensions of a Switch for better visual alignment -->
<div class="w-11"></div>
<!-- <div class="w-11"></div> -->
</div>
<Button
label="Save"
on:click={() => {
dispatch({
type: '[Trust List] Add entry',
payload: { trust_list_id: $page.params.id, domain: newEntryValue },
});
newEntryValue = '';
showNewEntry = false;
}}
disabled={!newEntryValue}
/>
{:else}
<Button
label="Add trusted domain"
Expand All @@ -149,7 +186,7 @@
<p
class={`grow text-left text-[13px]/[24px] font-medium text-slate-800 dark:text-white ${active ? '' : 'opacity-50'}`}
>
{domain}
{URL.parse(domain)?.hostname}
</p>
{#key active}
<Switch
Expand Down

0 comments on commit c6739e8

Please sign in to comment.