diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss
index 5b2a19228..261cbe0c5 100644
--- a/app/assets/stylesheets/admin.scss
+++ b/app/assets/stylesheets/admin.scss
@@ -31,14 +31,6 @@ $table-header: #ecf1f6;
.admin {
@include admin-layout;
- > header {
- border-bottom: 1px solid #eee;
-
- > * {
- @include full-width-background($adjust-margin: false, $adjust-padding: true);
- }
- }
-
h2 {
font-weight: 100;
margin-bottom: $line-height;
@@ -60,86 +52,6 @@ $table-header: #ecf1f6;
float: none;
}
- .top-links {
-
- a {
- line-height: rem-calc($line-height * 1.5);
- }
- }
-
- .top-bar {
- height: auto;
- padding-top: $line-height / 2;
-
- @include breakpoint(small only) {
-
- .top-bar-left ul {
- display: inline-block;
- }
-
- .top-bar-right {
-
- > ul {
- border-bottom: 0;
- padding-bottom: 0;
- margin-bottom: 0;
- }
-
- .submenu {
- position: initial;
- }
-
- a {
- font-weight: normal;
- }
- }
-
- [class^="icon-"] {
- display: none;
- }
- }
-
- [class^="icon-"] {
- font-size: $base-font-size;
- }
-
- h1 {
- margin-top: $line-height / 2;
- margin-bottom: 0;
-
- @include breakpoint(medium) {
- margin-top: 0;
- }
-
- small {
- color: inherit;
- text-transform: uppercase;
- }
-
- a {
- color: inherit;
- display: inline-block;
- font-family: "Lato" !important;
- font-size: rem-calc(24);
- font-weight: lighter;
- line-height: 1;
- }
- }
- }
-
- .top-bar .menu > li {
-
- @include breakpoint(medium) {
- height: auto !important;
- }
- }
-
- .title-bar {
- color: inherit;
- position: absolute;
- right: 12px;
- }
-
.notifications.unread-notifications::after {
color: $admin-color;
}
diff --git a/app/assets/stylesheets/layout/admin_header.scss b/app/assets/stylesheets/layout/admin_header.scss
new file mode 100644
index 000000000..758f1782a
--- /dev/null
+++ b/app/assets/stylesheets/layout/admin_header.scss
@@ -0,0 +1,89 @@
+.admin {
+ > header {
+ border-bottom: 1px solid #eee;
+
+ > * {
+ @include full-width-background($adjust-margin: false, $adjust-padding: true);
+ }
+ }
+
+ .top-links {
+
+ a {
+ line-height: rem-calc($line-height * 1.5);
+ }
+ }
+
+ .top-bar {
+ height: auto;
+ padding-top: $line-height / 2;
+
+ @include breakpoint(small only) {
+
+ .top-bar-left ul {
+ display: inline-block;
+ }
+
+ .top-bar-right {
+
+ > ul {
+ border-bottom: 0;
+ padding-bottom: 0;
+ margin-bottom: 0;
+ }
+
+ .submenu {
+ position: initial;
+ }
+
+ a {
+ font-weight: normal;
+ }
+ }
+
+ [class^="icon-"] {
+ display: none;
+ }
+ }
+
+ [class^="icon-"] {
+ font-size: $base-font-size;
+ }
+
+ h1 {
+ margin-top: $line-height / 2;
+ margin-bottom: 0;
+
+ @include breakpoint(medium) {
+ margin-top: 0;
+ }
+
+ small {
+ color: inherit;
+ text-transform: uppercase;
+ }
+
+ a {
+ color: inherit;
+ display: inline-block;
+ font-family: "Lato" !important;
+ font-size: rem-calc(24);
+ font-weight: lighter;
+ line-height: 1;
+ }
+ }
+ }
+
+ .top-bar .menu > li {
+
+ @include breakpoint(medium) {
+ height: auto !important;
+ }
+ }
+
+ .title-bar {
+ color: inherit;
+ position: absolute;
+ right: 12px;
+ }
+}
diff --git a/app/components/layout/account_menu_component.html.erb b/app/components/layout/account_menu_component.html.erb
new file mode 100644
index 000000000..7c6875c84
--- /dev/null
+++ b/app/components/layout/account_menu_component.html.erb
@@ -0,0 +1,5 @@
+
diff --git a/app/components/layout/account_menu_component.rb b/app/components/layout/account_menu_component.rb
new file mode 100644
index 000000000..b8918c695
--- /dev/null
+++ b/app/components/layout/account_menu_component.rb
@@ -0,0 +1,7 @@
+class Layout::AccountMenuComponent < ApplicationComponent
+ attr_reader :user
+
+ def initialize(user)
+ @user = user
+ end
+end
diff --git a/app/components/layout/admin_header_component.html.erb b/app/components/layout/admin_header_component.html.erb
new file mode 100644
index 000000000..f1be1d2f6
--- /dev/null
+++ b/app/components/layout/admin_header_component.html.erb
@@ -0,0 +1,39 @@
+
diff --git a/app/components/layout/admin_header_component.rb b/app/components/layout/admin_header_component.rb
new file mode 100644
index 000000000..3f97f9656
--- /dev/null
+++ b/app/components/layout/admin_header_component.rb
@@ -0,0 +1,32 @@
+class Layout::AdminHeaderComponent < ApplicationComponent
+ attr_reader :user
+ delegate :namespace, :namespaced_root_path, :show_admin_menu?, to: :helpers
+
+ def initialize(user)
+ @user = user
+ end
+
+ private
+
+ def namespaced_header_title
+ if namespace == "moderation/budgets"
+ t("moderation.header.title")
+ elsif namespace == "management"
+ t("management.dashboard.index.title")
+ else
+ t("#{namespace}.header.title")
+ end
+ end
+
+ def namespace_path
+ if namespace == "officing"
+ "#"
+ else
+ namespaced_root_path
+ end
+ end
+
+ def show_account_menu?
+ show_admin_menu?(user) || namespace != "management"
+ end
+end
diff --git a/app/components/layout/admin_login_items_component.html.erb b/app/components/layout/admin_login_items_component.html.erb
new file mode 100644
index 000000000..a5200f80d
--- /dev/null
+++ b/app/components/layout/admin_login_items_component.html.erb
@@ -0,0 +1,4 @@
+
diff --git a/app/components/layout/admin_login_items_component.rb b/app/components/layout/admin_login_items_component.rb
new file mode 100644
index 000000000..44dd2d429
--- /dev/null
+++ b/app/components/layout/admin_login_items_component.rb
@@ -0,0 +1,49 @@
+class Layout::AdminLoginItemsComponent < ApplicationComponent
+ attr_reader :user
+ delegate :link_list, :show_admin_menu?, to: :helpers
+
+ def initialize(user)
+ @user = user
+ end
+
+ def render?
+ show_admin_menu?(user)
+ end
+
+ private
+
+ def admin_links
+ [
+ (admin_link if user.administrator?),
+ (moderation_link if user.administrator? || user.moderator?),
+ (valuation_link if feature?(:budgets) && (user.administrator? || user.valuator?)),
+ (management_link if user.administrator? || user.manager?),
+ (officing_link if user.poll_officer? && Poll.current.any?),
+ (sdg_management_link if feature?(:sdg) && (user.administrator? || user.sdg_manager?))
+ ]
+ end
+
+ def admin_link
+ [t("layouts.header.administration"), admin_root_path]
+ end
+
+ def moderation_link
+ [t("layouts.header.moderation"), moderation_root_path]
+ end
+
+ def valuation_link
+ [t("layouts.header.valuation"), valuation_root_path]
+ end
+
+ def management_link
+ [t("layouts.header.management"), management_sign_in_path]
+ end
+
+ def officing_link
+ [t("layouts.header.officing"), officing_root_path]
+ end
+
+ def sdg_management_link
+ [t("sdg_management.header.title"), sdg_management_root_path]
+ end
+end
diff --git a/app/views/layouts/_footer.html.erb b/app/components/layout/footer_component.html.erb
similarity index 100%
rename from app/views/layouts/_footer.html.erb
rename to app/components/layout/footer_component.html.erb
diff --git a/app/components/layout/footer_component.rb b/app/components/layout/footer_component.rb
new file mode 100644
index 000000000..b9e0fe5de
--- /dev/null
+++ b/app/components/layout/footer_component.rb
@@ -0,0 +1,2 @@
+class Layout::FooterComponent < ApplicationComponent
+end
diff --git a/app/views/devise/menu/_login_items.html.erb b/app/components/layout/login_items_component.html.erb
similarity index 93%
rename from app/views/devise/menu/_login_items.html.erb
rename to app/components/layout/login_items_component.html.erb
index 0aed7e3a4..b2acca46e 100644
--- a/app/views/devise/menu/_login_items.html.erb
+++ b/app/components/layout/login_items_component.html.erb
@@ -1,7 +1,7 @@
-<% if user_signed_in? %>
+<% if user %>
<%= layout_menu_link_to t("layouts.header.my_activity_link"),
- user_path(current_user),
+ user_path(user),
controller_name == "users",
rel: "nofollow",
title: t("shared.go_to_page") +
diff --git a/app/components/layout/login_items_component.rb b/app/components/layout/login_items_component.rb
new file mode 100644
index 000000000..3ee4e6ee0
--- /dev/null
+++ b/app/components/layout/login_items_component.rb
@@ -0,0 +1,8 @@
+class Layout::LoginItemsComponent < ApplicationComponent
+ attr_reader :user
+ delegate :layout_menu_link_to, to: :helpers
+
+ def initialize(user)
+ @user = user
+ end
+end
diff --git a/app/views/shared/_subnavigation.html.erb b/app/components/layout/subnavigation_component.html.erb
similarity index 100%
rename from app/views/shared/_subnavigation.html.erb
rename to app/components/layout/subnavigation_component.html.erb
diff --git a/app/components/layout/subnavigation_component.rb b/app/components/layout/subnavigation_component.rb
new file mode 100644
index 000000000..57f12a683
--- /dev/null
+++ b/app/components/layout/subnavigation_component.rb
@@ -0,0 +1,3 @@
+class Layout::SubnavigationComponent < ApplicationComponent
+ delegate :content_block, :layout_menu_link_to, to: :helpers
+end
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index 1ec467ead..b89b4533a 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -3,16 +3,6 @@ module AdminHelper
"/#{namespace}"
end
- def namespaced_header_title
- if namespace == "moderation/budgets"
- t("moderation.header.title")
- elsif namespace == "management"
- t("management.dashboard.index.title")
- else
- t("#{namespace}.header.title")
- end
- end
-
def official_level_options
options = [["", 0]]
(1..5).each do |i|
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 90bcc7f30..49db9cb5c 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -35,34 +35,10 @@ module UsersHelper
end
end
- def current_administrator?
- current_user&.administrator?
- end
-
- def current_moderator?
- current_user&.moderator?
- end
-
- def current_valuator?
- current_user&.valuator?
- end
-
- def current_manager?
- current_user&.manager?
- end
-
- def current_sdg_manager?
- current_user&.sdg_manager?
- end
-
- def current_poll_officer?
- current_user&.poll_officer?
- end
-
- def show_admin_menu?(user = nil)
+ def show_admin_menu?(user)
unless namespace == "officing"
- current_administrator? || current_moderator? || current_valuator? || current_manager? ||
- user&.administrator? || current_poll_officer? || current_sdg_manager?
+ user&.administrator? || user&.moderator? || user&.valuator? ||
+ (user&.manager? && namespace != "management") || user&.poll_officer? || user&.sdg_manager?
end
end
diff --git a/app/views/layouts/_admin_header.html.erb b/app/views/layouts/_admin_header.html.erb
deleted file mode 100644
index f8cd11365..000000000
--- a/app/views/layouts/_admin_header.html.erb
+++ /dev/null
@@ -1,50 +0,0 @@
-
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb
index 1e101fa36..bf1884f93 100644
--- a/app/views/layouts/_header.html.erb
+++ b/app/views/layouts/_header.html.erb
@@ -26,15 +26,11 @@