#4228 Fix not showing the edit and delete buttons when they won't work
Merged 11 months ago by pingou. Opened 11 months ago by pingou.

file modified
+5 -2

@@ -2295,7 +2295,7 @@ 

      token_id = sa.Column(

          sa.String(64),

          sa.ForeignKey("tokens.id", ondelete="CASCADE", onupdate="CASCADE"),

-         nullable=True

+         nullable=True,

      )

      status = sa.Column(sa.String(32), nullable=False)

      user_id = sa.Column(

@@ -3008,7 +3008,10 @@ 

          """ Return a string representation of this object. """

  

          return "Token: %s - name %s - expiration: %s" % (

-             self.id, self.description, self.expiration)

+             self.id,

+             self.description,

+             self.expiration,

+         )

  

      @property

      def expired(self):

file modified
+16 -14

@@ -41,23 +41,25 @@ 

      + '      <a href="/user/' + data.comment_user + '"'

      + '        class="notblue font-weight-bold">'+data.comment_user+'</a>'

      + '      <a class="notblue" title="Permalink to this headline"'

-     + '          href="#comment-' + data.comment_id + '">'

-     + '        <span>commented seconds ago</span>'

+     if (data.comment_id) {

+       _data += ' href="#comment-' + data.comment_id + '"';

+     }

+     _data += '><span>commented seconds ago</span>'

      + '      </a>'

      + '    </div>';

  

-     if ( data.comment_user == username && data.comment_id !== 'undefined') {

-         _data = _data

-     + '    <div class="issue_actions ml-auto">'

-     + '      <a href="/' + data.project + '/pull-request/' + data.request_id + '/comment/' + data.comment_id + '/edit"'

-     + '         class="btn btn-outline-primary border-0" data-comment="' + data.comment_id + '" data-objid="' + data.request_id + '">'

-     + '        <i class="fa fa-pencil"  title="Edit comment"></i>'

-     + '      </a>'

-     + '      <button class="btn btn-outline-primary border-0" title="Remove comment" name="drop_comment" '

-     + '         value="' + data.comment_id + '" type="submit" onclick="return confirm(\'Do you really want to remove this comment?\');" >'

-     + '        <i class="fa fa-trash"></i>'

-     + '      </button>'

-     + '    </div>'

+     if ( data.comment_user == username && data.comment_id !== undefined) {

+       _data = _data

+       + '    <div class="issue_actions ml-auto">'

+       + '      <a href="/' + data.project + '/pull-request/' + data.request_id + '/comment/' + data.comment_id + '/edit"'

+       + '         class="btn btn-outline-primary border-0" data-comment="' + data.comment_id + '" data-objid="' + data.request_id + '">'

+       + '        <i class="fa fa-pencil"  title="Edit comment"></i>'

+       + '      </a>'

+       + '      <button class="btn btn-outline-primary border-0" title="Remove comment" name="drop_comment" '

+       + '         value="' + data.comment_id + '" type="submit" onclick="return confirm(\'Do you really want to remove this comment?\');" >'

+       + '        <i class="fa fa-trash"></i>'

+       + '      </button>'

+       + '    </div>';

      }

  

      _data = _data

If there is no identifier (which is the case when the comment is added
using ajax rather than being received by SSE), the edit and delete
buttons on the comment won't work, so there is no point in showing them,
the users will just have to refresh the page to see them.

In addition, this commit removes the link to the comment itself, for the
same reason.

Fixes https://pagure.io/pagure/issue/4210

rebased onto 6960de88287354bdf6135633c219da293de6f99a

11 months ago

rebased onto a225965

11 months ago

Thanks for the review! :)

Pull-Request has been merged by pingou

11 months ago