Skip to content

Commit 372d571

Browse files
authored
Improved rendering of repository URL in student assignment view (#7807)
* Made the URL not render as a link * Added copy functionality
1 parent a51fef5 commit 372d571

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Prevent "No rows found" message from displaying in tables when data is loading (#7790)
2121
- Prevent ZIP files from being previewed in the assignment file viewer (#7802)
2222
- Display descriptive error message when scanned exam template name exceeds the 20-character limit (#7796)
23+
- Made repository URL not a link for student assignment view when version control is enabled (#7807)
2324

2425
### 🔧 Internal changes
2526
- Updated autotest seed files to ensure settings follow tester JSON schema (#7775)

app/assets/stylesheets/common/_markus.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,13 @@ kbd {
628628
li {
629629
margin-bottom: 0.5em;
630630
}
631+
632+
.copy-url-button {
633+
margin-left: 0.5em;
634+
margin-bottom: 0.3em;
635+
min-width: auto;
636+
padding: 0.2em 0.1em 0.2em 0.4em;
637+
}
631638
}
632639
}
633640
}

app/javascript/common/fontawesome_config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
faClose,
1717
faComments,
1818
faCompress,
19+
faCopy,
1920
faDice,
2021
faDownload,
2122
faEnvelopeCircleCheck,
@@ -77,6 +78,7 @@ library.add(
7778
faClose,
7879
faComments,
7980
faCompress,
81+
faCopy,
8082
faDice,
8183
faDownload,
8284
faEnvelopeCircleCheck,

app/views/assignments/_read.html.erb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@
124124
<% if allowed_to?(:access_repo?, @grouping) %>
125125
<h3><%= t('groups.student_interface.url_repository') %></h3>
126126
<div class='sub_block'>
127-
HTTPS: <a href='#'><%= @grouping.group.repository_external_access_url %></a>
127+
HTTPS: <code><%= @grouping.group.repository_external_access_url %></code>
128+
<button class="copy-url-button" data-clipboard-text="<%= @grouping.group.repository_external_access_url %>">
129+
<i class="fa-solid fa-copy"></i>
130+
</button>
128131
<% if allowed_to?(:view?, with: KeyPairPolicy) %>
129132
<br>
130-
SSH: <a href='#'><%= @grouping.group.repository_ssh_access_url %></a>
133+
SSH: <code><%= @grouping.group.repository_ssh_access_url %></code>
134+
<button class="copy-url-button" data-clipboard-text="<%= @grouping.group.repository_ssh_access_url %>">
135+
<i class="fa-solid fa-copy"></i>
136+
</button>
131137
<% end %>
132138
</div>
133139
<% end %>
@@ -201,3 +207,18 @@
201207
<% end %>
202208
<% end %>
203209
</div>
210+
211+
<%= javascript_tag nonce: true do %>
212+
document.addEventListener("DOMContentLoaded", () => {
213+
document.querySelectorAll('.copy-url-button').forEach(button => {
214+
button.addEventListener('click', () => {
215+
navigator.clipboard.writeText(button.dataset.clipboardText).then(() => {
216+
var flashDiv = document.getElementsByClassName("success")[0];
217+
var contents = flashDiv.getElementsByClassName("flash-content")[0] || flashDiv;
218+
contents.innerHTML = "<p><%= t('groups.student_interface.copied_to_clipboard') %></p>";
219+
flashDiv.style.display = "block";
220+
});
221+
});
222+
});
223+
});
224+
<% end %>

config/locales/views/groups/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ en:
7777
student_interface:
7878
confirm_create_group: This action will decline your pending invitations. Are you sure?
7979
confirm_delete_group: 'WARNING: You will lose access to your submitted files after deleting your group. Make sure you have a local copy of your files before clicking OK.'
80+
copied_to_clipboard: Successfully copied to clipboard.
8081
form_group: Create a group
8182
group_information: Group information
8283
group_options: Group options

0 commit comments

Comments
 (0)