Skip to content

Commit

Permalink
added UX changes based on PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
zenmonkeykstop committed Dec 4, 2020
1 parent fae5d1c commit 8fcff8e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
14 changes: 7 additions & 7 deletions securedrop/journalist_app/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def manage_config() -> Union[str, werkzeug.Response]:
flash("Unable to process the image file."
" Try another one.", "logo-error")
finally:
return redirect(url_for("admin.manage_config"))
return redirect(url_for("admin.manage_config") + "#config-logoimage")
else:
for field, errors in list(logo_form.errors.items()):
for error in errors:
Expand All @@ -73,13 +73,13 @@ def update_submission_preferences() -> Optional[werkzeug.Response]:
flash(gettext("Preferences saved."), "submission-preferences-success")
value = not bool(request.form.get('prevent_document_uploads'))
InstanceConfig.set_allow_document_uploads(value)
return redirect(url_for('admin.manage_config'))
return redirect(url_for('admin.manage_config') + "#config-preventuploads")
else:
for field, errors in list(form.errors.items()):
for error in errors:
flash(gettext("Preferences not updated.") + " " + error,
"submission-preferences-error")
return redirect(url_for('admin.manage_config'))
return redirect(url_for('admin.manage_config') + "#config-preventuploads")

@view.route('/update-org-name', methods=['POST'])
@admin_required
Expand All @@ -92,12 +92,12 @@ def update_org_name() -> Union[str, werkzeug.Response]:
flash(gettext("Preferences saved."), "org-name-success")
except Exception:
flash(gettext('Failed to update organization name.'), 'org-name-error')
return redirect(url_for('admin.manage_config'))
return redirect(url_for('admin.manage_config') + "#config-orgname")
else:
for field, errors in list(form.errors.items()):
for error in errors:
flash(error, "org-name-error")
return redirect(url_for('admin.manage_config'))
return redirect(url_for('admin.manage_config') + "#config-orgname")

@view.route('/add', methods=('GET', 'POST'))
@admin_required
Expand Down Expand Up @@ -295,7 +295,7 @@ def new_password(user_id: int) -> werkzeug.Response:
def ossec_test() -> werkzeug.Response:
current_app.logger.error('This is a test OSSEC alert')
flash(gettext('Test alert sent. Please check your email.'),
'notification')
return redirect(url_for('admin.manage_config'))
'testalert-notification')
return redirect(url_for('admin.manage_config') + "#config-testalert")

return view
50 changes: 26 additions & 24 deletions securedrop/journalist_templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@

<h1>{{ gettext('Instance Configuration') }}</h1>

<h2>{{ gettext('Alerts') }}</h2>
<h2 id="config-orgname">{{ gettext('Organization Name') }}</h2>

<p>{{ gettext('Send an encrypted email to verify if OSSEC alerts work correctly:') }}</p>

<p>
<a class="btn" href="{{ url_for('admin.ossec_test') }}" id="test-ossec-alert">
<img src="{{ url_for('static', filename='icons/bell.png') }}" class="icon" width="13" height="15" alt="">
{{ gettext('SEND TEST OSSEC ALERT') }}
</a>
</p>
<form action="{{ url_for('admin.update_org_name') }}" method="post">
<input name="csrf_token" type="hidden" value="{{ csrf_token() }}">
<p>
<label for="organization_name">{{ gettext('Set the organization name used on the SecureDrop web interfaces:') }}</label><br>
{{ organization_name_form.organization_name() }}
</p>
<button type="submit" id="submit-update-org-name">
<img src="{{ url_for('static', filename='icons/pencil-alt.png') }}" class="icon" width="15" height="15" alt="">
{{ gettext('SET ORGANIZATION NAME') }}
</button>
{% set prefs_filter = ["org-name-error","org-name-success"] %}
{% include 'preferences_saved_flash.html' %}
</form>

<hr class="no-line">

