From 8ab8ca15f5d8066d0209c30c0ad1afb7a065c334 Mon Sep 17 00:00:00 2001 From: Aga Date: Mon, 13 Nov 2023 17:09:45 +0000 Subject: [PATCH 1/3] add click to copy widget to api field in the account page --- portality/templates/account/view.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/portality/templates/account/view.html b/portality/templates/account/view.html index ab4c8c0de6..dd1c2aa4a2 100644 --- a/portality/templates/account/view.html +++ b/portality/templates/account/view.html @@ -90,7 +90,9 @@

Your API access

{% if account.has_role("api") %}
API Key
- {{ account.api_key }} + {{ account.api_key }} + Copy value +
{% endif %} @@ -121,6 +123,17 @@

Your API access

$(window).scrollTop($(firstError).offset().top - 100) } + {% if account.has_role("api") %} + // Copy API key to clipboard + $('#click-to-copy--api').click(function() { + let value_to_copy = $('#user-api').html(); + navigator.clipboard.writeText(value_to_copy); + var confirmation = $("#copy-confirmation--api"); + confirmation.text("Copied: " + value_to_copy); + confirmation.show().delay(3000).fadeOut(); + }); + {% endif %} + // If the user is editing their own account, make them confirm when email address is updated {% if current_user.id == account.id %} $('form#edit_user').submit(function () { From c0a663ff10d90754abd86f143eaf5add6b7fe0bf Mon Sep 17 00:00:00 2001 From: Aga Date: Mon, 13 Nov 2023 17:16:09 +0000 Subject: [PATCH 2/3] add functional test --- .../testbook/user_management/user_management.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doajtest/testbook/user_management/user_management.yml b/doajtest/testbook/user_management/user_management.yml index a19230dbd9..aeb95a3267 100644 --- a/doajtest/testbook/user_management/user_management.yml +++ b/doajtest/testbook/user_management/user_management.yml @@ -40,6 +40,10 @@ fragments: - Your API Key at the top of the page is updated - You receive a flash message saying your record is updated and the API key has changed + - step: Click "Copy to click" icon next to your API key + results: + - The API key is copied to your clipboard + - Confirmation message appears and dissapears after a moment - step: Enter mismatched passwords into the "Change your password" boxes and click "Update Account" results: @@ -205,3 +209,12 @@ tests: - step: Click on the user's journals results: - All the same journals are still associated with the user + +- title: User account without API role + context: + role: admin + steps: + - step: Find (or create) a user account which does not have the API role + - step: View the user account page at /account/[account name] + results: + - The API key is not displayed From 5ef1f3049f0e769d32bc631c375bd8b8f32b20f9 Mon Sep 17 00:00:00 2001 From: Aga Date: Mon, 13 Nov 2023 17:23:59 +0000 Subject: [PATCH 3/3] fix the functional test --- doajtest/testbook/user_management/user_management.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doajtest/testbook/user_management/user_management.yml b/doajtest/testbook/user_management/user_management.yml index aeb95a3267..55795719bd 100644 --- a/doajtest/testbook/user_management/user_management.yml +++ b/doajtest/testbook/user_management/user_management.yml @@ -40,7 +40,7 @@ fragments: - Your API Key at the top of the page is updated - You receive a flash message saying your record is updated and the API key has changed - - step: Click "Copy to click" icon next to your API key + - step: Click "Click to Copy" icon next to your API key results: - The API key is copied to your clipboard - Confirmation message appears and dissapears after a moment