mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 02:00:31 +08:00
Allow opening links in a new tab
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
import { lineNumbersGutter } from "@app/lib/syntax";
|
||||
import { updateProjectRoute } from "@app/lib/router";
|
||||
|
||||
import HeaderToggleLabel from "@app/views/projects/HeaderToggleLabel.svelte";
|
||||
import Readme from "@app/views/projects/Readme.svelte";
|
||||
import SquareButton from "@app/components/SquareButton.svelte";
|
||||
|
||||
export let activeRoute: ProjectRoute;
|
||||
export let blob: Blob;
|
||||
@@ -103,7 +103,7 @@
|
||||
}
|
||||
|
||||
.last-commit {
|
||||
padding: 0.5rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: var(--color-secondary);
|
||||
background-color: var(--color-secondary-2);
|
||||
font-size: var(--font-size-tiny);
|
||||
@@ -229,12 +229,12 @@
|
||||
<div class="right">
|
||||
{#if isMarkdown}
|
||||
<div class="markdown-toggle">
|
||||
<HeaderToggleLabel
|
||||
<SquareButton
|
||||
active={!showMarkdown}
|
||||
clickable
|
||||
on:click={toggleMarkdown}>
|
||||
Raw
|
||||
</HeaderToggleLabel>
|
||||
</SquareButton>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="last-commit" title={lastCommit.author.name} use:twemoji>
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
<script lang="ts" strictEvents>
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
import * as utils from "@app/lib/utils";
|
||||
|
||||
import Dropdown from "@app/components/Dropdown.svelte";
|
||||
import Floating from "@app/components/Floating.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let branches: Record<string, string>;
|
||||
export let projectDefaultBranch: string;
|
||||
export let projectHead: string | undefined = undefined;
|
||||
export let revision: string;
|
||||
|
||||
const dispatch = createEventDispatcher<{ branchChanged: string }>();
|
||||
const switchBranch = (name: string) => {
|
||||
dispatch("branchChanged", name);
|
||||
};
|
||||
|
||||
let branchLabel: string | null = null;
|
||||
|
||||
$: branchList = Object.keys(branches)
|
||||
@@ -85,10 +80,13 @@
|
||||
{branchLabel}
|
||||
</div>
|
||||
<svelte:fragment slot="modal">
|
||||
<Dropdown
|
||||
items={branchList}
|
||||
selected={branchLabel}
|
||||
on:select={e => switchBranch(e.detail.value)} />
|
||||
<Dropdown items={branchList} selected={branchLabel}>
|
||||
<div class="branch-item" slot="item" let:item>
|
||||
<ProjectLink projectParams={{ revision: item.value }} on:click>
|
||||
{item.value}
|
||||
</ProjectLink>
|
||||
</div>
|
||||
</Dropdown>
|
||||
</svelte:fragment>
|
||||
</Floating>
|
||||
<div class="hash layout-desktop">
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
import { onMount } from "svelte";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
import * as utils from "@app/lib/utils";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
|
||||
@@ -48,6 +47,11 @@
|
||||
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
// When a user clicks between multiple files, we want to retain the previous
|
||||
// file contents and show them while the new file is loading to prevent the
|
||||
// UI from flickering or showing a loading indicator.
|
||||
let previousBlob: Blob;
|
||||
|
||||
const loadBlob = async (path: string) => {
|
||||
if (state.status === Status.Loaded && state.path === path) {
|
||||
return state.blob;
|
||||
@@ -63,6 +67,7 @@
|
||||
}
|
||||
|
||||
state = { status: Status.Loaded, path, blob };
|
||||
previousBlob = blob;
|
||||
return blob;
|
||||
};
|
||||
|
||||
@@ -70,31 +75,6 @@
|
||||
browserErrorStore.set(undefined);
|
||||
});
|
||||
|
||||
const onSelect = async (newPath: string) => {
|
||||
browserErrorStore.set(undefined);
|
||||
// Ensure we don't spend any time in a "loading" state. This means
|
||||
// the loading spinner won't be shown, and instead the blob will be
|
||||
// displayed once loaded.
|
||||
const blob = await loadBlob(newPath).catch(() => {
|
||||
browserErrorStore.set({
|
||||
message: "Not able to load selected file",
|
||||
path: newPath,
|
||||
});
|
||||
return undefined;
|
||||
});
|
||||
if (blob) {
|
||||
getBlob = new Promise(resolve => resolve(blob));
|
||||
}
|
||||
|
||||
// Close mobile tree if user navigates to other file
|
||||
mobileFileTree = false;
|
||||
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "tree" },
|
||||
path: newPath,
|
||||
});
|
||||
};
|
||||
|
||||
const fetchTree = async (path: string) => {
|
||||
return api.project.getTree(project.id, commit, path).catch(() => {
|
||||
browserErrorStore.set({
|
||||
@@ -105,10 +85,6 @@
|
||||
});
|
||||
};
|
||||
|
||||
const toggleMobileFileTree = () => {
|
||||
mobileFileTree = !mobileFileTree;
|
||||
};
|
||||
|
||||
$: getBlob = loadBlob(path).catch(() => {
|
||||
browserErrorStore.set({ message: "Not able to load file", path });
|
||||
return undefined;
|
||||
@@ -203,7 +179,9 @@
|
||||
<Button
|
||||
style="width: 100%;"
|
||||
variant="secondary"
|
||||
on:click={toggleMobileFileTree}>
|
||||
on:click={() => {
|
||||
mobileFileTree = !mobileFileTree;
|
||||
}}>
|
||||
Browse
|
||||
</Button>
|
||||
</nav>
|
||||
@@ -218,8 +196,9 @@
|
||||
{path}
|
||||
{fetchTree}
|
||||
{loadingPath}
|
||||
on:select={e => {
|
||||
onSelect(e.detail);
|
||||
on:select={() => {
|
||||
// Close mobile tree if user navigates to other file
|
||||
mobileFileTree = false;
|
||||
}} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -241,7 +220,20 @@
|
||||
</Placeholder>
|
||||
{:else}
|
||||
{#await getBlob}
|
||||
<Loading small center />
|
||||
{#if previousBlob}
|
||||
<div class="layout-desktop">
|
||||
<BlobComponent
|
||||
{line}
|
||||
blob={previousBlob}
|
||||
{activeRoute}
|
||||
rawPath={utils.getRawBasePath(project.id, baseUrl, commit)} />
|
||||
</div>
|
||||
<div class="layout-mobile">
|
||||
<Loading small center />
|
||||
</div>
|
||||
{:else}
|
||||
<Loading small center />
|
||||
{/if}
|
||||
{:then blob}
|
||||
{#if blob}
|
||||
<BlobComponent
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
.metadata-section {
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
.metadata-section-header {
|
||||
.header {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
@@ -56,20 +56,27 @@
|
||||
margin-bottom: 0.75rem;
|
||||
color: var(--color-foreground-6);
|
||||
}
|
||||
.metadata-section-body {
|
||||
.body {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
.metadata-section-empty {
|
||||
.empty {
|
||||
color: var(--color-foreground-5);
|
||||
}
|
||||
|
||||
.chip-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="metadata-section">
|
||||
<div class="metadata-section-header">
|
||||
<div class="header">
|
||||
<span>Assignees</span>
|
||||
{#if action === "edit"}
|
||||
{#if !edit}
|
||||
@@ -94,17 +101,19 @@
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
<div class="metadata-section-body">
|
||||
<div class="body">
|
||||
{#each updatedAssignees as assignee, key (assignee)}
|
||||
<Chip
|
||||
on:remove={removeAssignee}
|
||||
removeable={edit || action === "create"}
|
||||
{key}>
|
||||
<Avatar inline nodeId={assignee} />
|
||||
<span>{formatNodeId(assignee)}</span>
|
||||
<div class="chip-content">
|
||||
<Avatar inline nodeId={assignee} />
|
||||
<span>{formatNodeId(assignee)}</span>
|
||||
</div>
|
||||
</Chip>
|
||||
{:else}
|
||||
<div class="metadata-section-empty">No assignees</div>
|
||||
<div class="empty">No assignees</div>
|
||||
{/each}
|
||||
</div>
|
||||
{#if edit || action === "create"}
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
.tag {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
import * as router from "@app/lib/router";
|
||||
|
||||
import Changeset from "@app/views/projects/SourceBrowser/Changeset.svelte";
|
||||
import CommitAuthorship from "@app/views/projects/Commit/CommitAuthorship.svelte";
|
||||
import Clipboard from "@app/components/Clipboard.svelte";
|
||||
import CommitAuthorship from "@app/views/projects/Commit/CommitAuthorship.svelte";
|
||||
|
||||
export let commit: Commit;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
.commit {
|
||||
padding: 0 2rem 0 8rem;
|
||||
}
|
||||
header {
|
||||
.header {
|
||||
padding: 1rem;
|
||||
background: var(--color-background-1);
|
||||
border-radius: var(--border-radius);
|
||||
@@ -54,7 +54,7 @@
|
||||
</style>
|
||||
|
||||
<div class="commit">
|
||||
<header>
|
||||
<div class="header">
|
||||
<div class="summary">
|
||||
<div class="txt-medium txt-bold" use:twemoji>{header.summary}</div>
|
||||
<div class="layout-desktop-flex txt-monospace sha1">
|
||||
@@ -68,6 +68,6 @@
|
||||
</div>
|
||||
<pre class="description txt-small">{header.description}</pre>
|
||||
<CommitAuthorship {header} />
|
||||
</header>
|
||||
<Changeset diff={commit.diff} on:browse={onBrowse} />
|
||||
</div>
|
||||
<Changeset diff={commit.diff} revision={commit.commit.id} />
|
||||
</div>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
color: var(--color-foreground-6);
|
||||
padding: 0.125rem 0;
|
||||
}
|
||||
.authorship .author,
|
||||
.authorship .committer {
|
||||
|
||||
@@ -1,67 +1,48 @@
|
||||
<script lang="ts" strictEvents>
|
||||
<script lang="ts">
|
||||
import type { CommitHeader } from "@httpd-client";
|
||||
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
import { formatCommit, twemoji } from "@app/lib/utils";
|
||||
|
||||
import CommitAuthorship from "./CommitAuthorship.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let commit: CommitHeader;
|
||||
|
||||
const dispatch = createEventDispatcher<{ browseCommit: string }>();
|
||||
|
||||
function browseCommit(commit: string) {
|
||||
dispatch("browseCommit", commit);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.teaser {
|
||||
background-color: var(--color-background-1);
|
||||
padding: 0.75rem 0rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.teaser:hover {
|
||||
background-color: var(--color-foreground-2);
|
||||
}
|
||||
.hash {
|
||||
font-family: var(--font-family-monospace);
|
||||
font-size: var(--font-size-tiny);
|
||||
padding: 0 1.5rem;
|
||||
}
|
||||
.commit-teaser {
|
||||
background-color: var(--color-background-1);
|
||||
padding: 0.75rem 0rem;
|
||||
}
|
||||
.commit-teaser:hover {
|
||||
background-color: var(--color-foreground-2);
|
||||
cursor: pointer;
|
||||
}
|
||||
.commit-teaser:first-child {
|
||||
border-top-left-radius: var(--border-radius-small);
|
||||
border-top-right-radius: var(--border-radius-small);
|
||||
}
|
||||
.commit-teaser:last-child {
|
||||
border-bottom-left-radius: var(--border-radius-small);
|
||||
border-bottom-right-radius: var(--border-radius-small);
|
||||
}
|
||||
.commit-teaser:not(:last-child) {
|
||||
border-bottom: 1px solid var(--color-background);
|
||||
}
|
||||
.commit-teaser {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.column-left {
|
||||
.left {
|
||||
padding-left: 1rem;
|
||||
flex: min-content;
|
||||
}
|
||||
.commit-teaser .column-right {
|
||||
.right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-right: 1.5rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
.summary {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
padding-right: 1rem;
|
||||
margin-bottom: 0.25rem;
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
.summary:hover {
|
||||
color: var(--color-secondary);
|
||||
}
|
||||
.browse {
|
||||
display: flex;
|
||||
@@ -74,7 +55,7 @@
|
||||
.hash {
|
||||
padding-right: 0;
|
||||
}
|
||||
.column-left {
|
||||
.left {
|
||||
overflow: hidden;
|
||||
}
|
||||
.browse {
|
||||
@@ -84,29 +65,36 @@
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="commit-teaser" on:click>
|
||||
<div class="column-left">
|
||||
<div class="header">
|
||||
<div class="teaser">
|
||||
<div class="left">
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: { resource: "commits" },
|
||||
revision: commit.id,
|
||||
search: undefined,
|
||||
}}>
|
||||
<div class="summary" use:twemoji>
|
||||
{commit.summary}
|
||||
</div>
|
||||
</div>
|
||||
</ProjectLink>
|
||||
<CommitAuthorship header={commit} />
|
||||
</div>
|
||||
<div class="column-right">
|
||||
<div class="right">
|
||||
<span class="hash txt-highlight">{formatCommit(commit.id)}</span>
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="browse"
|
||||
title="Browse the repository at this point in the history"
|
||||
on:click|stopPropagation={() => browseCommit(commit.id)}>
|
||||
<Icon name="browse" />
|
||||
title="Browse the repository at this point in the history">
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: { resource: "tree" },
|
||||
revision: commit.id,
|
||||
}}>
|
||||
<Icon name="browse" />
|
||||
</ProjectLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
import type { BaseUrl, Project, Remote, Tree } from "@httpd-client";
|
||||
import type { ProjectRoute } from "@app/lib/router/definitions";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
|
||||
import { closeFocused } from "@app/components/Floating.svelte";
|
||||
import { config } from "@app/lib/config";
|
||||
import { pluralize } from "@app/lib/pluralize";
|
||||
|
||||
import BranchSelector from "@app/views/projects/BranchSelector.svelte";
|
||||
import CloneButton from "@app/views/projects/CloneButton.svelte";
|
||||
import HeaderToggleLabel from "@app/views/projects/HeaderToggleLabel.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import PeerSelector from "@app/views/projects/PeerSelector.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
import SquareButton from "@app/components/SquareButton.svelte";
|
||||
|
||||
export let project: Project;
|
||||
export let activeRoute: ProjectRoute;
|
||||
@@ -22,55 +22,10 @@
|
||||
export let baseUrl: BaseUrl;
|
||||
|
||||
$: revision = activeRoute.params.revision ?? commit;
|
||||
|
||||
// Switches between project views.
|
||||
const toggleContent = (
|
||||
input: "issues" | "patches" | "history",
|
||||
keepSourceInPath: boolean,
|
||||
) => {
|
||||
router.updateProjectRoute({
|
||||
view: {
|
||||
resource: activeRoute.params.view.resource === input ? "tree" : input,
|
||||
},
|
||||
id: project.id,
|
||||
revision: revision,
|
||||
search: undefined,
|
||||
...(keepSourceInPath ? null : { revision: undefined, path: undefined }),
|
||||
});
|
||||
};
|
||||
|
||||
const updatePeer = (peer: string) => {
|
||||
router.updateProjectRoute({
|
||||
peer,
|
||||
revision: undefined,
|
||||
});
|
||||
closeFocused();
|
||||
};
|
||||
|
||||
const updateRevision = (revision: string) => {
|
||||
router.updateProjectRoute({
|
||||
revision,
|
||||
});
|
||||
closeFocused();
|
||||
};
|
||||
|
||||
function goToSeed() {
|
||||
if (baseUrl.port !== config.seeds.defaultHttpdPort) {
|
||||
router.push({
|
||||
resource: "seeds",
|
||||
params: { hostnamePort: `${baseUrl.hostname}:${baseUrl.port}` },
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
resource: "seeds",
|
||||
params: { hostnamePort: baseUrl.hostname },
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
header {
|
||||
.header {
|
||||
font-size: var(--font-size-tiny);
|
||||
padding: 0 2rem 0 8rem;
|
||||
margin-bottom: 2rem;
|
||||
@@ -82,21 +37,21 @@
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
header {
|
||||
.header {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
header {
|
||||
.header {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<header>
|
||||
<div class="header">
|
||||
{#if peers.length > 0}
|
||||
<PeerSelector
|
||||
{peers}
|
||||
peer={activeRoute.params.peer}
|
||||
on:peerChanged={event => updatePeer(event.detail)} />
|
||||
on:click={() => closeFocused()} />
|
||||
{/if}
|
||||
|
||||
<BranchSelector
|
||||
@@ -104,45 +59,77 @@
|
||||
projectHead={project.head}
|
||||
{branches}
|
||||
{revision}
|
||||
on:branchChanged={event => updateRevision(event.detail)} />
|
||||
on:click={() => closeFocused()} />
|
||||
|
||||
<CloneButton {baseUrl} id={project.id} name={project.name} />
|
||||
|
||||
<span>
|
||||
<HeaderToggleLabel
|
||||
clickable
|
||||
ariaLabel="Seed"
|
||||
title="Project data is fetched from this seed"
|
||||
on:click={goToSeed}>
|
||||
<span>{baseUrl.hostname}</span>
|
||||
</HeaderToggleLabel>
|
||||
</span>
|
||||
<HeaderToggleLabel
|
||||
ariaLabel="Commit count"
|
||||
clickable
|
||||
active={activeRoute.params.view.resource === "history"}
|
||||
on:click={() => toggleContent("history", true)}>
|
||||
<span class="txt-bold">{tree.stats.commits}</span>
|
||||
{pluralize("commit", tree.stats.commits)}
|
||||
</HeaderToggleLabel>
|
||||
<HeaderToggleLabel
|
||||
ariaLabel="Issue count"
|
||||
active={activeRoute.params.view.resource === "issues"}
|
||||
clickable
|
||||
on:click={() => toggleContent("issues", false)}>
|
||||
<span class="txt-bold">{project.issues.open}</span>
|
||||
{pluralize("issue", project.issues.open)}
|
||||
</HeaderToggleLabel>
|
||||
<HeaderToggleLabel
|
||||
ariaLabel="Patch count"
|
||||
active={activeRoute.params.view.resource === "patches"}
|
||||
clickable
|
||||
on:click={() => toggleContent("patches", false)}>
|
||||
<span class="txt-bold">{project.patches.open}</span>
|
||||
{pluralize("patch", project.patches.open)}
|
||||
</HeaderToggleLabel>
|
||||
<HeaderToggleLabel ariaLabel="Contributor count">
|
||||
<Link
|
||||
route={{
|
||||
resource: "seeds",
|
||||
params: {
|
||||
hostnamePort:
|
||||
baseUrl.port === config.seeds.defaultHttpdPort
|
||||
? baseUrl.hostname
|
||||
: `${baseUrl.hostname}:${baseUrl.port}`,
|
||||
},
|
||||
}}>
|
||||
<SquareButton>
|
||||
{baseUrl.hostname}
|
||||
</SquareButton>
|
||||
</Link>
|
||||
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
id: project.id,
|
||||
view: {
|
||||
resource:
|
||||
activeRoute.params.view.resource === "history" ? "tree" : "history",
|
||||
},
|
||||
revision: revision,
|
||||
search: undefined,
|
||||
}}>
|
||||
<SquareButton active={activeRoute.params.view.resource === "history"}>
|
||||
<span class="txt-bold">{tree.stats.commits}</span>
|
||||
{pluralize("commit", tree.stats.commits)}
|
||||
</SquareButton>
|
||||
</ProjectLink>
|
||||
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
id: project.id,
|
||||
view: {
|
||||
resource:
|
||||
activeRoute.params.view.resource === "issues" ? "tree" : "issues",
|
||||
},
|
||||
search: undefined,
|
||||
revision: undefined,
|
||||
path: undefined,
|
||||
}}>
|
||||
<SquareButton active={activeRoute.params.view.resource === "issues"}>
|
||||
<span class="txt-bold">{project.issues.open}</span>
|
||||
{pluralize("issue", project.issues.open)}
|
||||
</SquareButton>
|
||||
</ProjectLink>
|
||||
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
id: project.id,
|
||||
view: {
|
||||
resource:
|
||||
activeRoute.params.view.resource === "patches" ? "tree" : "patches",
|
||||
},
|
||||
search: undefined,
|
||||
revision: undefined,
|
||||
path: undefined,
|
||||
}}>
|
||||
<SquareButton active={activeRoute.params.view.resource === "patches"}>
|
||||
<span class="txt-bold">{project.patches.open}</span>
|
||||
{pluralize("patch", project.patches.open)}
|
||||
</SquareButton>
|
||||
</ProjectLink>
|
||||
|
||||
<SquareButton hoverable={false}>
|
||||
<span class="txt-bold">{tree.stats.contributors}</span>
|
||||
{pluralize("contributor", tree.stats.contributors)}
|
||||
</HeaderToggleLabel>
|
||||
</header>
|
||||
</SquareButton>
|
||||
</div>
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<script lang="ts">
|
||||
export let title: string | undefined = undefined;
|
||||
export let ariaLabel: string | undefined = undefined;
|
||||
export let active = false;
|
||||
export let clickable = false;
|
||||
export let disabled = false;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.stat {
|
||||
font-family: var(--font-family-monospace);
|
||||
font-size: var(--font-size-tiny);
|
||||
padding: 0.5rem 0.75rem;
|
||||
padding-bottom: 1rem; /* moving the content a tad higher to match the previous span usage */
|
||||
height: 2rem;
|
||||
background: var(--color-foreground-1);
|
||||
border: none;
|
||||
color: var(--color-foreground);
|
||||
border-radius: var(--border-radius-small);
|
||||
min-width: max-content;
|
||||
}
|
||||
.active {
|
||||
color: var(--color-background);
|
||||
background: var(--color-foreground) !important;
|
||||
background-color: var(--color-foreground);
|
||||
}
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
.clickable:hover {
|
||||
background-color: var(--color-foreground-2);
|
||||
}
|
||||
.not-allowed {
|
||||
cursor: not-allowed;
|
||||
color: var(--color-foreground-5);
|
||||
}
|
||||
</style>
|
||||
|
||||
<button
|
||||
{title}
|
||||
{disabled}
|
||||
class:active
|
||||
class:clickable
|
||||
class:not-allowed={disabled}
|
||||
class="stat"
|
||||
aria-label={ariaLabel}
|
||||
on:click>
|
||||
<slot />
|
||||
</button>
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl, CommitHeader } from "@httpd-client";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { groupCommits } from "@app/lib/commit";
|
||||
|
||||
@@ -42,20 +41,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function goToSourceTreeAtCommit(event: { detail: string }) {
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "tree" },
|
||||
revision: event.detail,
|
||||
});
|
||||
}
|
||||
|
||||
function goToCommit(revision: string) {
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "commits" },
|
||||
revision,
|
||||
});
|
||||
}
|
||||
|
||||
$: showMoreButton =
|
||||
!loading && !error && totalCommitCount && history.length < totalCommitCount;
|
||||
|
||||
@@ -67,11 +52,13 @@
|
||||
padding: 0 2rem 0 8rem;
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
.commit-group header {
|
||||
color: var(--color-foreground-6);
|
||||
}
|
||||
.commit-group-headers {
|
||||
.group {
|
||||
margin-bottom: 2rem;
|
||||
border-radius: var(--border-radius);
|
||||
overflow: hidden;
|
||||
}
|
||||
.teaser-wrapper:not(:last-child) {
|
||||
border-bottom: 1px solid var(--color-background);
|
||||
}
|
||||
.more {
|
||||
margin-top: 2rem;
|
||||
@@ -88,18 +75,13 @@
|
||||
{#if history}
|
||||
<div class="history">
|
||||
{#each groupCommits(history) as group (group.time)}
|
||||
<div class="commit-group">
|
||||
<header class="commit-date">
|
||||
<p>{group.date}</p>
|
||||
</header>
|
||||
<div class="commit-group-headers">
|
||||
{#each group.commits as commit (commit.id)}
|
||||
<CommitTeaser
|
||||
{commit}
|
||||
on:click={() => goToCommit(commit.id)}
|
||||
on:browseCommit={goToSourceTreeAtCommit} />
|
||||
{/each}
|
||||
</div>
|
||||
<p style:color="var(--color-foreground-6)">{group.date}</p>
|
||||
<div class="group">
|
||||
{#each group.commits as commit (commit.id)}
|
||||
<div class="teaser-wrapper">
|
||||
<CommitTeaser {commit} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
<div class="more">
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import Authorship from "@app/components/Authorship.svelte";
|
||||
import Badge from "@app/components/Badge.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let issue: Issue;
|
||||
|
||||
@@ -25,14 +26,12 @@
|
||||
|
||||
<style>
|
||||
.issue-teaser {
|
||||
display: grid;
|
||||
grid-template-columns: 3rem minmax(0, 1fr) auto;
|
||||
display: flex;
|
||||
padding: 0.75rem 0;
|
||||
background-color: var(--color-foreground-1);
|
||||
}
|
||||
.issue-teaser:hover {
|
||||
background-color: var(--color-foreground-2);
|
||||
cursor: pointer;
|
||||
}
|
||||
.subtitle {
|
||||
color: var(--color-foreground-6);
|
||||
@@ -51,6 +50,10 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
.issue-title:hover {
|
||||
color: var(--color-secondary);
|
||||
}
|
||||
.comment-count {
|
||||
display: flex;
|
||||
@@ -70,14 +73,15 @@
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.column-right {
|
||||
.right {
|
||||
align-self: center;
|
||||
justify-self: center;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.state {
|
||||
justify-self: center;
|
||||
align-self: center;
|
||||
margin: 0 1.25rem;
|
||||
}
|
||||
.state-icon {
|
||||
width: 0.5rem;
|
||||
@@ -105,9 +109,17 @@
|
||||
class:closed={issue.state.status === "closed"}
|
||||
class:open={issue.state.status === "open"} />
|
||||
</div>
|
||||
<div class="column-left">
|
||||
<div>
|
||||
<div class="summary">
|
||||
<span class="issue-title">{issue.title}</span>
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: {
|
||||
resource: "issue",
|
||||
params: { issue: issue.id },
|
||||
},
|
||||
}}>
|
||||
<span class="issue-title">{issue.title}</span>
|
||||
</ProjectLink>
|
||||
<span class="tags">
|
||||
{#each issue.tags.slice(0, 4) as tag}
|
||||
<Badge style="max-width:7rem" variant="secondary">
|
||||
@@ -129,7 +141,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{#if commentCount > 0}
|
||||
<div class="column-right">
|
||||
<div class="right">
|
||||
<div class="comment-count">
|
||||
<Icon name="chat" />
|
||||
<span>{commentCount}</span>
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import type { Issue } from "@httpd-client";
|
||||
import type { Tab } from "@app/components/TabBar.svelte";
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
import * as utils from "@app/lib/utils";
|
||||
import capitalize from "lodash/capitalize";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
@@ -17,11 +15,11 @@
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import ErrorMessage from "@app/components/ErrorMessage.svelte";
|
||||
import HeaderToggleLabel from "@app/views/projects/HeaderToggleLabel.svelte";
|
||||
import IssueTeaser from "@app/views/projects/Issue/IssueTeaser.svelte";
|
||||
import Loading from "@app/components/Loading.svelte";
|
||||
import Placeholder from "@app/components/Placeholder.svelte";
|
||||
import TabBar from "@app/components/TabBar.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
import SquareButton from "@app/components/SquareButton.svelte";
|
||||
|
||||
export let projectId: string;
|
||||
export let state: IssueStatus;
|
||||
@@ -30,9 +28,6 @@
|
||||
|
||||
const perPage = 10;
|
||||
|
||||
// Keeping it true, to avoid an initial flash
|
||||
// of EmptyState Placeholder
|
||||
let refresh = true;
|
||||
let loading = false;
|
||||
let page = 0;
|
||||
let error: any;
|
||||
@@ -40,7 +35,7 @@
|
||||
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
async function loadIssues(): Promise<void> {
|
||||
async function loadIssues(state: IssueStatus): Promise<void> {
|
||||
loading = true;
|
||||
try {
|
||||
const response = await api.project.getAllIssues(projectId, {
|
||||
@@ -54,26 +49,17 @@
|
||||
error = e;
|
||||
} finally {
|
||||
loading = false;
|
||||
refresh = false;
|
||||
}
|
||||
}
|
||||
|
||||
function switchState(e: CustomEvent<IssueStatus>): void {
|
||||
refresh = true;
|
||||
// Update state to be used in the query
|
||||
state = e.detail;
|
||||
// Reset page to 0 to load the first page for a new state
|
||||
page = 0;
|
||||
// Remove all existing patches with old state
|
||||
issues = [];
|
||||
loadIssues();
|
||||
router.updateProjectRoute({
|
||||
search: `state=${state}`,
|
||||
});
|
||||
interface Tab {
|
||||
value: IssueStatus;
|
||||
title: string;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
const stateOptions: IssueStatus[] = ["open", "closed"];
|
||||
const options = stateOptions.map<Tab<IssueStatus>>(s => ({
|
||||
const options = stateOptions.map<Tab>(s => ({
|
||||
value: s,
|
||||
title: `${issueCounters[s]} ${s}`,
|
||||
disabled: issueCounters[s] === 0,
|
||||
@@ -85,7 +71,11 @@
|
||||
issueCounters[state] &&
|
||||
issues.length < issueCounters[state];
|
||||
|
||||
loadIssues();
|
||||
$: {
|
||||
page = 0;
|
||||
issues = [];
|
||||
loadIssues(state);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -98,7 +88,7 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
.teaser:not(:last-child) {
|
||||
border-bottom: 1px dashed var(--color-background);
|
||||
border-bottom: 1px solid var(--color-background);
|
||||
}
|
||||
.section-header {
|
||||
display: flex;
|
||||
@@ -106,9 +96,6 @@
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
.loader {
|
||||
margin-top: 8rem;
|
||||
}
|
||||
.more {
|
||||
margin-top: 2rem;
|
||||
text-align: center;
|
||||
@@ -125,61 +112,72 @@
|
||||
<div class="issues">
|
||||
<div class="section-header">
|
||||
<div style="margin-bottom: 1rem;">
|
||||
<TabBar {options} on:select={switchState} active={state} />
|
||||
<div style="display: flex; gap: 0.5rem;">
|
||||
{#each options as option}
|
||||
{#if !option.disabled}
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
search: `state=${option.value}`,
|
||||
}}>
|
||||
<SquareButton
|
||||
size="small"
|
||||
clickable={option.disabled}
|
||||
active={option.value === state}
|
||||
disabled={option.disabled}>
|
||||
{option.title}
|
||||
</SquareButton>
|
||||
</ProjectLink>
|
||||
{:else}
|
||||
<SquareButton
|
||||
size="small"
|
||||
clickable={option.disabled}
|
||||
active={option.value === state}
|
||||
disabled={option.disabled}>
|
||||
{option.title}
|
||||
</SquareButton>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<HeaderToggleLabel
|
||||
disabled={!$sessionStore || !utils.isLocal(baseUrl.hostname)}
|
||||
on:click={() => {
|
||||
router.updateProjectRoute({
|
||||
{#if $sessionStore && utils.isLocal(baseUrl.hostname)}
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: {
|
||||
resource: "issues",
|
||||
params: { view: { resource: "new" } },
|
||||
},
|
||||
});
|
||||
}}
|
||||
clickable>
|
||||
New issue
|
||||
</HeaderToggleLabel>
|
||||
}}>
|
||||
<SquareButton size="small">New issue</SquareButton>
|
||||
</ProjectLink>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="issues-list">
|
||||
{#if refresh}
|
||||
<div class="loader">
|
||||
<Loading center />
|
||||
{#each issues as issue}
|
||||
<div class="teaser">
|
||||
<IssueTeaser {issue} />
|
||||
</div>
|
||||
{:else}
|
||||
{#each issues as issue}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="teaser"
|
||||
on:click={() => {
|
||||
router.updateProjectRoute({
|
||||
view: {
|
||||
resource: "issue",
|
||||
params: { issue: issue.id },
|
||||
},
|
||||
});
|
||||
}}>
|
||||
<IssueTeaser {issue} />
|
||||
</div>
|
||||
{#if error}
|
||||
<ErrorMessage message="Couldn't load issues." stackTrace={error} />
|
||||
{:else if loading}
|
||||
<!-- We already show a loader below. -->
|
||||
{:else}
|
||||
{#if error}
|
||||
<ErrorMessage message="Couldn't load issues." stackTrace={error} />
|
||||
{:else}
|
||||
<Placeholder emoji="🍂">
|
||||
<div slot="title">{capitalize(state)} issues</div>
|
||||
<div slot="body">No issues matched the current filter</div>
|
||||
</Placeholder>
|
||||
{/if}
|
||||
{/each}
|
||||
<div class="more">
|
||||
{#if loading}
|
||||
<Loading small={page !== 0} center />
|
||||
{/if}
|
||||
<Placeholder emoji="🍂">
|
||||
<div slot="title">{capitalize(state)} issues</div>
|
||||
<div slot="body">No issues matched the current filter</div>
|
||||
</Placeholder>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
<div class="more">
|
||||
{#if loading}
|
||||
<Loading small={page !== 0} center />
|
||||
{/if}
|
||||
|
||||
{#if showMoreButton}
|
||||
<Button variant="foreground" on:click={loadIssues}>More</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{#if showMoreButton}
|
||||
<Button variant="foreground" on:click={() => loadIssues(state)}>
|
||||
More
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
import CommitTeaser from "./Commit/CommitTeaser.svelte";
|
||||
import Dropdown from "@app/components/Dropdown.svelte";
|
||||
import Floating from "@app/components/Floating.svelte";
|
||||
import HeaderToggleLabel from "./HeaderToggleLabel.svelte";
|
||||
import TabBar from "@app/components/TabBar.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
import SquareButton from "@app/components/SquareButton.svelte";
|
||||
import TagInput from "./Cob/TagInput.svelte";
|
||||
import ThreadComponent from "@app/components/Thread.svelte";
|
||||
|
||||
@@ -54,14 +54,6 @@
|
||||
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
const browseCommit = (event: { detail: string }) => {
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "tree" },
|
||||
search: undefined,
|
||||
revision: event.detail,
|
||||
});
|
||||
};
|
||||
|
||||
async function createReply({
|
||||
detail: reply,
|
||||
}: CustomEvent<{ id: string; body: string }>) {
|
||||
@@ -193,6 +185,11 @@
|
||||
margin: 1rem;
|
||||
color: var(--color-foreground-5);
|
||||
}
|
||||
.commit-list {
|
||||
border-radius: var(--border-radius);
|
||||
overflow: hidden;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 1092px) {
|
||||
.patch {
|
||||
@@ -214,14 +211,13 @@
|
||||
<div>
|
||||
<CobHeader id={patch.id} title={patch.title}>
|
||||
<span slot="revision" class="txt-monospace txt-tiny">
|
||||
<Floating>
|
||||
<Floating disabled={patch.revisions.length === 1}>
|
||||
<svelte:fragment slot="toggle">
|
||||
<HeaderToggleLabel
|
||||
<SquareButton
|
||||
clickable={patch.revisions.length > 1}
|
||||
disabled={patch.revisions.length === 1}
|
||||
title="Toggle revision">
|
||||
disabled={patch.revisions.length === 1}>
|
||||
Revision {currentRevisionIndex}
|
||||
</HeaderToggleLabel>
|
||||
</SquareButton>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="modal">
|
||||
<Dropdown
|
||||
@@ -263,13 +259,32 @@
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</CobHeader>
|
||||
<TabBar
|
||||
{options}
|
||||
active={currentTab}
|
||||
on:select={({ detail: tab }) =>
|
||||
router.updateProjectRoute({
|
||||
search: `tab=${tab}`,
|
||||
})} />
|
||||
<div style="display: flex; gap: 0.5rem;">
|
||||
{#each options as option}
|
||||
{#if !option.disabled}
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
search: `tab=${option.value}`,
|
||||
}}>
|
||||
<SquareButton
|
||||
size="small"
|
||||
clickable={option.disabled}
|
||||
active={option.value === currentTab}
|
||||
disabled={option.disabled}>
|
||||
{option.title}
|
||||
</SquareButton>
|
||||
</ProjectLink>
|
||||
{:else}
|
||||
<SquareButton
|
||||
size="small"
|
||||
clickable={option.disabled}
|
||||
active={option.value === currentTab}
|
||||
disabled={option.disabled}>
|
||||
{option.title}
|
||||
</SquareButton>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{#if currentTab === "activity"}
|
||||
<div style:margin-top="1rem">
|
||||
<div class="txt-tiny">
|
||||
@@ -332,34 +347,16 @@
|
||||
</div>
|
||||
{:else if currentTab === "commits"}
|
||||
{#await diffPromise then diff}
|
||||
<div style:margin-top="1rem">
|
||||
<div class="commit-list">
|
||||
{#each diff.commits as commit}
|
||||
<CommitTeaser
|
||||
{commit}
|
||||
on:click={() => {
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "commits" },
|
||||
revision: commit.id,
|
||||
search: undefined,
|
||||
});
|
||||
}}
|
||||
on:browseCommit={browseCommit} />
|
||||
<CommitTeaser {commit} />
|
||||
{/each}
|
||||
</div>
|
||||
{/await}
|
||||
{:else if currentTab === "files"}
|
||||
{#await diffPromise then diff}
|
||||
<div style:margin-top="1rem">
|
||||
<Changeset
|
||||
diff={diff.diff}
|
||||
on:browse={({ detail: path }) => {
|
||||
router.updateProjectRoute({
|
||||
view: { resource: "tree" },
|
||||
search: undefined,
|
||||
revision: currentRevision.oid,
|
||||
path,
|
||||
});
|
||||
}} />
|
||||
<Changeset revision={currentRevision.oid} diff={diff.diff} />
|
||||
</div>
|
||||
{/await}
|
||||
{/if}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import Badge from "@app/components/Badge.svelte";
|
||||
import DiffStatBadge from "@app/components/DiffStatBadge.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let projectId: string;
|
||||
export let baseUrl: BaseUrl;
|
||||
@@ -27,14 +28,12 @@
|
||||
|
||||
<style>
|
||||
.patch-teaser {
|
||||
display: grid;
|
||||
grid-template-columns: 3rem minmax(0, 1fr) auto;
|
||||
display: flex;
|
||||
padding: 0.75rem 0;
|
||||
background-color: var(--color-foreground-1);
|
||||
}
|
||||
.patch-teaser:hover {
|
||||
background-color: var(--color-foreground-2);
|
||||
cursor: pointer;
|
||||
}
|
||||
.meta {
|
||||
display: flex;
|
||||
@@ -57,23 +56,25 @@
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.patch-title:hover {
|
||||
color: var(--color-secondary);
|
||||
}
|
||||
.comment-count {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding-right: 1rem;
|
||||
gap: 0.5rem;
|
||||
color: var(--color-foreground-5);
|
||||
}
|
||||
|
||||
.column-right {
|
||||
.right {
|
||||
align-self: center;
|
||||
justify-self: center;
|
||||
padding-right: 1rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
.state {
|
||||
justify-self: center;
|
||||
align-self: center;
|
||||
margin: 0 1.25rem;
|
||||
}
|
||||
.tags {
|
||||
display: flex;
|
||||
@@ -117,9 +118,17 @@
|
||||
class:merged={patch.state.status === "merged"}
|
||||
class:archived={patch.state.status === "archived"} />
|
||||
</div>
|
||||
<div class="column-left">
|
||||
<div>
|
||||
<div class="summary">
|
||||
<span class="patch-title">{patch.title}</span>
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: {
|
||||
resource: "patch",
|
||||
params: { patch: patch.id },
|
||||
},
|
||||
}}>
|
||||
<span class="patch-title">{patch.title}</span>
|
||||
</ProjectLink>
|
||||
<span class="tags">
|
||||
{#each patch.tags.slice(0, 4) as tag}
|
||||
<Badge style="max-width:7rem" variant="secondary">
|
||||
@@ -142,7 +151,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column-right">
|
||||
<div class="right">
|
||||
<div class="comment-count">
|
||||
{#await diffPromise then { diff }}
|
||||
<DiffStatBadge
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Tab } from "@app/components/TabBar.svelte";
|
||||
import type { BaseUrl } from "@httpd-client";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
import capitalize from "lodash/capitalize";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
|
||||
@@ -17,7 +15,8 @@
|
||||
import Loading from "@app/components/Loading.svelte";
|
||||
import PatchTeaser from "./Patch/PatchTeaser.svelte";
|
||||
import Placeholder from "@app/components/Placeholder.svelte";
|
||||
import TabBar from "@app/components/TabBar.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
import SquareButton from "@app/components/SquareButton.svelte";
|
||||
|
||||
export let projectId: string;
|
||||
export let state: PatchStatus;
|
||||
@@ -31,9 +30,6 @@
|
||||
|
||||
const perPage = 10;
|
||||
|
||||
// Keeping it true, to avoid an initial flash
|
||||
// of EmptyState Placeholder
|
||||
let refresh = true;
|
||||
let loading = false;
|
||||
let page = 0;
|
||||
let error: any;
|
||||
@@ -41,7 +37,7 @@
|
||||
|
||||
const api = new HttpdClient(baseUrl);
|
||||
|
||||
async function loadPatches(): Promise<void> {
|
||||
async function loadPatches(state: PatchStatus): Promise<void> {
|
||||
loading = true;
|
||||
try {
|
||||
const response = await api.project.getAllPatches(projectId, {
|
||||
@@ -55,37 +51,33 @@
|
||||
error = e;
|
||||
} finally {
|
||||
loading = false;
|
||||
refresh = false;
|
||||
}
|
||||
}
|
||||
|
||||
function switchState(e: CustomEvent<PatchStatus>): void {
|
||||
refresh = true;
|
||||
// Update state to be used in the query
|
||||
state = e.detail;
|
||||
// Reset page to 0 to load the first page for a new state
|
||||
page = 0;
|
||||
// Remove all existing patches with old state
|
||||
patches = [];
|
||||
loadPatches();
|
||||
router.updateProjectRoute({
|
||||
search: `state=${state}`,
|
||||
});
|
||||
interface Tab {
|
||||
value: PatchStatus;
|
||||
title: string;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
const stateOptions: PatchStatus[] = ["draft", "open", "archived", "merged"];
|
||||
const options = stateOptions.map<Tab<PatchStatus>>(s => ({
|
||||
const options = stateOptions.map<Tab>(s => ({
|
||||
value: s,
|
||||
title: `${patchCounters[s]} ${s}`,
|
||||
disabled: patchCounters[s] === 0,
|
||||
}));
|
||||
|
||||
$: showMoreButton =
|
||||
!loading &&
|
||||
!error &&
|
||||
patchCounters[state] &&
|
||||
patches.length < patchCounters[state];
|
||||
|
||||
loadPatches();
|
||||
$: {
|
||||
page = 0;
|
||||
patches = [];
|
||||
loadPatches(state);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -97,9 +89,6 @@
|
||||
border-radius: var(--border-radius);
|
||||
overflow: hidden;
|
||||
}
|
||||
.loader {
|
||||
margin-top: 8rem;
|
||||
}
|
||||
.more {
|
||||
margin-top: 2rem;
|
||||
text-align: center;
|
||||
@@ -118,47 +107,62 @@
|
||||
|
||||
<div class="patches">
|
||||
<div style="margin-bottom: 1rem;">
|
||||
<TabBar {options} on:select={switchState} active={state} />
|
||||
</div>
|
||||
<div class="patches-list">
|
||||
{#if refresh}
|
||||
<div class="loader">
|
||||
<Loading center />
|
||||
</div>
|
||||
{:else}
|
||||
{#each patches as patch}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="teaser"
|
||||
on:click={() => {
|
||||
router.updateProjectRoute({
|
||||
view: {
|
||||
resource: "patch",
|
||||
params: { patch: patch.id },
|
||||
},
|
||||
});
|
||||
}}>
|
||||
<PatchTeaser {baseUrl} {projectId} {patch} />
|
||||
</div>
|
||||
{:else}
|
||||
{#if error}
|
||||
<ErrorMessage message="Couldn't load patches." stackTrace={error} />
|
||||
<div style="display: flex; gap: 0.5rem;">
|
||||
{#each options as option}
|
||||
{#if option.disabled}
|
||||
<SquareButton
|
||||
size="small"
|
||||
clickable={option.disabled}
|
||||
active={option.value === state}
|
||||
disabled={option.disabled}>
|
||||
{option.title}
|
||||
</SquareButton>
|
||||
{:else}
|
||||
<Placeholder emoji="🍂">
|
||||
<div slot="title">{capitalize(state)} patches</div>
|
||||
<div slot="body">No patches matched the current filter</div>
|
||||
</Placeholder>
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
search: `state=${option.value}`,
|
||||
}}>
|
||||
<SquareButton
|
||||
size="small"
|
||||
clickable={option.disabled}
|
||||
active={option.value === state}
|
||||
disabled={option.disabled}>
|
||||
{option.title}
|
||||
</SquareButton>
|
||||
</ProjectLink>
|
||||
{/if}
|
||||
{/each}
|
||||
<div class="more">
|
||||
{#if loading}
|
||||
<Loading small={page !== 0} center />
|
||||
{/if}
|
||||
|
||||
{#if showMoreButton}
|
||||
<Button variant="foreground" on:click={loadPatches}>More</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="patches-list">
|
||||
{#each patches as patch}
|
||||
<div class="teaser">
|
||||
<PatchTeaser {baseUrl} {projectId} {patch} />
|
||||
</div>
|
||||
{:else}
|
||||
{#if error}
|
||||
<ErrorMessage message="Couldn't load patches." stackTrace={error} />
|
||||
{:else if loading}
|
||||
<!-- We already show a loader below. -->
|
||||
{:else}
|
||||
<Placeholder emoji="🍂">
|
||||
<div slot="title">{capitalize(state)} patches</div>
|
||||
<div slot="body">No patches matched the current filter</div>
|
||||
</Placeholder>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
<div class="more">
|
||||
{#if loading}
|
||||
<div style:margin-top={page === 0 ? "8rem" : ""}>
|
||||
<Loading small={page !== 0} center />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if showMoreButton}
|
||||
<Button variant="foreground" on:click={() => loadPatches(state)}>
|
||||
More
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { Item } from "@app/components/Dropdown.svelte";
|
||||
import type { Remote } from "@httpd-client";
|
||||
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
import { formatNodeId, truncateId } from "@app/lib/utils";
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
import Dropdown from "@app/components/Dropdown.svelte";
|
||||
import Floating from "@app/components/Floating.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let peer: string | null = null;
|
||||
export let peer: string | undefined = undefined;
|
||||
export let peers: Remote[];
|
||||
|
||||
let meta: Remote | undefined;
|
||||
@@ -36,11 +37,6 @@
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
const dispatch = createEventDispatcher<{ peerChanged: string }>();
|
||||
const switchPeer = (peer: string) => {
|
||||
dispatch("peerChanged", peer);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -69,7 +65,7 @@
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 0;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.prefix {
|
||||
display: inline-block;
|
||||
@@ -83,6 +79,12 @@
|
||||
height: 2rem;
|
||||
line-height: initial;
|
||||
background: var(--color-foreground-1);
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.avatar-id {
|
||||
display: flex;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -93,39 +95,53 @@
|
||||
<Icon name="fork" />
|
||||
{/if}
|
||||
{#if meta}
|
||||
<span style:display="flex">
|
||||
<span class="avatar-id">
|
||||
<Avatar nodeId={meta.id} inline />
|
||||
<span style:color="var(--color-secondary-5)">did:key:</span>
|
||||
{truncateId(meta.id)}
|
||||
<!-- Ignore prettier to avoid getting a whitespace between
|
||||
did:key: and the nid due to a newline. -->
|
||||
<!-- prettier-ignore -->
|
||||
<span><span style:color="var(--color-secondary-5)">did:key:</span>{truncateId(meta.id)}</span>
|
||||
</span>
|
||||
{#if meta.delegate}
|
||||
<Badge variant="primary">delegate</Badge>
|
||||
{/if}
|
||||
{:else if peer}
|
||||
<span style:display="flex">
|
||||
<span class="avatar-id">
|
||||
<Avatar nodeId={peer} inline />
|
||||
<span style:color="var(--color-secondary-5)">did:key:</span>
|
||||
{truncateId(peer)}
|
||||
<!-- prettier-ignore -->
|
||||
<span><span style:color="var(--color-secondary-5)">did:key:</span>{truncateId(peer)}</span>
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<svelte:fragment slot="modal">
|
||||
<Dropdown
|
||||
{items}
|
||||
selected={peer}
|
||||
on:select={e => switchPeer(e.detail.value)}>
|
||||
<div class="peer-item" slot="item" let:item>
|
||||
<Avatar nodeId={item.value} inline />
|
||||
<!-- We ignore prettier here for the following line
|
||||
to avoid getting a whitespace between did:key: and the nid due to a newline -->
|
||||
<!-- prettier-ignore -->
|
||||
<span><span class="prefix">did:key:</span>{item.value}</span>
|
||||
{#if item.badge}
|
||||
<Badge variant="primary">{item.badge}</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<Dropdown {items} selected={peer}>
|
||||
<svelte:fragment slot="item" let:item>
|
||||
<ProjectLink
|
||||
on:click
|
||||
projectParams={{
|
||||
peer: item.value,
|
||||
revision: undefined,
|
||||
}}>
|
||||
<div class="peer-item">
|
||||
<span class="avatar-id">
|
||||
<Avatar nodeId={item.value} inline />
|
||||
<div class="layout-desktop">
|
||||
<!-- prettier-ignore -->
|
||||
<span><span class="prefix">did:key:</span>{item.value}</span>
|
||||
</div>
|
||||
<div class="layout-mobile">
|
||||
<!-- prettier-ignore -->
|
||||
<span><span class="prefix">did:key:</span>{truncateId(item.value)}</span>
|
||||
</div>
|
||||
</span>
|
||||
{#if item.badge}
|
||||
<Badge variant="primary">{item.badge}</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
</ProjectLink>
|
||||
</svelte:fragment>
|
||||
</Dropdown>
|
||||
</svelte:fragment>
|
||||
</Floating>
|
||||
|
||||
@@ -16,22 +16,28 @@
|
||||
|
||||
<style>
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: left;
|
||||
color: var(--color-secondary);
|
||||
display: flex;
|
||||
font-size: var(--font-size-x-large);
|
||||
font-weight: var(--font-weight-bold);
|
||||
justify-content: left;
|
||||
margin-bottom: 0.5rem;
|
||||
overflow-x: hidden;
|
||||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.title .divider {
|
||||
.divider {
|
||||
color: var(--color-foreground-4);
|
||||
margin: 0 0.5rem;
|
||||
font-weight: var(--font-weight-normal);
|
||||
}
|
||||
.title .node-id {
|
||||
.node-id {
|
||||
color: var(--color-foreground-5);
|
||||
font-weight: var(--font-weight-normal);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.project-name:hover {
|
||||
color: inherit;
|
||||
@@ -68,11 +74,15 @@
|
||||
.content {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
.title {
|
||||
font-size: var(--font-size-medium);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<header class="content">
|
||||
<div class="title txt-bold txt-title">
|
||||
<div class="title">
|
||||
<span class="truncate">
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import FileDiff from "@app/views/projects/SourceBrowser/FileDiff.svelte";
|
||||
|
||||
export let diff: Diff;
|
||||
export let revision: string;
|
||||
|
||||
const diffDescription = ({ modified, added, deleted }: Diff): string => {
|
||||
const s = [];
|
||||
@@ -53,12 +54,12 @@
|
||||
</div>
|
||||
<div class="diff-listing">
|
||||
{#each diff.added as file}
|
||||
<FileDiff on:browse {file} mode="added" />
|
||||
<FileDiff on:browse {file} {revision} mode="added" />
|
||||
{/each}
|
||||
{#each diff.deleted as file}
|
||||
<FileDiff on:browse {file} mode="deleted" />
|
||||
<FileDiff on:browse {file} {revision} mode="deleted" />
|
||||
{/each}
|
||||
{#each diff.modified as file}
|
||||
<FileDiff on:browse {file} />
|
||||
<FileDiff on:browse {file} {revision} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
<script lang="ts" strictEvents>
|
||||
<script lang="ts">
|
||||
import type {
|
||||
DiffAddedDeletedModifiedChangeset,
|
||||
HunkLine,
|
||||
} from "@httpd-client";
|
||||
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
import Badge from "@app/components/Badge.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
|
||||
const dispatch = createEventDispatcher<{ browse: string }>();
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let file: DiffAddedDeletedModifiedChangeset;
|
||||
export let revision: string;
|
||||
export let mode: string | null = null;
|
||||
|
||||
function collapse() {
|
||||
collapsed = !collapsed;
|
||||
}
|
||||
|
||||
let collapsed = false;
|
||||
|
||||
function lineNumberR(line: HunkLine): string | number {
|
||||
@@ -64,19 +58,19 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.changeset-file {
|
||||
.wrapper {
|
||||
border: 1px solid var(--color-foreground-4);
|
||||
border-radius: var(--border-radius-small);
|
||||
margin-bottom: 2rem;
|
||||
line-height: 1.5rem;
|
||||
}
|
||||
.changeset-file header {
|
||||
cursor: pointer;
|
||||
height: 3rem;
|
||||
display: flex;
|
||||
.header {
|
||||
align-items: center;
|
||||
background: none;
|
||||
border-radius: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 3rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
main {
|
||||
@@ -84,15 +78,8 @@
|
||||
border-top: 1px dashed var(--color-foreground-4);
|
||||
background: var(--color-background-1);
|
||||
border-radius: 0 0 var(--border-radius-small) var(--border-radius-small);
|
||||
}
|
||||
.changeset-file main {
|
||||
overflow-x: auto;
|
||||
}
|
||||
header {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -105,69 +92,82 @@
|
||||
text-align: center;
|
||||
background-color: var(--color-foreground-2);
|
||||
}
|
||||
table.diff {
|
||||
.browse {
|
||||
margin-left: auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
.expand-button {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
.diff {
|
||||
font-family: var(--font-family-monospace);
|
||||
table-layout: fixed;
|
||||
border-collapse: collapse;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
tr.diff-line {
|
||||
.diff-line {
|
||||
vertical-align: top;
|
||||
}
|
||||
tr.diff-line[data-type="+"] > * {
|
||||
.diff-line[data-type="+"] > * {
|
||||
color: var(--color-positive);
|
||||
}
|
||||
tr.diff-line[data-type="-"] > * {
|
||||
.diff-line[data-type="-"] > * {
|
||||
color: var(--color-negative);
|
||||
}
|
||||
td.diff-line-number {
|
||||
.diff-line-number {
|
||||
text-align: right;
|
||||
user-select: none;
|
||||
line-height: 1.5rem;
|
||||
min-width: 3rem;
|
||||
}
|
||||
td.diff-line-number[data-type="+"],
|
||||
td.diff-line-type[data-type="+"] {
|
||||
.diff-line-number[data-type="+"],
|
||||
.diff-line-type[data-type="+"] {
|
||||
background-color: var(--color-positive-2);
|
||||
color: var(--color-positive-6);
|
||||
}
|
||||
td.diff-line-number[data-type="-"],
|
||||
td.diff-line-type[data-type="-"] {
|
||||
.diff-line-number[data-type="-"],
|
||||
.diff-line-type[data-type="-"] {
|
||||
background-color: var(--color-negative-2);
|
||||
color: var(--color-negative-6);
|
||||
}
|
||||
td.diff-line-number.left {
|
||||
.diff-line-number.left {
|
||||
padding: 0 0.5rem 0 0.75rem;
|
||||
}
|
||||
td.diff-line-number.right {
|
||||
.diff-line-number.right {
|
||||
padding: 0 0.75rem 0 0.5rem;
|
||||
}
|
||||
td.diff-line-content {
|
||||
.diff-line-content {
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
width: 100%;
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
td.diff-line-type {
|
||||
.diff-line-type {
|
||||
text-align: center;
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 0.75rem;
|
||||
}
|
||||
td.diff-expand-header {
|
||||
.diff-expand-header {
|
||||
padding-left: 0.5rem;
|
||||
color: var(--color-foreground-5);
|
||||
}
|
||||
td.diff-line-number {
|
||||
.diff-line-number {
|
||||
color: var(--color-foreground-5);
|
||||
}
|
||||
.browse {
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
|
||||
<article id={file.path} class="changeset-file">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<header class="file-header" on:click={collapse}>
|
||||
<div id={file.path} class="wrapper">
|
||||
<header class="header">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="expand-button" on:click={() => (collapsed = !collapsed)}>
|
||||
{#if collapsed}
|
||||
<Icon name="chevron-right" />
|
||||
{:else}
|
||||
<Icon name="chevron-down" />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="actions">
|
||||
<p class="txt-regular">{file.path}</p>
|
||||
{#if mode === "added"}
|
||||
@@ -176,12 +176,16 @@
|
||||
<Badge variant="negative">deleted</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div
|
||||
class="browse clickable"
|
||||
on:click|stopPropagation={() => dispatch("browse", file.path)}>
|
||||
<span title="View file" style="transform: scale(1.25);">
|
||||
<div class="browse" title="View file">
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: { resource: "tree" },
|
||||
path: file.path,
|
||||
revision,
|
||||
search: undefined,
|
||||
}}>
|
||||
<Icon name="browse" />
|
||||
</span>
|
||||
</ProjectLink>
|
||||
</div>
|
||||
</header>
|
||||
{#if !collapsed}
|
||||
@@ -216,4 +220,4 @@
|
||||
{/if}
|
||||
</main>
|
||||
{/if}
|
||||
</article>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import File from "./Tree/File.svelte";
|
||||
import Folder from "./Tree/Folder.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
export let fetchTree: (path: string) => Promise<Tree | undefined>;
|
||||
export let path: string;
|
||||
@@ -27,10 +28,16 @@
|
||||
currentPath={path}
|
||||
on:select={onSelect} />
|
||||
{:else}
|
||||
<File
|
||||
active={entry.path === path}
|
||||
loading={entry.path === loadingPath}
|
||||
name={entry.name}
|
||||
on:click={() => onSelect({ detail: entry.path })} />
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: { resource: "tree" },
|
||||
path: entry.path,
|
||||
}}
|
||||
on:click={() => onSelect({ detail: entry.path })}>
|
||||
<File
|
||||
active={entry.path === path}
|
||||
loading={entry.path === loadingPath}
|
||||
name={entry.name} />
|
||||
</ProjectLink>
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
@@ -46,8 +46,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="file" class:active on:click>
|
||||
<div class="file" class:active>
|
||||
<span class="name">{name}</span>
|
||||
<div class="spinner">
|
||||
{#if loading}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
import Loading from "@app/components/Loading.svelte";
|
||||
import ProjectLink from "@app/components/ProjectLink.svelte";
|
||||
|
||||
import File from "./File.svelte";
|
||||
|
||||
@@ -84,13 +85,17 @@
|
||||
{loadingPath}
|
||||
{currentPath} />
|
||||
{:else}
|
||||
<File
|
||||
active={entry.path === currentPath}
|
||||
loading={entry.path === loadingPath}
|
||||
name={entry.name}
|
||||
on:click={() => {
|
||||
onSelectFile({ detail: entry.path });
|
||||
}} />
|
||||
<ProjectLink
|
||||
projectParams={{
|
||||
view: { resource: "tree" },
|
||||
path: entry.path,
|
||||
}}
|
||||
on:click={() => onSelectFile({ detail: entry.path })}>
|
||||
<File
|
||||
active={entry.path === currentPath}
|
||||
loading={entry.path === loadingPath}
|
||||
name={entry.name} />
|
||||
</ProjectLink>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user