Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
Prepare components for draft reviews
Open did:key:z6Mki9XN...FvWF opened 10 months ago
  • Make timestamp optional in Comment component
  • Make comments without IDs editable. For upcoming draft reviews, comments don’t have an ID yet but we still want to make them editable.
  • Allow disabling of reactions, replies and changing status on diff comments
2 files changed +33 -27 30710d51 5b5ea9a6
modified src/components/Comment.svelte
@@ -28,7 +28,7 @@
    reactions?: Reaction[];
    embeds?: Map<string, Embed>;
    caption?: string;
-
    timestamp: number;
+
    timestamp?: number;
    lastEdit?: Edit;
    disallowEmptyBody?: boolean;
    emptyBodyTooltip?: string;
@@ -139,9 +139,11 @@
      {#if beforeTimestamp}
        {@render beforeTimestamp()}
      {/if}
-
      <span class="timestamp" title={utils.absoluteTimestamp(timestamp)}>
-
        {utils.formatTimestamp(timestamp)}
-
      </span>
+
      {#if timestamp}
+
        <span class="timestamp" title={utils.absoluteTimestamp(timestamp)}>
+
          {utils.formatTimestamp(timestamp)}
+
        </span>
+
      {/if}
      {#if lastEdit}
        <div
          class="card-metadata"
@@ -153,12 +155,12 @@
        </div>
      {/if}
      <div class="header-right">
-
        {#if id && editComment}
+
        {#if editComment}
          <div class="edit-buttons">
            <Icon name="pen" onclick={toggleEdit} />
          </div>
        {/if}
-
        {#if id && reactions && reactOnComment}
+
        {#if reactions && reactOnComment}
          <ReactionSelector
            popoverPositionRight="0"
            popoverPositionBottom="1.5rem"
modified src/components/Diff.svelte
@@ -1,6 +1,6 @@
<script lang="ts" module>
  export interface CodeComments {
-
    changeCommentStatus: (
+
    changeCommentStatus?: (
      commentId: string,
      resolved: boolean,
    ) => Promise<void>;
@@ -16,12 +16,14 @@
      body: string,
      embeds: Embed[],
    ) => Promise<void>;
-
    reactOnComment: (
+
    reactOnComment?: (
      publicKey: string,
      commentId: string,
      authors: Author[],
      reaction: string,
    ) => Promise<void>;
+
    // Defaults to `true`.
+
    canReply?: boolean;
    repoDelegates: Author[];
    rid: string;
    threads: Thread<CodeLocation>[];
@@ -430,27 +432,27 @@
                  thread.root.location?.path,
                  rangeAnchorsFromCodeLocation(thread.root.location),
                )}
-
                {#if roles.isDelegateOrAuthor( codeComments.config.publicKey, codeComments.repoDelegates.map(delegate => delegate.did), thread.root.author.did, )}
+
                {#if codeComments.changeCommentStatus && roles.isDelegateOrAuthor( codeComments.config.publicKey, codeComments.repoDelegates.map(delegate => delegate.did), thread.root.author.did, )}
                  <div style:margin-left="auto">
                    {#if thread.root.resolved}
                      <div title="Unresolve comment thread">
                        <Icon
                          name="cross"
-
                          onclick={() =>
-
                            codeComments.changeCommentStatus(
-
                              thread.root.id,
-
                              false,
-
                            )} />
+
                          onclick={partial(
+
                            codeComments.changeCommentStatus,
+
                            thread.root.id,
+
                            false,
+
                          )} />
                      </div>
                    {:else}
                      <div title="Resolve comment thread">
                        <Icon
                          name="checkmark"
-
                          onclick={() =>
-
                            codeComments.changeCommentStatus(
-
                              thread.root.id,
-
                              true,
-
                            )} />
+
                          onclick={partial(
+
                            codeComments.changeCommentStatus,
+
                            thread.root.id,
+
                            true,
+
                          )} />
                      </div>
                    {/if}
                  </div>
@@ -460,18 +462,20 @@
                inline
                rid={codeComments.rid}
                {thread}
-
                reactOnComment={codeComments.config &&
+
                reactOnComment={codeComments.reactOnComment &&
                  partial(
                    codeComments.reactOnComment,
                    codeComments.config.publicKey,
                  )}
-
                createReply={async (body, embeds) => {
-
                  await codeComments.createComment(
-
                    body,
-
                    embeds,
-
                    thread.root.id,
-
                  );
-
                }}
+
                createReply={(codeComments.canReply ?? true)
+
                  ? async (body, embeds) => {
+
                      await codeComments.createComment(
+
                        body,
+
                        embeds,
+
                        thread.root.id,
+
                      );
+
                    }
+
                  : undefined}
                editComment={codeComments.editComment}
                canEditComment={partial(
                  roles.isDelegateOrAuthor,