diff --git a/app/assets/stylesheets/components/table.css.scss b/app/assets/stylesheets/components/table.css.scss index a6f2eef0ae..243a2604ed 100644 --- a/app/assets/stylesheets/components/table.css.scss +++ b/app/assets/stylesheets/components/table.css.scss @@ -134,6 +134,15 @@ tr.gu-mirror { text-align: center; color: $on-surface-muted; } + + td.empty { + white-space: break-spaces; + text-align: center; + padding: 16px; + line-height: 22px; + width: 100%; + color: $on-surface-muted; + } } #scoresheet-table-wrapper td { diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 6d6f89d7a8..2adb6a80c5 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -7,8 +7,9 @@ class RepositoriesController < ApplicationController # GET /repositories.json def index authorize Repository - @repositories = Repository.all - @title = I18n.t('repositories.index.title') + @repositories = policy_scope(Repository.all) + @repositories = @repositories.has_admin(current_user) unless current_user&.zeus? + @title = current_user&.zeus? ? I18n.t('repositories.index.title_zeus') : I18n.t('repositories.index.title') end # GET /repositories/1 diff --git a/app/models/user.rb b/app/models/user.rb index 61900988e2..e530357ad7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -274,6 +274,10 @@ def repository_admin?(repository) @repository_admin.include?(repository.id) end + def a_repository_admin? + zeus? || repositories.any? + end + def personal? institution.nil? end diff --git a/app/views/repositories/index.html.erb b/app/views/repositories/index.html.erb index d63be1605c..b5710719a2 100644 --- a/app/views/repositories/index.html.erb +++ b/app/views/repositories/index.html.erb @@ -2,7 +2,7 @@
-

<%= t ".title" %>

+

<%= @title %>

<% if policy(Repository).new? %>
<%= render 'application/fab_link', url: new_repository_path, icon: 'plus' %> @@ -62,6 +62,11 @@ <% end %> + <% if @repositories.empty? %> + + <%= t ".empty_html" %> + + <% end %>
diff --git a/config/locales/views/repositories/en.yml b/config/locales/views/repositories/en.yml index ad353d865e..135f07e66e 100644 --- a/config/locales/views/repositories/en.yml +++ b/config/locales/views/repositories/en.yml @@ -8,15 +8,17 @@ en: toggle-label: "Feature this repository" remote_cant_be_edited_html: The clone URL can't be edited after the repository was created. Contact dodona@ugent.be if it needs to be changed. index: - title: All exercise repositories + title_zeus: All exercise repositories + title: Your exercise repositories admins: "Edit administrators" courses: "Edit allowed courses" edit: "Edit" delete: "Delete" admin: "You are an administrator of this repository" + empty_html: "You don't have any repositories yet.
Click on the plus button to create your first repository or ask a repository admin you know to add you as an administrator." new: title: Add an exercise repository - help_html: "You can find a guide with more information on managing repositories in our documentation." + help_html: "You can find a guide with more information on managing repositories in our documentation." show: repository: Repository empty_repo_title: "Getting started" diff --git a/config/locales/views/repositories/nl.yml b/config/locales/views/repositories/nl.yml index d7edc73d9a..5fc2bbb0be 100644 --- a/config/locales/views/repositories/nl.yml +++ b/config/locales/views/repositories/nl.yml @@ -8,12 +8,14 @@ nl: toggle-label: "Deze repository uitlichten" remote_cant_be_edited_html: De clone URL kan niet aangepast worden nadat de repository werd aangemaakt. Contacteer dodona@ugent.be als het toch aangepast moet worden. index: - title: Alle oefeningen repository's + title_zeus: Alle oefeningen repository's + title: Jouw oefeningenrepository's admins: "Beheerders aanpassen" courses: "Toegelaten cursussen aanpassen" edit: "Aanpassen" delete: "Verwijderen" admin: "Je bent beheerder van deze repository" + empty_html: "Je hebt nog geen repository's.
Je kan een repository aanmaken via de plus-knop, of je kan aan een repository-beheerder vragen om je toe te voegen aan een repository." new: title: Een repository met oefeningen toevoegen help_html: "Een handleiding met meer informatie over het beheren van een repository kan je in onze documentatie terugvinden."