From 393d82b71e704dfdb6377d438c6e5926780304f6 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 12 Jun 2024 16:05:19 +0200 Subject: [PATCH] wip --- .../DropdownList/DropdownListItem.svelte | 2 + src/views/projects/Source.svelte | 37 +---- .../projects/Source/BranchSelector.svelte | 4 - src/views/projects/Source/Header.svelte | 50 ++++-- src/views/projects/Source/PeerSelector.svelte | 130 ---------------- .../projects/Source/SourceSelector.svelte | 145 ++++++++++++++++++ .../Source/SourceSelector/PeerItem.svelte | 84 ++++++++++ src/views/projects/router.ts | 11 +- 8 files changed, 274 insertions(+), 189 deletions(-) delete mode 100644 src/views/projects/Source/PeerSelector.svelte create mode 100644 src/views/projects/Source/SourceSelector.svelte create mode 100644 src/views/projects/Source/SourceSelector/PeerItem.svelte diff --git a/src/components/DropdownList/DropdownListItem.svelte b/src/components/DropdownList/DropdownListItem.svelte index a670d74b54..cf1957b629 100644 --- a/src/components/DropdownList/DropdownListItem.svelte +++ b/src/components/DropdownList/DropdownListItem.svelte @@ -2,6 +2,7 @@ export let selected: boolean; export let disabled: boolean = false; export let title: string | undefined = undefined; + export let style: string | undefined = undefined;
- {#if peers.length > 0} - - {/if} - - +
+
diff --git a/src/views/projects/Source/PeerSelector.svelte b/src/views/projects/Source/PeerSelector.svelte deleted file mode 100644 index fd9160ad2a..0000000000 --- a/src/views/projects/Source/PeerSelector.svelte +++ /dev/null @@ -1,130 +0,0 @@ - - - - -
- - - - - - closeFocused()} route={item.route}> - -
- -
- - {item.remote.alias || formatNodeId(item.remote.id)} - - {#if $httpdStore.state !== "stopped" && item.remote.id === $httpdStore.node.id} - - You - - {/if} - {#if item.remote.delegate} - - - Delegate - - {/if} -
- -
-
-
- {#if selectedPeer} - - - - {/if} -
diff --git a/src/views/projects/Source/SourceSelector.svelte b/src/views/projects/Source/SourceSelector.svelte new file mode 100644 index 0000000000..265facc43e --- /dev/null +++ b/src/views/projects/Source/SourceSelector.svelte @@ -0,0 +1,145 @@ + + + + +
+ + + + + +
diff --git a/src/views/projects/Source/SourceSelector/PeerItem.svelte b/src/views/projects/Source/SourceSelector/PeerItem.svelte new file mode 100644 index 0000000000..a5e9e083f4 --- /dev/null +++ b/src/views/projects/Source/SourceSelector/PeerItem.svelte @@ -0,0 +1,84 @@ + + +
+
+ (expanded = !expanded)}> + + +
+ +
+ + {peer.remote.alias || formatNodeId(peer.remote.id)} + + {#if peer.remote.delegate} + + + Delegate + + {/if} +
+
+{#if expanded} + {#each Object.entries(peer.remote.heads) as [name, head]} + closeFocused()}> + + replace({ + ...$activeUnloadedRouteStore, + resource: "project.source", + peer: peer.remote.id, + revision: name, + project: projectId, + node, + })} + selected={false} + style="display: grid; padding-left: 2.3rem; gap: inherit; grid-template-columns: subgrid; grid-column: span 2;"> +
+ {name} +
+
+ + {formatCommit(head)} + +
+
+ + {/each} +{/if} diff --git a/src/views/projects/router.ts b/src/views/projects/router.ts index 27cf29af9d..a01e80252e 100644 --- a/src/views/projects/router.ts +++ b/src/views/projects/router.ts @@ -438,7 +438,9 @@ async function loadTreeView( isLocalNodeSeeding(route), ]); - let branchMap: Record; + let branchMap: Record = { + [project.defaultBranch]: project.head, + }; if (route.peer) { const peer = peers.find(peer => peer.id === route.peer); if (!peer) { @@ -449,15 +451,10 @@ async function loadTreeView( } else { branchMap = peer.heads; } - } else { - branchMap = { [project.defaultBranch]: project.head }; } if (route.route) { - const { revision, path } = detectRevision( - route.route, - branchMap || { [project.defaultBranch]: project.head }, - ); + const { revision, path } = detectRevision(route.route, branchMap); route.revision = revision; route.path = path; }