mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Add experimental switch in settings
Hide all read/write functionality behind this setting.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
<script lang="ts">
|
||||
import * as modal from "@app/lib/modal";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
import { httpdStore, api } from "@app/lib/httpd";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Command from "@app/components/Command.svelte";
|
||||
import ErrorModal from "@app/modals/ErrorModal.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
@@ -70,63 +72,80 @@
|
||||
.counter {
|
||||
font-weight: var(--font-weight-regular);
|
||||
border-radius: var(--border-radius-tiny);
|
||||
background-color: var(--color-fill-secondary-counter);
|
||||
background-color: var(--color-fill-ghost-hover);
|
||||
border: 1px solid var(--color-border-secondary-counter);
|
||||
color: var(--color-foreground-match-background);
|
||||
color: var(--color-foreground-contrast);
|
||||
padding: 0 0.25rem;
|
||||
}
|
||||
.seeding {
|
||||
background-color: var(--color-fill-counter-emphasized);
|
||||
color: var(--color-foreground-emphasized);
|
||||
}
|
||||
.not-seeding {
|
||||
background-color: var(--color-fill-secondary-counter);
|
||||
color: var(--color-foreground-match-background);
|
||||
}
|
||||
.disabled {
|
||||
background-color: var(--color-fill-ghost-hover);
|
||||
background-color: var(--color-fill-float-hover);
|
||||
color: var(--color-foreground-disabled);
|
||||
}
|
||||
</style>
|
||||
|
||||
<Popover popoverPositionTop="2.5rem" popoverPositionRight="0">
|
||||
<Button
|
||||
disabled={!canEditSeeding}
|
||||
slot="toggle"
|
||||
disabled={$experimental ? !canEditSeeding : false}
|
||||
let:toggle
|
||||
on:click={async () => {
|
||||
if (!seeding && canEditSeeding) {
|
||||
if ($experimental && !seeding && canEditSeeding) {
|
||||
await editSeeding();
|
||||
} else {
|
||||
toggle();
|
||||
}
|
||||
}}
|
||||
variant={seeding ? "secondary-toggle-on" : "secondary-toggle-off"}>
|
||||
variant={!$experimental
|
||||
? "outline"
|
||||
: seeding
|
||||
? "secondary-toggle-on"
|
||||
: "secondary-toggle-off"}>
|
||||
<IconSmall name="network" />
|
||||
<span class="title-counter">
|
||||
{seeding ? "Seeding" : "Seed"}
|
||||
<span
|
||||
class="counter"
|
||||
class:seeding
|
||||
class:disabled={!canEditSeeding}
|
||||
class:seeding={$experimental ? seeding : false}
|
||||
class:not-seeding={$experimental ? !seeding : false}
|
||||
class:disabled={$experimental ? !canEditSeeding : false}
|
||||
style:font-weight="var(--font-weight-regular)">
|
||||
{seedCount}
|
||||
</span>
|
||||
</span>
|
||||
</Button>
|
||||
|
||||
<div slot="popover" let:toggle style:width={seeding ? "19.5rem" : "30.5rem"}>
|
||||
<div class="seed-label txt-bold">Stop seeding</div>
|
||||
<div class="seed-label">
|
||||
Are you sure you want to stop seeding this project? If you don't seed a
|
||||
project it won't appear in the local projects section anymore and any
|
||||
changes you make to it won't propagate to the network.
|
||||
</div>
|
||||
<Button
|
||||
styleWidth="100%"
|
||||
disabled={editSeedingInProgress}
|
||||
on:click={async () => {
|
||||
await editSeeding();
|
||||
toggle();
|
||||
}}>
|
||||
<IconSmall name="network" />
|
||||
Stop seeding
|
||||
</Button>
|
||||
<div
|
||||
slot="popover"
|
||||
style:width={$experimental ? (seeding ? "19.5rem" : "30.5rem") : "auto"}>
|
||||
{#if $experimental && canEditSeeding && seeding}
|
||||
<div class="seed-label txt-bold">Stop seeding</div>
|
||||
<div class="seed-label">
|
||||
Are you sure you want to stop seeding this project? If you don't seed a
|
||||
project it won't appear in the local projects section anymore and any
|
||||
changes you make to it won't propagate to the network.
|
||||
</div>
|
||||
<Button
|
||||
styleWidth="100%"
|
||||
disabled={editSeedingInProgress}
|
||||
on:click={async () => {
|
||||
await editSeeding();
|
||||
}}>
|
||||
<IconSmall name="network" />
|
||||
Stop seeding
|
||||
</Button>
|
||||
{:else}
|
||||
<span class="seed-label">
|
||||
Use the Radicle CLI to {seeding ? "stop" : "start"} seeding this project.
|
||||
</span>
|
||||
<Command command={`rad ${seeding ? "unseed" : "seed"} ${projectId}`} />
|
||||
{/if}
|
||||
</div>
|
||||
</Popover>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import * as role from "@app/lib/roles";
|
||||
import * as router from "@app/lib/router";
|
||||
import * as utils from "@app/lib/utils";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
@@ -537,7 +538,7 @@
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<div slot="description">
|
||||
{#if issueState !== "read"}
|
||||
{#if $experimental && issueState !== "read"}
|
||||
<ExtendedTextarea
|
||||
isValid={() => newTitle.length > 0}
|
||||
disallowEmptyBody
|
||||
@@ -578,7 +579,7 @@
|
||||
<span class="txt-missing">No description</span>
|
||||
{/if}
|
||||
<div class="reactions">
|
||||
{#if session}
|
||||
{#if $experimental && session}
|
||||
<ReactionSelector
|
||||
reactions={issue.discussion[0].reactions}
|
||||
on:select={async ({ detail: { authors, emoji } }) => {
|
||||
@@ -635,14 +636,20 @@
|
||||
session?.publicKey,
|
||||
project.delegates,
|
||||
)}
|
||||
editComment={session && partial(editComment, session.id)}
|
||||
createReply={session && partial(createReply, session.id)}
|
||||
reactOnComment={session && partial(reactOnComment, session)} />
|
||||
editComment={$experimental &&
|
||||
session &&
|
||||
partial(editComment, session.id)}
|
||||
createReply={$experimental &&
|
||||
session &&
|
||||
partial(createReply, session.id)}
|
||||
reactOnComment={$experimental &&
|
||||
session &&
|
||||
partial(reactOnComment, session)} />
|
||||
<div class="connector" />
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
{#if session}
|
||||
{#if $experimental && session}
|
||||
{#if threads.length === 0}
|
||||
<div class="connector" />{/if}
|
||||
<CommentToggleInput
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl, Issue, IssueState, Project } from "@httpd-client";
|
||||
|
||||
import capitalize from "lodash/capitalize";
|
||||
import { HttpdClient } from "@httpd-client";
|
||||
import { ISSUES_PER_PAGE } from "./router";
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
import { baseUrlToString, isLocal } from "@app/lib/utils";
|
||||
import capitalize from "lodash/capitalize";
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import DropdownList from "@app/components/DropdownList.svelte";
|
||||
@@ -146,7 +147,7 @@
|
||||
|
||||
<div style="margin-left: auto; display: flex; gap: 1rem;">
|
||||
<Share {baseUrl} />
|
||||
{#if $httpdStore.state === "authenticated" && isLocal(baseUrl.hostname)}
|
||||
{#if $experimental && $httpdStore.state === "authenticated" && isLocal(baseUrl.hostname)}
|
||||
<Link
|
||||
route={{
|
||||
resource: "project.newIssue",
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
import * as role from "@app/lib/roles";
|
||||
import * as router from "@app/lib/router";
|
||||
import * as utils from "@app/lib/utils";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
import capitalize from "lodash/capitalize";
|
||||
import isEqual from "lodash/isEqual";
|
||||
import partial from "lodash/partial";
|
||||
@@ -767,7 +768,7 @@
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="description">
|
||||
<div class="revision-description">
|
||||
{#if session && patchState !== "read" && lastEdit}
|
||||
{#if $experimental && session && patchState !== "read" && lastEdit}
|
||||
<ExtendedTextarea
|
||||
isValid={() => patch.title.length > 0}
|
||||
enableAttachments
|
||||
@@ -802,7 +803,7 @@
|
||||
{:else}
|
||||
<span class="txt-missing">No description available</span>
|
||||
{/if}
|
||||
{#if session || (firstRevision.revisionReactions && firstRevision.revisionReactions.length > 0)}
|
||||
{#if ($experimental && session) || (firstRevision.revisionReactions && firstRevision.revisionReactions.length > 0)}
|
||||
<div class="actions">
|
||||
{#if session}
|
||||
<ReactionSelector
|
||||
@@ -979,15 +980,20 @@
|
||||
session?.publicKey,
|
||||
project.delegates,
|
||||
)}
|
||||
editRevision={session &&
|
||||
editRevision={$experimental &&
|
||||
session &&
|
||||
partial(editRevision, session.id, revision.revisionId)}
|
||||
editComment={session &&
|
||||
editComment={$experimental &&
|
||||
session &&
|
||||
partial(editComment, session.id, revision.revisionId)}
|
||||
reactOnComment={session &&
|
||||
reactOnComment={$experimental &&
|
||||
session &&
|
||||
partial(reactOnComment, session, revision.revisionId)}
|
||||
reactOnRevision={session &&
|
||||
reactOnRevision={$experimental &&
|
||||
session &&
|
||||
partial(reactOnRevision, session, revision.revisionId)}
|
||||
createReply={session &&
|
||||
createReply={$experimental &&
|
||||
session &&
|
||||
partial(createReply, session.id, revision.revisionId)}
|
||||
patchId={patch.id}
|
||||
patchState={patch.state}
|
||||
@@ -995,7 +1001,7 @@
|
||||
previousRevId={previousRevision?.id}
|
||||
previousRevOid={previousRevision?.oid}>
|
||||
{#if index === patch.revisions.length - 1}
|
||||
{#if session && view.name === "activity"}
|
||||
{#if $experimental && session && view.name === "activity"}
|
||||
<div class="connector" />
|
||||
<CommentToggleInput
|
||||
rawPath={rawPath(patch.revisions[0].id)}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import capitalize from "lodash/capitalize";
|
||||
|
||||
import { PATCHES_PER_PAGE } from "./router";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
import { baseUrlToString, isLocal } from "@app/lib/utils";
|
||||
|
||||
@@ -160,7 +161,7 @@
|
||||
|
||||
<div style="margin-left: auto; display: flex; gap: 1rem;">
|
||||
<Share {baseUrl} />
|
||||
{#if $httpdStore.state === "authenticated" && isLocal(baseUrl.hostname)}
|
||||
{#if $experimental && $httpdStore.state === "authenticated" && isLocal(baseUrl.hostname)}
|
||||
<Popover popoverPositionTop="2.5rem" popoverPositionRight="0">
|
||||
<Button
|
||||
slot="toggle"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import type { ActiveTab } from "./Header.svelte";
|
||||
import type { BaseUrl, Project } from "@httpd-client";
|
||||
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
import { queryProject } from "@app/lib/projects";
|
||||
import { httpdStore, api } from "@app/lib/httpd";
|
||||
import { isLocal } from "@app/lib/utils";
|
||||
@@ -36,7 +37,9 @@
|
||||
let queryingLocalProject: boolean = true;
|
||||
let localProject: "notFound" | "found" | undefined = undefined;
|
||||
$: hideContextHelp =
|
||||
isLocal(baseUrl.hostname) && $httpdStore.state === "authenticated";
|
||||
$experimental &&
|
||||
isLocal(baseUrl.hostname) &&
|
||||
$httpdStore.state === "authenticated";
|
||||
|
||||
httpdStore.subscribe(async () => {
|
||||
if ($httpdStore.state !== "stopped" && !queryingLocalProject) {
|
||||
@@ -65,7 +68,13 @@
|
||||
queryingLocalProject = false;
|
||||
}
|
||||
|
||||
onMount(async () => await detectLocalProject());
|
||||
onMount(async () => {
|
||||
if ($httpdStore.state !== "stopped") {
|
||||
await detectLocalProject();
|
||||
} else {
|
||||
localProject = "notFound";
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -250,7 +259,7 @@
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="help" class:expanded>
|
||||
{#if !hideContextHelp && expanded}
|
||||
{#if !hideContextHelp && expanded && $experimental}
|
||||
{#if !localProject}
|
||||
<div
|
||||
style="display: flex; justify-content: center; align-items: center; height: 2rem;">
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
import { twemoji } from "@app/lib/utils";
|
||||
|
||||
import Badge from "@app/components/Badge.svelte";
|
||||
import CloneButton from "../Header/CloneButton.svelte";
|
||||
import CloneButton from "@app/views/projects/Header/CloneButton.svelte";
|
||||
import CopyableId from "@app/components/CopyableId.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import InlineMarkdown from "@app/components/InlineMarkdown.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import SeedButton from "../Header/SeedButton.svelte";
|
||||
import SeedButton from "@app/views/projects/Header/SeedButton.svelte";
|
||||
import Share from "@app/views/projects/Share.svelte";
|
||||
|
||||
export let project: Project;
|
||||
|
||||
@@ -27,6 +27,8 @@ import { ResponseError } from "@httpd-client/lib/fetcher";
|
||||
import { handleError } from "@app/views/projects/error";
|
||||
import { nodePath } from "@app/views/nodes/router";
|
||||
import { unreachable } from "@app/lib/utils";
|
||||
import { get } from "svelte/store";
|
||||
import { experimental } from "@app/lib/appearance";
|
||||
|
||||
export const COMMITS_PER_PAGE = 30;
|
||||
export const PATCHES_PER_PAGE = 10;
|
||||
@@ -242,6 +244,9 @@ function parseRevisionToOid(
|
||||
}
|
||||
|
||||
async function isLocalNodeSeeding(route: ProjectRoute): Promise<boolean> {
|
||||
if (!get(experimental) && get(httpd.httpdStore).state === "stopped") {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const tracking = await httpd.api.getTracking();
|
||||
return tracking.some(({ id }) => id === route.project);
|
||||
|
||||
Reference in New Issue
Block a user