Add support for submodules and update heartwood

This commit is contained in:
Sebastian Martinez
2024-03-11 19:13:22 +01:00
committed by Rūdolfs Ošiņš
parent 953643c09c
commit 5b30269c7c
26 changed files with 183 additions and 86 deletions
+4 -1
View File
@@ -34,7 +34,10 @@
| ((body: string, embeds: Embed[]) => Promise<void>)
| undefined = undefined;
export let reactOnComment:
| ((nids: string[], reaction: string) => Promise<void>)
| ((
authors: Comment["reactions"][0]["authors"],
reaction: string,
) => Promise<void>)
| undefined = undefined;
</script>
+1 -1
View File
@@ -12,7 +12,7 @@
export let reactions: Comment["reactions"] | undefined = undefined;
const dispatch = createEventDispatcher<{
select: { emoji: string; authors: string[] };
select: Comment["reactions"][0];
}>();
</script>
+4 -1
View File
@@ -5,7 +5,10 @@
export let reactions: Comment["reactions"];
export let handleReaction:
| ((authors: string[], reaction: string) => Promise<void>)
| ((
authors: Comment["reactions"][0]["authors"],
reaction: string,
) => Promise<void>)
| undefined;
</script>
+5 -1
View File
@@ -25,7 +25,11 @@
| ((commentId: string, comment: string, embeds: Embed[]) => Promise<void>)
| undefined;
export let reactOnComment:
| ((commentId: string, nids: string[], reaction: string) => Promise<void>)
| ((
commentId: string,
authors: Comment["reactions"][0]["authors"],
reaction: string,
) => Promise<void>)
| undefined;
async function toggleReply() {
+18 -13
View File
@@ -1,4 +1,6 @@
<script lang="ts" strictEvents>
import type { Reaction } from "@httpd-client";
import { createEventDispatcher } from "svelte";
import { formatNodeId, parseNodeId } from "@app/lib/utils";
@@ -9,14 +11,16 @@
import IconSmall from "@app/components/IconSmall.svelte";
import TextInput from "@app/components/TextInput.svelte";
const dispatch = createEventDispatcher<{ save: string[] }>();
const dispatch = createEventDispatcher<{
save: Reaction["authors"];
}>();
export let locallyAuthenticated: boolean = false;
export let assignees: string[] = [];
export let assignees: Reaction["authors"] = [];
export let submitInProgress: boolean = false;
let showInput: boolean = false;
let updatedAssignees: string[] = assignees;
let updatedAssignees: Reaction["authors"] = assignees;
let inputValue = "";
let validationMessage: string | undefined = undefined;
let valid: boolean = false;
@@ -29,7 +33,7 @@
const parsedNodeId = parseNodeId(inputValue);
if (parsedNodeId) {
assignee = `${parsedNodeId.prefix}${parsedNodeId.pubkey}`;
if (updatedAssignees.includes(assignee)) {
if (!updatedAssignees.find(({ id }) => id === assignee)) {
valid = false;
validationMessage = "This assignee is already added";
} else {
@@ -48,7 +52,7 @@
function addAssignee() {
if (valid && assignee) {
updatedAssignees = [...updatedAssignees, assignee];
updatedAssignees = [...updatedAssignees, { id: assignee }];
inputValue = "";
dispatch("save", updatedAssignees);
showInput = false;
@@ -56,7 +60,7 @@
}
function removeAssignee(assignee: string) {
updatedAssignees = updatedAssignees.filter(x => x !== assignee);
updatedAssignees = updatedAssignees.filter(({ id }) => id !== assignee);
dispatch("save", updatedAssignees);
showInput = false;
}
@@ -98,15 +102,16 @@
variant="neutral"
size="small"
style="cursor: pointer;"
on:click={() => (removeToggles[assignee] = !removeToggles[assignee])}>
on:click={() =>
(removeToggles[assignee.id] = !removeToggles[assignee.id])}>
<div class="assignee">
<Avatar inline nodeId={assignee} />
<span>{formatNodeId(assignee)}</span>
{#if removeToggles[assignee]}
<Avatar inline nodeId={assignee.id} />
<span>{formatNodeId(assignee.id)}</span>
{#if removeToggles[assignee.id]}
<IconButton title="remove assignee">
<IconSmall
name="cross"
on:click={() => removeAssignee(assignee)} />
on:click={() => removeAssignee(assignee.id)} />
</IconButton>
{/if}
</div>
@@ -153,8 +158,8 @@
{#each updatedAssignees as assignee}
<Badge variant="neutral" size="small">
<div class="assignee">
<Avatar inline nodeId={assignee} />
<span>{formatNodeId(assignee)}</span>
<Avatar inline nodeId={assignee.id} />
<span>{formatNodeId(assignee.id)}</span>
</div>
</Badge>
{:else}
+5 -2
View File
@@ -63,12 +63,15 @@
| ((commentId: string, body: string, embeds: Embed[]) => Promise<void>)
| undefined;
export let reactOnRevision:
| ((authors: string[], reaction: string) => Promise<void>)
| ((
authors: Comment["reactions"][0]["authors"],
reaction: string,
) => Promise<void>)
| undefined;
export let reactOnComment:
| ((
commentId: string,
authors: string[],
authors: Comment["reactions"][0]["authors"],
reaction: string,
) => Promise<void>)
| undefined;
+13 -5
View File
@@ -1,9 +1,11 @@
<script lang="ts">
import type { Reaction } from "@httpd-client/lib/project/comment";
import type {
BaseUrl,
Comment,
Embed,
Issue,
IssueState,
Embed,
Project,
} from "@httpd-client";
import type { Session } from "@app/lib/httpd";
@@ -166,9 +168,10 @@
async function reactOnComment(
session: Session,
commentId: string,
nids: string[],
authors: Comment["reactions"][0]["authors"],
reaction: string,
) {
console.log(session.publicKey, authors);
try {
await api.project.updateIssue(
project.id,
@@ -177,7 +180,9 @@
type: "comment.react",
id: commentId,
reaction,
active: nids.includes(session.publicKey) ? false : true,
active: !authors.find(
({ id }) => utils.parseNodeId(id)?.pubkey === session.publicKey,
),
},
session.id,
);
@@ -275,12 +280,15 @@
}
}
async function saveAssignees(sessionId: string, assignees: string[]) {
async function saveAssignees(
sessionId: string,
assignees: Reaction["authors"],
) {
try {
await api.project.updateIssue(
project.id,
issue.id,
{ type: "assign", assignees },
{ type: "assign", assignees: assignees.map(({ id }) => id) },
sessionId,
);
} catch (error) {
+9 -3
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import type { BaseUrl, Embed, Project } from "@httpd-client";
import type { BaseUrl, Embed, Project, Reaction } from "@httpd-client";
import * as modal from "@app/lib/modal";
import * as router from "@app/lib/router";
@@ -21,7 +21,7 @@
export let rawPath: (commit?: string) => string;
let issueTitle = "";
let assignees: string[] = [];
let assignees: Reaction["authors"] = [];
let labels: string[] = [];
const api = new HttpdClient(baseUrl);
@@ -35,7 +35,13 @@
try {
const result = await api.project.createIssue(
project.id,
{ title, description, assignees, embeds: [...embeds.values()], labels },
{
title,
description,
assignees: assignees.map(a => a.id),
embeds: [...embeds.values()],
labels,
},
sessionId,
);
+4 -4
View File
@@ -208,7 +208,7 @@
session: Session,
revisionId: string,
commentId: string,
authors: string[],
authors: Comment["reactions"][0]["authors"],
reaction: string,
) {
try {
@@ -220,7 +220,7 @@
revision: revisionId,
comment: commentId,
reaction,
active: authors.includes(session.publicKey) ? false : true,
active: Boolean(authors.find(({ id }) => id === session.publicKey)),
},
session.id,
);
@@ -367,7 +367,7 @@
async function reactOnRevision(
session: Session,
revisionId: string,
authors: string[],
authors: Revision["reactions"][0]["authors"],
reaction: string,
) {
try {
@@ -378,7 +378,7 @@
type: "revision.react",
revision: revisionId,
reaction,
active: authors.includes(session.publicKey) ? false : true,
active: Boolean(authors.find(({ id }) => id === session.publicKey)),
},
session.id,
);
+3
View File
@@ -6,6 +6,7 @@
import File from "./Tree/File.svelte";
import Folder from "./Tree/Folder.svelte";
import Link from "@app/components/Link.svelte";
import Submodule from "./Tree/Submodule.svelte";
export let baseUrl: BaseUrl;
export let fetchTree: (path: string) => Promise<Tree | undefined>;
@@ -33,6 +34,8 @@
{peer}
{projectId}
{revision} />
{:else if entry.kind === "submodule"}
<Submodule name={entry.name} oid={entry.oid} />
{:else}
<Link
route={{
@@ -0,0 +1,43 @@
<script lang="ts">
import IconSmall from "@app/components/IconSmall.svelte";
import { formatCommit } from "@app/lib/utils";
export let name: string;
export let oid: string;
</script>
<style>
.file {
border-radius: var(--border-radius-tiny);
display: flex;
line-height: 1.5em;
margin: 0.25rem 0;
padding: 0.25rem 0.875rem;
width: 100%;
}
.name {
margin-left: 0.25rem;
user-select: none;
white-space: nowrap;
text-overflow: ellipsis !important;
color: var(--color-foreground-dim);
overflow: hidden;
font-size: var(--font-size-small);
font-weight: var(--font-weight-medium);
}
.icon-container {
color: var(--color-fill-secondary);
display: flex;
justify-content: center;
align-items: center;
margin-right: 0.125rem;
}
</style>
<div class="file">
<div class="icon-container">
<IconSmall name="link" />
</div>
<span class="name">{name} @ {formatCommit(oid)}</span>
</div>