Skip to content

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinez committed Jun 13, 2024
1 parent 29c0bbb commit 3dc8985
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 52 deletions.
22 changes: 0 additions & 22 deletions src/views/projects/Source/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,6 @@
}
$: lastCommit = tree.lastCommit;
// $: peersWithRoute = peers.map(remote => ({
// remote,
// route: {
// resource: "project.source",
// node,
// project: project.id,
// peer: remote.id,
// revision: remote.heads[project.defaultBranch]
// ? undefined
// : Object.keys(remote.heads)[0],
// } as Route,
// }));
// $: branchesWithRoute = branches.map(name => ({
// name,
// route: {
// resource: "project.source",
// node,
// project: project.id,
// peer,
// revision: name,
// } as Route,
// }));
</script>

<style>
Expand Down
71 changes: 41 additions & 30 deletions src/views/projects/Source/SourceSelector.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<script lang="ts">
import type { BaseUrl, Project, Remote } from "@http-client";
import { search } from "@app/lib/search";
import { formatCommit } from "@app/lib/utils";
import Badge from "@app/components/Badge.svelte";
import Button from "@app/components/Button.svelte";
import DropdownListItem from "@app/components/DropdownList/DropdownListItem.svelte";
import IconSmall from "@app/components/IconSmall.svelte";
import Link from "@app/components/Link.svelte";
import NodeId from "@app/components/NodeId.svelte";
import PeerItem from "./SourceSelector/PeerItem.svelte";
import Popover, { closeFocused } from "@app/components/Popover.svelte";
import TextInput from "@app/components/TextInput.svelte";
import Link from "@app/components/Link.svelte";
import { activeUnloadedRouteStore } from "@app/lib/router";
import { search } from "@app/lib/search";
export let peers: Remote[];
export let peer: string | undefined;
Expand All @@ -25,13 +24,6 @@
let searchInput = "";
let searchResults: string[] = [];
// function createTitle(p: Remote): string {
// const nodeId = formatNodeId(p.id);
// return p.delegate
// ? `${nodeId} is a delegate of this project`
// : `${nodeId} is a peer followed by this node`;
// }
$: selectedPeer = peers.find(p => p.id === peer);
</script>

Expand Down Expand Up @@ -100,22 +92,25 @@
<div slot="popover" class="dropdown">
<TextInput
placeholder="Search"
on:blur={() => {
searchInput = "";
searchResults = [];
}}
bind:value={searchInput}
on:input={() => {
searchResults = search(
peers.flatMap(peer =>
Object.entries(peer.heads).map(([name, head]) =>
JSON.stringify({
peer: { alias: peer.alias, id: peer.id },
revision: name,
head,
}),
[
JSON.stringify({
peer: undefined,
revision: project.defaultBranch,
head: project.head,
}),
...peers.flatMap(peer =>
Object.entries(peer.heads).map(([name, head]) =>
JSON.stringify({
peer: { alias: peer.alias, id: peer.id },
revision: name,
head,
}),
),
),
),
],
searchInput,
);
}} />
Expand All @@ -129,22 +124,36 @@
<Link
style="display: grid; grid-template-columns: subgrid; grid-column: span 2;"
route={{
...$activeUnloadedRouteStore,
resource: "project.source",
node,
project: project.id,
peer: parsedResult.peer.id,
peer: parsedResult.peer?.id,
revision: parsedResult.revision,
path: "/",
}}
on:afterNavigate={() => closeFocused()}>
on:afterNavigate={() => {
closeFocused();
searchInput = "";
}}>
<DropdownListItem
selected={false}
style="display: grid; gap: inherit; grid-template-columns: subgrid; grid-column: span 2;">
<div style="display: flex; gap: 0.5rem;">
<div style="display: flex; gap: 0.5rem; align-items: center;">
<IconSmall name="branch" />
<span class="txt-overflow">
{parsedResult.peer.alias || parsedResult.peer.id} / {parsedResult.revision}
{#if parsedResult.peer}
{parsedResult.peer.alias || parsedResult.peer.id} / {parsedResult.revision}
{:else}
<div
style="display: flex; gap: 0.5rem; align-items: center;">
{parsedResult.revision}
<Badge
title="Canonical branch"
variant="foreground-emphasized">
Canonical
</Badge>
</div>
{/if}
</span>
</div>
<div
Expand All @@ -165,14 +174,16 @@
<Link
style="display: grid; grid-template-columns: subgrid; grid-column: span 2;"
route={{
...$activeUnloadedRouteStore,
resource: "project.source",
peer: undefined,
revision: project.defaultBranch,
project: project.id,
node,
path: "/",
}}
on:afterNavigate={() => closeFocused()}>
on:afterNavigate={() => {
closeFocused();
searchInput = "";
}}>
<DropdownListItem
selected={false}
style="display: grid; gap: inherit; grid-template-columns: subgrid; grid-column: span 2;">
Expand Down

0 comments on commit 3dc8985

Please sign in to comment.