Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Allow commit selection in revisions only if more than one commit
Merged did:key:z6MkkfM3...sVz5 opened 1 year ago

Closes issue 20f85e93b849721d372d0913197bc788273f24ce

checkcheck-unit-testcheck-e2e

👉 Workflow runs 👉 Branch on GitHub

2 files changed +24 -14 9ec894cb 10b055cf
modified src/components/Changes.svelte
@@ -90,22 +90,26 @@
  .commit-dot.active {
    background-color: var(--color-border-focus);
  }
-
  .commit:hover .commit-dot:not(.active) {
+
  .commit:hover:not(.single-commit) .commit-dot:not(.active) {
    background-color: var(--color-foreground-contrast);
  }
-
  .commit:hover {
+
  .commit:hover:not(.single-commit) {
    background-color: var(--color-background-float);
  }
  .disabled {
    color: var(--color-foreground-disabled) !important;
  }
  .summary {
+
    cursor: pointer;
    padding: 0.25rem 0;
  }
-
  .summary:hover {
+
  .summary:hover:not(.single-commit) {
    background-color: var(--color-background-float);
    color: var(--color-foreground-contrast) !important;
  }
+
  .single-commit {
+
    cursor: default !important;
+
  }
</style>

<div
@@ -144,13 +148,15 @@
          <!-- svelte-ignore a11y_click_events_have_key_events -->
          <div
            class="global-flex txt-small summary"
+
            class:single-commit={commits.length === 1}
            class:disabled={selectedCommit}
-
            style:cursor="pointer"
-
            onclick={() =>
+
            onclick={() => {
+
              if (commits.length === 1) return;
              selectRevision({
                headId: revision.head,
                baseId: revision.base,
-
              })}>
+
              });
+
            }}>
            <Icon name="branch" />
            {commits.length}
            {pluralize("commit", commits.length)} on base
@@ -161,20 +167,26 @@
          </div>
          <div class="commits">
            {#each commits.reverse() as commit}
-
              <div class="commit" style:position="relative">
+
              <div
+
                class="commit"
+
                class:single-commit={commits.length === 1}
+
                style:position="relative">
                <div class="commit-dot"></div>
                <div
                  class="commit-dot"
                  class:active={isActiveCommit(commit.id)}>
                </div>
                <CobCommitTeaser
+
                  hoverable={commits.length > 1}
                  disabled={isTeaserDisabled(commit.id)}
-
                  onclick={() =>
+
                  onclick={() => {
+
                    if (commits.length === 1) return;
                    selectRevision({
                      headId: commit.id,
                      baseId: commit.parents[0],
                      commitId: commit.id,
-
                    })}
+
                    });
+
                  }}
                  {commit} />
              </div>
            {/each}
modified src/components/CobCommitTeaser.svelte
@@ -13,9 +13,10 @@
    disabled: boolean;
    commit: Commit;
    onclick: () => void;
+
    hoverable?: boolean;
  }

-
  const { disabled, commit, onclick }: Props = $props();
+
  const { disabled, hoverable = false, commit, onclick }: Props = $props();

  let commitMessageVisible = $state(false);
</script>
@@ -67,9 +68,6 @@
    white-space: pre-wrap;
    word-wrap: break-word;
  }
-
  .summary {
-
    cursor: pointer;
-
  }
</style>

<!-- svelte-ignore a11y_no_static_element_interactions -->
@@ -77,7 +75,7 @@
<div class="teaser" class:disabled {onclick} aria-label="commit-teaser">
  <div class="left">
    <div class="message">
-
      <div class="summary" use:twemoji>
+
      <div style:cursor={hoverable ? "pointer" : "default"} use:twemoji>
        <InlineTitle fontSize="small" content={commit.summary} />
      </div>
      {#if commit.message.trim() !== commit.summary.trim()}