Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moved add comment page into modal on analysis page #1319

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/test/unit/web_interface/test_app_add_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ def add_comment_to_object(_, comment, author, time):

@pytest.mark.WebInterfaceUnitTestConfig(database_mock_class=DbMock)
class TestAppAddComment:
def test_app_add_comment_get_not_in_db(self, test_client):
rv = test_client.get('/comment/abc_123')
assert b'Error: UID not found in database' in rv.data

def test_app_add_comment_get_valid_uid(self, test_client):
rv = test_client.get(f'/comment/{TEST_FW.uid}')
assert b'Error: UID not found in database' not in rv.data
assert b'Add Comment' in rv.data
maringuu marked this conversation as resolved.
Show resolved Hide resolved

def test_app_add_comment_put(self, test_client):
data = {'comment': 'this is the test comment', 'author': 'test author'}
rv = test_client.post(
Expand Down
6 changes: 0 additions & 6 deletions src/web_interface/components/miscellaneous_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ def post_comment(self, uid):
self.db.editing.add_comment_to_object(uid, comment, author, round(time()))
return redirect(url_for('show_analysis', uid=uid))

@roles_accepted(*PRIVILEGES['comment'])
@AppRoute('/comment/<uid>', GET)
def show_add_comment(self, uid):
error = not self.db.frontend.exists(uid)
return render_template('add_comment.html', uid=uid, error=error)

@roles_accepted(*PRIVILEGES['delete'])
@AppRoute('/admin/delete_comment/<uid>/<timestamp>', GET)
def delete_comment(self, uid, timestamp):
Expand Down
68 changes: 0 additions & 68 deletions src/web_interface/templates/add_comment.html

This file was deleted.

49 changes: 44 additions & 5 deletions src/web_interface/templates/show_analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,11 @@ <h5 class="modal-title">Add analysis to file</h5>
<th>
Comments
{# Add Comment Button #}
<form action="/comment/{{ firmware.uid }}" style="float: right; margin-right: 5px;">
<button class="btn btn-primary btn-sm" type="submit">
<i class="far fa-edit"></i> add comment
</button>
</form>
<button class="btn btn-primary btn-sm" type="button" data-toggle="collapse"
data-target="#addCommentCell" aria-expanded="false" aria-controls="addCommentCell"
style="float: right;">
<i class="far fa-edit"></i> add comment
</button>

{# Show Comments Button #}
<form onsubmit="return false;" style="float: right; margin-right: 5px;">
Expand All @@ -397,6 +397,45 @@ <h5 class="modal-title">Add analysis to file</h5>
</th>
</tr>
</thead>
<tbody>
<tr class="collapse" id="addCommentCell">
<td>
<div>
<form class="form-horizontal" id="addCommentForm" action="/comment/{{ uid }}" method=post enctype=multipart/form-data>

<div class="form-group row">
<label class="control-label col-sm-2" for="comment" style="margin-top: 6px;">
Comment:
</label>
<div class="col-xs-12 col-sm-10">
<textarea name="comment" rows="5" style="resize: vertical; position: relative; z-index: 1;" required autofocus class="form-control" id="comment"></textarea>
</div>
</div>

<div class="form-group row">
<label class="control-label col-sm-2" for="author" style="margin-top: 6px;">
Author:
</label>
<div class="col-xs-12 col-sm-10">
<input type="text" name="author" class="form-control" id="author" required
style="position: relative; z-index: 1;" value="anonymous">
</div>
</div>

{% if current_user.is_authenticated %}
<script type="text/javascript">
document.getElementById('author').value = '{{ current_user.email }}';
document.getElementById('author').setAttribute("readonly", true);
</script>
{% endif %}
</form>
</div>
<div>
<button type="submit" class="btn btn-primary" form="addCommentForm">Add Comment</button>
</div>
</td>
</tr>
</tbody>
</table>
{% if firmware.comments %}
<div class="collapse m-0" id="comments">
Expand Down
Loading