Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Don't show filter inputs when there's nothing to filter
Rūdolfs Ošiņš committed 1 year ago
commit 054174f606e5261212923d5661b9c0c55c442141
parent 12afb43
3 files changed +98 -93
modified src/views/home/Repos.svelte
@@ -122,32 +122,34 @@
  <div class="container">
    <div class="global-flex" style:margin-bottom="0.5rem">
      <div class="header">Repositories</div>
-
      <div class="global-flex" style:margin-left="auto">
-
        <TextInput
-
          onSubmit={async () => {
-
            if (searchResults.length === 1) {
-
              await router.push({
-
                resource: "repo.issues",
-
                rid: searchResults[0].obj.repo.rid,
-
                status: "open",
-
              });
-
            }
-
          }}
-
          onDismiss={() => {
-
            searchInput = "";
-
          }}
-
          placeholder={`Fuzzy filter repositories ${modifierKey()} + f`}
-
          keyShortcuts="ctrl+f"
-
          bind:value={searchInput}>
-
          {#snippet left()}
-
            <div
-
              style:color="var(--color-foreground-dim)"
-
              style:padding-left="0.5rem">
-
              <Icon name="filter" />
-
            </div>
-
          {/snippet}
-
        </TextInput>
-
      </div>
+
      {#if repos.length > 0}
+
        <div class="global-flex" style:margin-left="auto">
+
          <TextInput
+
            onSubmit={async () => {
+
              if (searchResults.length === 1) {
+
                await router.push({
+
                  resource: "repo.issues",
+
                  rid: searchResults[0].obj.repo.rid,
+
                  status: "open",
+
                });
+
              }
+
            }}
+
            onDismiss={() => {
+
              searchInput = "";
+
            }}
+
            placeholder={`Fuzzy filter repositories ${modifierKey()} + f`}
+
            keyShortcuts="ctrl+f"
+
            bind:value={searchInput}>
+
            {#snippet left()}
+
              <div
+
                style:color="var(--color-foreground-dim)"
+
                style:padding-left="0.5rem">
+
                <Icon name="filter" />
+
              </div>
+
            {/snippet}
+
          </TextInput>
+
        </div>
+
      {/if}
    </div>
    {#if repos.length > 0}
      {#if searchResults.length > 0}
@@ -173,7 +175,7 @@
          styleJustifyContent="center">
          <div
            class="global-flex"
-
            style:height="74px"
+
            style:height="126px"
            style:justify-content="center">
            <div class="txt-missing txt-small global-flex" style:gap="0.25rem">
              <Icon name="none" />
modified src/views/repo/Issues.svelte
@@ -97,31 +97,33 @@
    <div class="header">
      <div>Issues</div>
      <div class="global-flex" style:margin-left="auto">
-
        <TextInput
-
          onSubmit={async () => {
-
            if (searchResults.length === 1) {
-
              await router.push({
-
                resource: "repo.issue",
-
                rid: repo.rid,
-
                issue: searchResults[0].obj.issue.id,
-
                status,
-
              });
-
            }
-
          }}
-
          onDismiss={() => {
-
            searchInput = "";
-
          }}
-
          placeholder={`Fuzzy filter issues ${modifierKey()} + f`}
-
          keyShortcuts="ctrl+f"
-
          bind:value={searchInput}>
-
          {#snippet left()}
-
            <div
-
              style:color="var(--color-foreground-dim)"
-
              style:padding-left="0.5rem">
-
              <Icon name="filter" />
-
            </div>
-
          {/snippet}
-
        </TextInput>
+
        {#if issues.length > 0}
+
          <TextInput
+
            onSubmit={async () => {
+
              if (searchResults.length === 1) {
+
                await router.push({
+
                  resource: "repo.issue",
+
                  rid: repo.rid,
+
                  issue: searchResults[0].obj.issue.id,
+
                  status,
+
                });
+
              }
+
            }}
+
            onDismiss={() => {
+
              searchInput = "";
+
            }}
+
            placeholder={`Fuzzy filter issues ${modifierKey()} + f`}
+
            keyShortcuts="ctrl+f"
+
            bind:value={searchInput}>
+
            {#snippet left()}
+
              <div
+
                style:color="var(--color-foreground-dim)"
+
                style:padding-left="0.5rem">
+
                <Icon name="filter" />
+
              </div>
+
            {/snippet}
+
          </TextInput>
+
        {/if}
        <div class="txt-regular txt-semibold">
          <Button
            variant="secondary"
modified src/views/repo/Patches.svelte
@@ -29,8 +29,6 @@

  const { repo, patches, config, status }: Props = $props();

-
  let loading: boolean = $state(false);
-

  let items = $state(patches.content);
  let cursor = patches.cursor;
  let more = patches.more;
@@ -63,6 +61,7 @@

  const project = $derived(repo.payloads["xyz.radicle.project"]!);

+
  let loading: boolean = $state(false);
  let searchInput = $state("");

  const searchablePatches = $derived(
@@ -130,45 +129,47 @@
    <div class="header">
      Patches

-
      <div class="global-flex" style:margin-left="auto">
-
        <TextInput
-
          onFocus={async () => {
-
            try {
-
              loading = true;
-
              // Load all patches.
-
              await loadMoreContent(true);
-
            } catch (e) {
-
              console.error("Loading all patches failed: ", e);
-
            } finally {
-
              loading = false;
-
            }
-
          }}
-
          onSubmit={async () => {
-
            if (searchResults.length === 1) {
-
              await router.push({
-
                patch: searchResults[0].obj.patch.id,
-
                resource: "repo.patch",
-
                reviewId: undefined,
-
                rid: repo.rid,
-
                status,
-
              });
-
            }
-
          }}
-
          onDismiss={() => {
-
            searchInput = "";
-
          }}
-
          placeholder={`Fuzzy filter issues ${modifierKey()} + f`}
-
          keyShortcuts="ctrl+f"
-
          bind:value={searchInput}>
-
          {#snippet left()}
-
            <div
-
              style:color="var(--color-foreground-dim)"
-
              style:padding-left="0.5rem">
-
              <Icon name={loading ? "clock" : "filter"} />
-
            </div>
-
          {/snippet}
-
        </TextInput>
-
      </div>
+
      {#if items.length > 0}
+
        <div class="global-flex" style:margin-left="auto">
+
          <TextInput
+
            onFocus={async () => {
+
              try {
+
                loading = true;
+
                // Load all patches.
+
                await loadMoreContent(true);
+
              } catch (e) {
+
                console.error("Loading all patches failed: ", e);
+
              } finally {
+
                loading = false;
+
              }
+
            }}
+
            onSubmit={async () => {
+
              if (searchResults.length === 1) {
+
                await router.push({
+
                  patch: searchResults[0].obj.patch.id,
+
                  resource: "repo.patch",
+
                  reviewId: undefined,
+
                  rid: repo.rid,
+
                  status,
+
                });
+
              }
+
            }}
+
            onDismiss={() => {
+
              searchInput = "";
+
            }}
+
            placeholder={`Fuzzy filter patches ${modifierKey()} + f`}
+
            keyShortcuts="ctrl+f"
+
            bind:value={searchInput}>
+
            {#snippet left()}
+
              <div
+
                style:color="var(--color-foreground-dim)"
+
                style:padding-left="0.5rem">
+
                <Icon name={loading ? "clock" : "filter"} />
+
              </div>
+
            {/snippet}
+
          </TextInput>
+
        </div>
+
      {/if}
    </div>

    <div class="list">