mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Add query string for issue state filtering
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { navigate } from "svelte-routing";
|
||||
import { groupIssues, Issue } from "@app/issue";
|
||||
import Placeholder from "@app/Placeholder.svelte";
|
||||
import { capitalize } from "@app/utils";
|
||||
@@ -15,6 +16,7 @@
|
||||
.filter {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin: 1rem 0;
|
||||
border-radius: var(--border-radius-small);
|
||||
}
|
||||
@@ -44,7 +46,7 @@
|
||||
<div class="filter">
|
||||
<button
|
||||
class="unstyled state-toggle"
|
||||
on:click={() => state = "open"}
|
||||
on:click={() => navigate("?state=open") }
|
||||
disabled={open.length === 0}
|
||||
class:active={state === "open"}>
|
||||
{open.length} Open
|
||||
@@ -52,7 +54,7 @@
|
||||
<span class="separator">·</span>
|
||||
<button
|
||||
class="unstyled state-toggle"
|
||||
on:click={() => state = "closed"}
|
||||
on:click={() => navigate("?state=closed")}
|
||||
disabled={closed.length === 0}
|
||||
class:active={state === "closed"}>
|
||||
{closed.length} Closed
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
export let project: Project;
|
||||
export let config: Config;
|
||||
export let state: string;
|
||||
export let issues: Issue[];
|
||||
|
||||
const navigate = (issue: string) => {
|
||||
@@ -41,7 +42,7 @@
|
||||
</style>
|
||||
|
||||
<div class="issues">
|
||||
<IssueFilter {issues} let:filteredIssues>
|
||||
<IssueFilter {state} {issues} let:filteredIssues>
|
||||
{@const sortedIssues = filteredIssues.sort(({ timestamp: t1 }, { timestamp: t2 }) => t2 - t1)}
|
||||
<div class="issues-list">
|
||||
{#each sortedIssues as issue}
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
|
||||
{#if content == proj.ProjectContent.Issues}
|
||||
<Async fetch={issue.Issue.getIssues(project.urn, project.seed.api)} let:result>
|
||||
<Issues {project} {config} issues={result} />
|
||||
<Issues {project} state={$browserStore.search?.get("state") || "open"} {config} issues={result} />
|
||||
</Async>
|
||||
{:else if content == proj.ProjectContent.Issue && $browserStore.issue}
|
||||
<Async fetch={issue.Issue.getIssue(project.urn, $browserStore.issue, project.seed.api)} let:result>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import type { Config } from "@app/config";
|
||||
import { formatLocationHash } from '@app/utils';
|
||||
import * as proj from '@app/project';
|
||||
import type { RouteLocation } from "@app/index";
|
||||
|
||||
import Project from '@app/base/projects/Project.svelte';
|
||||
|
||||
@@ -15,13 +16,13 @@
|
||||
export let content: proj.ProjectContent = proj.ProjectContent.Tree;
|
||||
export let project: proj.Project;
|
||||
export let config: Config;
|
||||
export let hash: string | null = null;
|
||||
export let location: RouteLocation | null = null;
|
||||
|
||||
const browse: proj.BrowseTo = { content, peer, path: "/" };
|
||||
const head = project.branches[project.defaultBranch] || null;
|
||||
|
||||
// If line-number hash changes, we update the browser.
|
||||
$: browse.line = formatLocationHash(hash);
|
||||
$: browse.line = formatLocationHash(location?.hash || null);
|
||||
|
||||
// `route` includes any unmatched path segments.
|
||||
$: if (route) {
|
||||
@@ -33,6 +34,8 @@
|
||||
browse.revision = revision;
|
||||
} else if (issue) {
|
||||
browse.issue = issue;
|
||||
} else if (location) {
|
||||
browse.search = new URLSearchParams(location.search);
|
||||
} else if (patch) {
|
||||
browse.patch = patch;
|
||||
} else if (head) {
|
||||
|
||||
@@ -51,28 +51,28 @@
|
||||
<ProjectRoute content={ProjectContent.Tree} {peer} {project} {config} />
|
||||
</Route>
|
||||
<Route path="/tree/*" let:params let:location>
|
||||
<ProjectRoute route={params["*"]} hash={location.hash} content={ProjectContent.Tree} {peer} {project} {config} />
|
||||
<ProjectRoute route={params["*"]} content={ProjectContent.Tree} {location} {peer} {project} {config} />
|
||||
</Route>
|
||||
|
||||
<Route path="/history">
|
||||
<ProjectRoute content={ProjectContent.History} {peer} {project} {config} />
|
||||
</Route>
|
||||
<Route path="/history/*" let:params let:location>
|
||||
<ProjectRoute route={params["*"]} hash={location.hash} content={ProjectContent.History} {peer} {project} {config} />
|
||||
<ProjectRoute route={params["*"]} content={ProjectContent.History} {location} {peer} {project} {config} />
|
||||
</Route>
|
||||
|
||||
<Route path="/commits/:commit" let:params>
|
||||
<ProjectRoute revision={params.commit} content={ProjectContent.Commit} {peer} {project} {config} />
|
||||
</Route>
|
||||
<Route path="/commits/*" let:params let:location>
|
||||
<ProjectRoute route={params["*"]} hash={location.hash} content={ProjectContent.Commit} {peer} {project} {config} />
|
||||
<ProjectRoute route={params["*"]} content={ProjectContent.Commit} {location} {peer} {project} {config} />
|
||||
</Route>
|
||||
|
||||
<Route path="/issues">
|
||||
<ProjectRoute content={ProjectContent.Issues} {peer} {project} {config} />
|
||||
<Route path="/issues" let:location>
|
||||
<ProjectRoute content={ProjectContent.Issues} {peer} {project} {location} {config} />
|
||||
</Route>
|
||||
<Route path="/issues/:issue" let:params>
|
||||
<ProjectRoute content={ProjectContent.Issue} issue={params.issue} {peer} {project} {config} />
|
||||
<Route path="/issues/:issue" let:params let:location>
|
||||
<ProjectRoute content={ProjectContent.Issue} issue={params.issue} {peer} {project} {location} {config} />
|
||||
</Route>
|
||||
|
||||
<Route path="/patches">
|
||||
|
||||
+8
-10
@@ -1,15 +1,13 @@
|
||||
import App from "./App.svelte";
|
||||
|
||||
declare global {
|
||||
// Taken from svelte-routing, since it's not exported.
|
||||
interface RouteLocation {
|
||||
pathname: string;
|
||||
search: string;
|
||||
hash?: string;
|
||||
state: {
|
||||
[k in string | number]: unknown;
|
||||
};
|
||||
}
|
||||
// Taken from svelte-routing, since it's not exported.
|
||||
export interface RouteLocation {
|
||||
pathname: string;
|
||||
search: string;
|
||||
hash?: string;
|
||||
state: {
|
||||
[k in string | number]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
const app = new App({
|
||||
|
||||
@@ -119,6 +119,7 @@ export interface Browser {
|
||||
peer: string | null;
|
||||
path: string | null;
|
||||
line: number | null;
|
||||
search: URLSearchParams | null;
|
||||
}
|
||||
|
||||
export const browserStore = writable({
|
||||
@@ -130,6 +131,7 @@ export const browserStore = writable({
|
||||
peer: null,
|
||||
path: null,
|
||||
line: null,
|
||||
search: null,
|
||||
} as Browser);
|
||||
|
||||
export interface BrowseTo {
|
||||
@@ -140,6 +142,7 @@ export interface BrowseTo {
|
||||
path?: string | null;
|
||||
peer?: string | null;
|
||||
line?: number | null;
|
||||
search?: URLSearchParams | null;
|
||||
}
|
||||
|
||||
export interface PathOptions extends BrowseTo {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ethers } from "ethers";
|
||||
import type { RouteLocation } from "@app/index";
|
||||
import md5 from "md5";
|
||||
import { BigNumber } from "ethers";
|
||||
import multibase from 'multibase';
|
||||
|
||||
Reference in New Issue
Block a user