Skip to content

Commit 958a0c2

Browse files
Add dashboard lock/unlock actions in menu and fix assert_nil for Redmine master compatibility
1 parent 5d6f02b commit 958a0c2

File tree

20 files changed

+189
-1
lines changed

20 files changed

+189
-1
lines changed

app/controllers/dashboards_controller.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,22 @@ def destroy
155155
end
156156
end
157157

158+
def lock
159+
return render_403 unless @dashboard.editable?
160+
161+
@dashboard.update! locked: true
162+
flash[:notice] = l :notice_successful_update
163+
redirect_to dashboard_link_path(@project, @dashboard)
164+
end
165+
166+
def unlock
167+
return render_403 unless @dashboard.editable?
168+
169+
@dashboard.update! locked: false
170+
flash[:notice] = l :notice_successful_update
171+
redirect_to dashboard_link_path(@project, @dashboard)
172+
end
173+
158174
def update_layout_setting
159175
block_settings = params[:settings] || {}
160176

app/views/projects/show.html.slim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@
5555
= link_to sprite_icon('copy', entity_headline(object_name: :label_dashboard, type: :copy)),
5656
new_project_dashboard_path(@project, copy: @dashboard.id),
5757
class: 'icon icon-copy'
58+
- if @dashboard.locked?
59+
= link_to svg_icon_tag('unlock', label: :label_dashboard_unlock, plugin: ''),
60+
unlock_project_dashboard_path(@project, @dashboard),
61+
data: { confirm: l(:text_dashboard_unlock_confirmation) },
62+
method: :put,
63+
class: 'icon icon-unlock'
64+
- else
65+
= link_to svg_icon_tag('lock', label: :label_dashboard_lock, plugin: ''),
66+
lock_project_dashboard_path(@project, @dashboard),
67+
data: { confirm: l(:text_dashboard_lock_confirmation) },
68+
method: :put,
69+
class: 'icon icon-lock'
5870

5971
- if @dashboard&.deletable?
6072
= delete_dashboard_link project_dashboard_path(@project, @dashboard), @dashboard

app/views/welcome/index.html.slim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
= link_to sprite_icon('copy', entity_headline(object_name: :label_dashboard, type: :copy)),
2626
new_dashboard_path(copy: @dashboard.id),
2727
class: 'icon icon-copy'
28+
- if @dashboard.locked?
29+
= link_to svg_icon_tag('unlock', label: :label_dashboard_unlock, plugin: ''),
30+
unlock_dashboard_path(@dashboard),
31+
data: { confirm: l(:text_dashboard_unlock_confirmation) },
32+
method: :put,
33+
class: 'icon icon-unlock'
34+
- else
35+
= link_to svg_icon_tag('lock', label: :label_dashboard_lock, plugin: ''),
36+
lock_dashboard_path(@dashboard),
37+
data: { confirm: l(:text_dashboard_lock_confirmation) },
38+
method: :put,
39+
class: 'icon icon-lock'
2840
- if @dashboard&.deletable?
2941
= delete_dashboard_link dashboard_path(@dashboard), @dashboard
3042
= sidebar_action_toggle @dashboard_sidebar, @dashboard

config/locales/cs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ cs:
9090
label_dashboard_block_info_async: "Tento blok se načítá asynchronně a ukládá se do mezipaměti po dobu %{time}."
9191
label_dashboard_legacy_left: "Zbývá standardní obsah"
9292
label_dashboard_legacy_right: "Standardní obsahové právo"
93+
label_dashboard_lock: Aktivovat zámek dashboardu
9394
label_dashboard_lock_is_active: "Dashboard Zámek je aktivní"
9495
label_dashboard_plural: Dashboards
96+
label_dashboard_unlock: Odstranit zámek dashboardu
9597
label_day: den
9698
label_default_sort_by: "Výchozí třídění podle"
9799
label_disable_sidebar: "Zakázat sidebar"
@@ -222,3 +224,5 @@ cs:
222224
field_watched_by_me: "Sledováno mnou"
223225
label_with_amount: "Částka %{value}"
224226
label_list_all_entries: "Seznam všech %{value}"
227+
text_dashboard_lock_confirmation: Opravdu chcete zamknout tento dashboard?
228+
text_dashboard_unlock_confirmation: Opravdu chcete odemknout tento dashboard?

config/locales/de.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ de:
9090
label_dashboard_block_info_async: Dieser Block wird asynchron geladen und %{time} gecached.
9191
label_dashboard_legacy_left: Standard-Inhalt links
9292
label_dashboard_legacy_right: Standard-Inhalt rechts
93+
label_dashboard_lock: Dashboard Schutz aktivieren
9394
label_dashboard_lock_is_active: Dashboard Schutz ist aktiv
9495
label_dashboard_plural: Dashboards
96+
label_dashboard_unlock: Dashboard Schutz entfernen
9597
label_day: Tag
9698
label_default_sort_by: Standard-Sortierreihenfolge
9799
label_disable_sidebar: Sidebar deaktivieren
@@ -222,3 +224,5 @@ de:
222224
field_watched_by_me: Von mir beobachtet
223225
label_with_amount: "Anzahl %{value}"
224226
label_list_all_entries: "Alle %{value} auflisten"
227+
text_dashboard_lock_confirmation: Möchtest du dieses Dashboard wirklich sperren?
228+
text_dashboard_unlock_confirmation: Möchtest du die Sperre für dieses Dashboard wirklich aufheben?

