Skip to content

Commit

Permalink
A11y/fix your profile layout (#1684)
Browse files Browse the repository at this point in the history
* feat(profile-item): add `profile-item` component to display user profile information

* feat(user-profile): update view to use new component

* feat(profile-item): add new css class and use it; regen index.css

* fix(profile-item): remove unused class

* fix(user-profile): update test following new markup

* chore: formatting

* a11y(profile-item): fix issue where `div`s were being created inside of `span`s

* fix(cypress): skip video recording and screenshots for now since they go nowhere anyway

* style(profile-item): align change bottom bottom right; make change font size text-small

* style(profile-item): update styles to match designs

* fix(test): update dom selector
  • Loading branch information
andrewleith authored Oct 10, 2023
1 parent b34134c commit 6eed766
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-admin-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ jobs:
CYPRESS_BASE_URL: ${{needs.deploy-test-admin.outputs.LAMBDA_URL}}
with:
record: false
config: "video=false,screenshotOnRunFailure=false"
build: npx cypress info
working-directory: tests_cypress
spec: |
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/index.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/assets/stylesheets/tailwind/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,7 @@ label {
}
}

.overflow-anywhere {
overflow-wrap: anywhere;
}
/*! purgecss end ignore */
15 changes: 15 additions & 0 deletions app/templates/components/profile-item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% from "components/table.html" import edit_field, text_field %}

{% macro profile_item(label, value, action=None) %}
<div class="flex flex-wrap md:flex-no-wrap items-end border-b-1 border-gray-400 py-5">
<div class="w-full sm:w-3/4" tabindex="0">
<div class="text-gray-600">{{ text_field(label) }}</div>
<div class="font-bold inline-block mt-2 break-words mr-5 overflow-anywhere">{{ value }}</div>
</div>
<div class="w-full sm:w-1/4 sm:text-right">
{% if action %}
<span class="mt-2">{{ edit_field(_('Change'), url_for(action), for="{} {}".format(_('your'), label.lower())) }}</span>
{% endif %}
</div>
</div>
{% endmacro %}
16 changes: 14 additions & 2 deletions app/templates/views/user-profile.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "admin_template.html" %}
{% from "components/table.html" import list_table, row, field %}
{% from "components/table.html" import mapping_table, row, text_field, optional_text_field, edit_field, field, boolean_field with context %}
{% from "components/profile-item.html" import profile_item %}

{% block per_page_title %}
{{ _('Your profile') }}
Expand All @@ -12,6 +13,18 @@

<h1 class="heading-large">{{ _('Your profile') }}</h1>


{{ profile_item(_('Name'), text_field(current_user.name), '.user_profile_name') }}
{{ profile_item(_('Email address'), text_field(current_user.email_address), '.user_profile_email' if can_see_edit else None) }}
{{ profile_item(_('Mobile number'), optional_text_field(current_user.mobile_number), '.user_profile_mobile_number') }}
{{ profile_item(_('Password'), text_field(_('Last changed ') + " " + current_user.password_changed_at|format_delta ), '.user_profile_password') }}
{{ profile_item(_('Security keys'), text_field(num_keys), '.user_profile_security_keys') }}

{% if current_user.platform_admin or session.get('disable_platform_admin_view') %}
{{ profile_item(_('Use platform admin view'), text_field(_('Yes') if not session.get('disable_platform_admin_view') else _('No')), '.user_profile_disable_platform_admin_view') }}
{% endif %}

<!--
<div class="body-copy-table">
{% set caption = _('Your profile') %}
{% set heading_1 = _('Label') %}
Expand Down Expand Up @@ -79,6 +92,5 @@ <h1 class="heading-large">{{ _('Your profile') }}</h1>
</div>

</div> -->
{% endblock %}
3 changes: 2 additions & 1 deletion app/translations/csv/fr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1761,11 +1761,12 @@
"Maximum 612 characters. Some messages may be too long due to custom content.","612 caractères au maximum. Certains messages peuvent être trop longs en raison de leur contenu personnalisé."
"Too many characters","Limite de caractère atteinte"
"New features","Nouvelles fonctionnalités"
"Your","Votre"
"You are browsing templates. Create and copy template or add new folder.","Vous explorez les gabarits. Créer et copier un gabarit ou créer un nouveau dossier."
"Move templates to a new or existing folder","Déplacer les gabarits dans un dossier"
"You are selecting templates. Move templates into a new or existing folder.","Vous sélectionnez les gabarits. Déplacer les gabarits dans un dossier."
"Row number","Numéro de ligne"
"Type","Type"
"Sent by email","Envoyé par courriel"
"Sent Time","Heure d’envoi"
"Job","Tâche"
"Job","Tâche"
4 changes: 2 additions & 2 deletions tests/app/main/views/test_user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def test_overview_page_shows_disable_for_platform_admin(client_request, platform
client_request.login(platform_admin_user)
page = client_request.get(("main.user_profile"))
assert page.select_one("h1").text.strip() == "Your profile"
disable_platform_admin_row = page.select("tr")[-1]
assert " ".join(disable_platform_admin_row.text.split()) == "Use platform admin view Yes Change"
disable_platform_admin_row = page.find_all("div", class_="sm:w-3/4")[-1]
assert " ".join(disable_platform_admin_row.text.split()) == "Use platform admin view Yes"


def test_should_show_name_page(client_request, mock_get_security_keys):
Expand Down

0 comments on commit 6eed766

Please sign in to comment.