Skip to content

Commit

Permalink
Add local prop to other project routes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinez committed Jan 9, 2024
1 parent 4f308d4 commit 84e0d20
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/views/projects/Commit.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
export let baseUrl: BaseUrl;
export let commit: Commit;
export let project: Project;
export let local: boolean;
$: header = commit.commit;
</script>
Expand All @@ -30,7 +31,7 @@
}
</style>

<Layout {baseUrl} {project}>
<Layout {baseUrl} {project} {local}>
<div class="commit">
<div class="header">
<InlineMarkdown fontSize="large" content={header.summary} />
Expand Down
3 changes: 2 additions & 1 deletion src/views/projects/History.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
export let totalCommitCount: number;
export let tree: Tree;
export let seeding: boolean;
export let local: boolean;
const api = new HttpdClient(baseUrl);
Expand Down Expand Up @@ -108,7 +109,7 @@
}
</style>

<Layout {baseUrl} {project} activeTab="source">
<Layout {baseUrl} {project} {local} activeTab="source">
<ProjectNameHeader {project} {baseUrl} {seeding} slot="header" />

<div style:margin="1rem 0 1rem 1rem" slot="subheader">
Expand Down
3 changes: 2 additions & 1 deletion src/views/projects/Issue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
export let issue: Issue;
export let project: Project;
export let rawPath: (commit?: string) => string;
export let local: boolean;
const api = new HttpdClient(baseUrl);
Expand Down Expand Up @@ -464,7 +465,7 @@
}
</style>

<Layout {baseUrl} {project} activeTab="issues">
<Layout {baseUrl} {project} {local} activeTab="issues">
<div class="issue">
<div style="display: flex; flex: 1; flex-direction: column; gap: 1.5rem;">
<CobHeader id={issue.id}>
Expand Down
3 changes: 2 additions & 1 deletion src/views/projects/Issue/New.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
export let baseUrl: BaseUrl;
export let project: Project;
export let rawPath: (commit?: string) => string;
export let local: boolean;
let preview: boolean = false;
let selectionStart = 0;
Expand Down Expand Up @@ -134,7 +135,7 @@
}
</style>

<Layout {baseUrl} {project} activeTab="issues">
<Layout {baseUrl} {project} {local} activeTab="issues">
<div>
{#if session}
<div class="form">
Expand Down
3 changes: 2 additions & 1 deletion src/views/projects/Issues.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
export let issues: Issue[];
export let project: Project;
export let state: IssueState["status"];
export let local: boolean;
let loading = false;
let page = 0;
Expand Down Expand Up @@ -92,7 +93,7 @@
}
</style>

<Layout {baseUrl} {project} activeTab="issues">
<Layout {baseUrl} {project} {local} activeTab="issues">
<div slot="header" style:display="flex" style:padding="1rem">
<Popover
popoverPadding="0"
Expand Down
3 changes: 2 additions & 1 deletion src/views/projects/Patch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
export let rawPath: (commit?: string) => string;
export let project: Project;
export let view: PatchView;
export let local: boolean;
$: api = new HttpdClient(baseUrl);
Expand Down Expand Up @@ -644,7 +645,7 @@
}
</style>

<Layout {baseUrl} {project} activeTab="patches">
<Layout {baseUrl} {project} {local} activeTab="patches">
<div class="patch">
<div style="display: flex; flex: 1; flex-direction: column;">
<CobHeader id={patch.id}>
Expand Down
3 changes: 2 additions & 1 deletion src/views/projects/Patches.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
export let patches: Patch[];
export let project: Project;
export let state: PatchState["status"];
export let local: boolean;
let loading = false;
let page = 0;
Expand Down Expand Up @@ -97,7 +98,7 @@
}
</style>