config/locales/en.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ en:
9090
label_dashboard_block_info_async: This block is loaded asynchronous and cached for %{time}.
9191
label_dashboard_legacy_left: "Standard content left"
9292
label_dashboard_legacy_right: "Standard content right"
93+
label_dashboard_lock: Activate dashboard lock
9394
label_dashboard_lock_is_active: Dashboard lock is active
9495
label_dashboard_plural: Dashboards
96+
label_dashboard_unlock: Remove dashboard lock
9597
label_day: day
9698
label_default_sort_by: Default sort by
9799
label_disable_sidebar: Disable sidebar
@@ -222,3 +224,5 @@ en:
222224
field_watched_by_me: Watched by me
223225
label_with_amount: "Amount %{value}"
224226
label_list_all_entries: "List all %{value}"
227+
text_dashboard_lock_confirmation: Are you sure you want to lock this dashboard?
228+
text_dashboard_unlock_confirmation: Are you sure you want to unlock this dashboard?

config/locales/es.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ es:
9090
label_dashboard_block_info_async: "Este bloque se carga de forma asíncrona y se almacena en caché durante %{time}."
9191
label_dashboard_legacy_left: "Contenido estándar a la izquierda"
9292
label_dashboard_legacy_right: "Contenido estándar correcto"
93+
label_dashboard_lock: Activar bloqueo del dashboard
9394
label_dashboard_lock_is_active: "Dashboard bloqueo activo"
9495
label_dashboard_plural: Dashboards
96+
label_dashboard_unlock: Eliminar bloqueo del dashboard
9597
label_day: día
9698
label_default_sort_by: "Ordenar por defecto por"
9799
label_disable_sidebar: "Deshabilitar la barra lateral"
@@ -222,3 +224,5 @@ es:
222224
field_watched_by_me: "Vigilado por mí"
223225
label_with_amount: "Importe %{value}"
224226
label_list_all_entries: "Lista completa %{value}"
227+
text_dashboard_lock_confirmation: ¿Está seguro de que desea bloquear este dashboard?
228+
text_dashboard_unlock_confirmation: ¿Está seguro de que desea desbloquear este dashboard?

config/locales/fr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ fr:
9090
label_dashboard_block_info_async: "Ce bloc est chargé de manière asynchrone et mis en cache pendant %{time}."
9191
label_dashboard_legacy_left: "Contenu standard à gauche"
9292
label_dashboard_legacy_right: "Droit au contenu standard"
93+
label_dashboard_lock: Activer le verrouillage du tableau de bord
9394
label_dashboard_lock_is_active: "Dashboard blocage est activé"
9495
label_dashboard_plural: Tableaux de bord
96+
label_dashboard_unlock: Supprimer le verrouillage du tableau de bord
9597
label_day: Jour
9698
label_default_sort_by: "Tri par défaut"
9799
label_disable_sidebar: "Désactiver la sidebar"
@@ -222,3 +224,5 @@ fr:
222224
field_watched_by_me: "Surveillé par moi"
223225
label_with_amount: "Montant %{value}"
224226
label_list_all_entries: "Liste complète %{value}"
227+
text_dashboard_lock_confirmation: Êtes-vous sûr de vouloir verrouiller ce tableau de bord?
228+
text_dashboard_unlock_confirmation: Êtes-vous sûr de vouloir déverrouiller ce tableau de bord?

config/locales/it.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ it:
9090
label_dashboard_block_info_async: "Questo blocco viene caricato in modo asincrono e memorizzato nella cache per %{time}."
9191
label_dashboard_legacy_left: "Contenuto standard a sinistra"
9292
label_dashboard_legacy_right: "Contenuto standard a destra"
93+
label_dashboard_lock: Attiva blocco dashboard
9394
label_dashboard_lock_is_active: "Dashboard Blocco attivo"
9495
label_dashboard_plural: Dashboards
96+
label_dashboard_unlock: Rimuovi blocco dashboard
9597
label_day: giorno
9698
label_default_sort_by: "Ordinamento predefinito per"
9799
label_disable_sidebar: "Disattivare la barra laterale"
@@ -222,3 +224,5 @@ it:
222224
field_watched_by_me: "Osservato da me"
223225
label_with_amount: "Importo %{value}"
224226
label_list_all_entries: "Elenco di tutti %{value}"
227+
text_dashboard_lock_confirmation: Sei sicuro di voler bloccare questa dashboard?
228+
text_dashboard_unlock_confirmation: Sei sicuro di voler sbloccare questa dashboard?

config/locales/ja.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ ja:
9090
label_dashboard_block_info_async: のために非同期でブロックがロードされ、キャッシュされます %{time}.
9191
label_dashboard_legacy_left: "標準インハルト左"
9292
label_dashboard_legacy_right: "標準コンテンツの権利"
93+
label_dashboard_lock: ダッシュボードをロック
9394
label_dashboard_lock_is_active: "Dashboard ロックが有効"
9495
label_dashboard_plural: Dashboards
96+
label_dashboard_unlock: ダッシュボードのロックを解除
9597
label_day: ""
9698
label_default_sort_by: "デフォルトの並べ替え"
9799
label_disable_sidebar: "サイドバーを無効にする"
@@ -222,3 +224,5 @@ ja:
222224
field_watched_by_me: "私が見る"
223225
label_with_amount: "金額 %{value}"
224226
label_list_all_entries: "すべて表示 %{value}"
227+
text_dashboard_lock_confirmation: このダッシュボードをロックしてもよろしいですか?
228+
text_dashboard_unlock_confirmation: このダッシュボードのロックを解除してもよろしいですか?

0 commit comments

Comments
 (0)