<h2>{{ gettext('Logo Image') }}</h2>
<h2 id="config-logoimage">{{ gettext('Logo Image') }}</h2>

<p>{{ gettext('Here you can update the image displayed on the SecureDrop web interfaces:') }}</p>

Expand All @@ -47,7 +52,7 @@ <h5>

<hr class="no-line">

<h2>{{ gettext('Submission Preferences') }}</h2>
<h2 id="config-preventuploads">{{ gettext('Submission Preferences') }}</h2>

<form action="{{ url_for('admin.update_submission_preferences') }}" method="post">
<input name="csrf_token" type="hidden" value="{{ csrf_token() }}">
Expand All @@ -65,20 +70,17 @@ <h2>{{ gettext('Submission Preferences') }}</h2>

<hr class="no-line">

<h2>{{ gettext('Organization Name') }}</h2>
<h2 id="config-testalert">{{ gettext('Alerts') }}</h2>

<form action="{{ url_for('admin.update_org_name') }}" method="post">
<input name="csrf_token" type="hidden" value="{{ csrf_token() }}">
<p>
<label for="organization_name">{{ gettext('Set your organization name:') }}</label>
{{ organization_name_form.organization_name() }}
</p>
<button type="submit" id="submit-update-org-name">
<img src="{{ url_for('static', filename='icons/pencil-alt.png') }}" class="icon" width="15" height="15" alt="">
{{ gettext('SET ORGANIZATION NAME') }}
</button>
{% set prefs_filter = ["org-name-error","org-name-success"] %}
<p>{{ gettext('Send an encrypted email to verify if OSSEC alerts work correctly:') }}</p>

<p>
<a class="btn" href="{{ url_for('admin.ossec_test') }}" id="test-ossec-alert">
<img src="{{ url_for('static', filename='icons/bell.png') }}" class="icon" width="13" height="15" alt="">
{{ gettext('SEND TEST OSSEC ALERT') }}
</a>
{% set prefs_filter = ["testalert-success","testalert-error","testalert-notification"] %}
{% include 'preferences_saved_flash.html' %}
</form>
</p>

{% endblock %}
2 changes: 1 addition & 1 deletion securedrop/journalist_templates/flashed.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
{% if category not in ["banner-warning","logo-success","logo-error","submission-preferences-success","submission-preferences-error","org-name-success","org-name-error"] %}
{% if category not in ["banner-warning","logo-success","logo-error","submission-preferences-success","submission-preferences-error","org-name-success","org-name-error", "testalert-success", "testalert-error", "testalert-notification"] %}
<div class="flash {{ category }}">
{% if category == "notification" %}
<img src="{{ url_for('static', filename='i/font-awesome/info-circle-black.png') }}" height="16" width="20">
Expand Down
4 changes: 4 additions & 0 deletions securedrop/source_templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% if g.organization_name == "SecureDrop" %}
<title>{{ g.organization_name }} | {{ gettext('Protecting Journalists and Sources') }}</title>
{% else %}
<title>{{ g.organization_name }} | {{ gettext('SecureDrop') }}</title>
{% endif %}

<link rel="stylesheet" href="/static/css/source.css">
<link rel="icon" type="image/png" href="/static/i/favicon.png">
Expand Down
6 changes: 5 additions & 1 deletion securedrop/source_templates/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<!DOCTYPE html>
<html lang="{{ g.html_lang }}" dir="{{ g.text_direction }}">
<head>
<title> {{ g.organization_name }} | {{ gettext('Protecting Journalists and Sources') }}</title>
{% if g.organization_name == "SecureDrop" %}
<title>{{ g.organization_name }} | {{ gettext('Protecting Journalists and Sources') }}</title>
{% else %}
<title>{{ g.organization_name }} | {{ gettext('SecureDrop') }}</title>
{% endif %}

<link rel="stylesheet" href="/static/css/source.css">
<link rel="icon" type="image/png" href="/static/i/favicon.png">
Expand Down

0 comments on commit 8fcff8e

Please sign in to comment.