From f8e74da72115bc8e9908385da9c46ae0e100e8e5 Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Thu, 13 Sep 2018 14:04:43 +0100 Subject: Review changes --- .../clusters/components/gcp_signup_offer.js | 2 +- app/assets/javascripts/pages/root/index.js | 1 + app/assets/javascripts/persistent_user_callout.js | 2 ++ app/helpers/dashboard_helper.rb | 23 ++++++++++++++++++++++ app/views/explore/groups/index.html.haml | 3 +++ app/views/explore/projects/index.html.haml | 3 +++ app/views/explore/projects/starred.html.haml | 3 +++ app/views/explore/projects/trending.html.haml | 3 +++ 8 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/pages/root/index.js (limited to 'app') diff --git a/app/assets/javascripts/clusters/components/gcp_signup_offer.js b/app/assets/javascripts/clusters/components/gcp_signup_offer.js index 38663bd4898..04b778c6be9 100644 --- a/app/assets/javascripts/clusters/components/gcp_signup_offer.js +++ b/app/assets/javascripts/clusters/components/gcp_signup_offer.js @@ -4,5 +4,5 @@ export default function gcpSignupOffer() { const alertEl = document.querySelector('.gcp-signup-offer'); if (!alertEl) return; - new PersistentUserCallout(alertEl).init(); + new PersistentUserCallout(alertEl); } diff --git a/app/assets/javascripts/pages/root/index.js b/app/assets/javascripts/pages/root/index.js new file mode 100644 index 00000000000..bb3e672a000 --- /dev/null +++ b/app/assets/javascripts/pages/root/index.js @@ -0,0 +1 @@ +import '../dashboard/projects/index'; diff --git a/app/assets/javascripts/persistent_user_callout.js b/app/assets/javascripts/persistent_user_callout.js index d136b3bfee9..1e34e74a152 100644 --- a/app/assets/javascripts/persistent_user_callout.js +++ b/app/assets/javascripts/persistent_user_callout.js @@ -8,6 +8,8 @@ export default class PersistentUserCallout { this.container = container; this.dismissEndpoint = dismissEndpoint; this.featureId = featureId; + + this.init(); } init() { diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index 19aa55a8d49..7a0e2135b94 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -19,6 +19,29 @@ module DashboardHelper links.any? { |link| dashboard_nav_link?(link) } end + def controller_action_to_child_dashboards(controller = controller_name, action = action_name) + case "#{controller}##{action}" + when 'projects#index', 'root#index', 'projects#starred', 'projects#trending' + ['projects', 'stars'] + when 'dashboard#activity' + ['starred_project_activity', 'project_activity'] + when 'groups#index' + ['groups'] + when 'todos#index' + ['todos'] + when 'dashboard#issues' + ['issues'] + when 'dashboard#merge_requests' + ['merge_requests'] + else + [] + end + end + + def is_default_dashboard?(user = current_user) + controller_action_to_child_dashboards.any? {|dashboard| dashboard == user.dashboard } + end + private def get_dashboard_nav_links diff --git a/app/views/explore/groups/index.html.haml b/app/views/explore/groups/index.html.haml index 387c37b7a91..1d8b9c5bc8f 100644 --- a/app/views/explore/groups/index.html.haml +++ b/app/views/explore/groups/index.html.haml @@ -2,6 +2,9 @@ - page_title _("Groups") - header_title _("Groups"), dashboard_groups_path += content_for :above_breadcrumbs_content do + = render_if_exists "shared/gold_trial_callout" + - if current_user = render 'dashboard/groups_head' - else diff --git a/app/views/explore/projects/index.html.haml b/app/views/explore/projects/index.html.haml index 452f390695c..16be5791f83 100644 --- a/app/views/explore/projects/index.html.haml +++ b/app/views/explore/projects/index.html.haml @@ -2,6 +2,9 @@ - page_title _("Projects") - header_title _("Projects"), dashboard_projects_path += content_for :above_breadcrumbs_content do + = render_if_exists "shared/gold_trial_callout" + - if current_user = render 'dashboard/projects_head' - else diff --git a/app/views/explore/projects/starred.html.haml b/app/views/explore/projects/starred.html.haml index 452f390695c..16be5791f83 100644 --- a/app/views/explore/projects/starred.html.haml +++ b/app/views/explore/projects/starred.html.haml @@ -2,6 +2,9 @@ - page_title _("Projects") - header_title _("Projects"), dashboard_projects_path += content_for :above_breadcrumbs_content do + = render_if_exists "shared/gold_trial_callout" + - if current_user = render 'dashboard/projects_head' - else diff --git a/app/views/explore/projects/trending.html.haml b/app/views/explore/projects/trending.html.haml index 452f390695c..16be5791f83 100644 --- a/app/views/explore/projects/trending.html.haml +++ b/app/views/explore/projects/trending.html.haml @@ -2,6 +2,9 @@ - page_title _("Projects") - header_title _("Projects"), dashboard_projects_path += content_for :above_breadcrumbs_content do + = render_if_exists "shared/gold_trial_callout" + - if current_user = render 'dashboard/projects_head' - else -- cgit v1.2.1