<Layout {baseUrl} {project} activeTab="patches">
<Layout {baseUrl} {project} {local} activeTab="patches">
<div slot="header" style:display="flex" style:padding="1rem">
<Popover
popoverPadding="0"
Expand Down
34 changes: 34 additions & 0 deletions src/views/projects/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export type ProjectLoadedRoute =
branches: string[];
revision: string | undefined;
tree: Tree;
local: boolean;
commitHeaders: CommitHeader[];
totalCommitCount: number;
seeding: boolean;
Expand All @@ -141,6 +142,7 @@ export type ProjectLoadedRoute =
baseUrl: BaseUrl;
project: Project;
commit: Commit;
local: boolean;
};
}
| {
Expand All @@ -150,6 +152,7 @@ export type ProjectLoadedRoute =
project: Project;
rawPath: (commit?: string) => string;
issue: Issue;
local: boolean;
};
}
| {
Expand All @@ -159,6 +162,7 @@ export type ProjectLoadedRoute =
project: Project;
issues: Issue[];
state: IssueState["status"];
local: boolean;
};
}
| {
Expand All @@ -167,6 +171,7 @@ export type ProjectLoadedRoute =
baseUrl: BaseUrl;
project: Project;
rawPath: (commit?: string) => string;
local: boolean;
};
}
| {
Expand All @@ -176,6 +181,7 @@ export type ProjectLoadedRoute =
project: Project;
patches: Patch[];
state: PatchState["status"];
local: boolean;
};
}
| {
Expand All @@ -186,6 +192,7 @@ export type ProjectLoadedRoute =
rawPath: (commit?: string) => string;
patch: Patch;
view: PatchView;
local: boolean;
};
};

Expand Down Expand Up @@ -259,6 +266,10 @@ export async function loadProjectRoute(
route: ProjectRoute,
): Promise<ProjectLoadedRoute | LoadErrorRoute | NotFoundRoute> {
const api = new HttpdClient(route.node);
const local = await httpd.api.project
.getById(route.project)
.then(() => true)
.catch(() => false);
const rawPath = (commit?: string) =>
`${route.node.scheme}://${route.node.hostname}:${route.node.port}/raw/${
route.project
Expand All @@ -281,6 +292,7 @@ export async function loadProjectRoute(
baseUrl: route.node,
project,
commit,
local,
},
};
} else if (route.resource === "project.issue") {
Expand All @@ -295,6 +307,7 @@ export async function loadProjectRoute(
project,
rawPath,
issue,
local,
},
};
} else if (route.resource === "project.patch") {
Expand All @@ -309,6 +322,7 @@ export async function loadProjectRoute(
baseUrl: route.node,
project,
rawPath,
local,
},
};
} else if (route.resource === "project.patches") {
Expand Down Expand Up @@ -353,6 +367,10 @@ async function loadPatchesView(
route: ProjectPatchesRoute,
): Promise<ProjectLoadedRoute> {
const api = new HttpdClient(route.node);
const local = await httpd.api.project
.getById(route.project)
.then(() => true)
.catch(() => false);
const searchParams = new URLSearchParams(route.search || "");
const state = (searchParams.get("state") as PatchState["status"]) || "open";

Expand All @@ -372,6 +390,7 @@ async function loadPatchesView(
patches,
state,
project,
local,
},
};
}
Expand All @@ -380,6 +399,10 @@ async function loadIssuesView(
route: ProjectIssuesRoute,
): Promise<ProjectLoadedRoute> {
const api = new HttpdClient(route.node);
const local = await httpd.api.project
.getById(route.project)
.then(() => true)
.catch(() => false);
const state = route.state || "open";

const [project, issues] = await Promise.all([
Expand All @@ -396,6 +419,7 @@ async function loadIssuesView(
resource: "project.issues",
params: {
baseUrl: route.node,
local,
issues,
state,
project,
Expand Down Expand Up @@ -508,6 +532,10 @@ async function loadHistoryView(
route: ProjectHistoryRoute,
): Promise<ProjectLoadedRoute> {
const api = new HttpdClient(route.node);
const local = await httpd.api.project
.getById(route.project)
.then(() => true)
.catch(() => false);

const [project, peers, branchMap] = await Promise.all([
api.project.getById(route.project),
Expand Down Expand Up @@ -553,6 +581,7 @@ async function loadHistoryView(
commitHeaders: commitsResponse.commits.map(c => c.commit),
totalCommitCount: commitsResponse.stats.commits,
seeding,
local,
},
};
}
Expand All @@ -561,6 +590,10 @@ async function loadPatchView(
route: ProjectPatchRoute,
): Promise<ProjectLoadedRoute> {
const api = new HttpdClient(route.node);
const local = await httpd.api.project
.getById(route.project)
.then(() => true)
.catch(() => false);
const rawPath = (commit?: string) =>
`${route.node.scheme}://${route.node.hostname}:${route.node.port}/raw/${
route.project
Expand Down Expand Up @@ -622,6 +655,7 @@ async function loadPatchView(
rawPath,
patch,
view,
local,
},
};
}
Expand Down

0 comments on commit 84e0d20

Please sign in to comment.