Commit b0ef53b0 authored by Tiger Watson's avatar Tiger Watson

Merge branch 'rc/add_dashboard_timezone' into 'master'

Add dashboard timezone setting

See merge request gitlab-org/gitlab!33120
parents 448e0446 0f0259ac
...@@ -104,7 +104,7 @@ module Projects ...@@ -104,7 +104,7 @@ module Projects
project_params = { project_params = {
incident_management_setting_attributes: ::Gitlab::Tracking::IncidentManagement.tracking_keys.keys, incident_management_setting_attributes: ::Gitlab::Tracking::IncidentManagement.tracking_keys.keys,
metrics_setting_attributes: [:external_dashboard_url], metrics_setting_attributes: [:external_dashboard_url, :dashboard_timezone],
error_tracking_setting_attributes: [ error_tracking_setting_attributes: [
:enabled, :enabled,
......
...@@ -367,6 +367,10 @@ module ProjectsHelper ...@@ -367,6 +367,10 @@ module ProjectsHelper
@project.metrics_setting_external_dashboard_url @project.metrics_setting_external_dashboard_url
end end
def metrics_dashboard_timezone
@project.metrics_setting_dashboard_timezone
end
def grafana_integration_url def grafana_integration_url
@project.grafana_integration&.grafana_url @project.grafana_integration&.grafana_url
end end
......
...@@ -372,6 +372,7 @@ class Project < ApplicationRecord ...@@ -372,6 +372,7 @@ class Project < ApplicationRecord
delegate :root_ancestor, to: :namespace, allow_nil: true delegate :root_ancestor, to: :namespace, allow_nil: true
delegate :last_pipeline, to: :commit, allow_nil: true delegate :last_pipeline, to: :commit, allow_nil: true
delegate :external_dashboard_url, to: :metrics_setting, allow_nil: true, prefix: true delegate :external_dashboard_url, to: :metrics_setting, allow_nil: true, prefix: true
delegate :dashboard_timezone, to: :metrics_setting, allow_nil: true, prefix: true
delegate :default_git_depth, :default_git_depth=, to: :ci_cd_settings, prefix: :ci delegate :default_git_depth, :default_git_depth=, to: :ci_cd_settings, prefix: :ci
delegate :forward_deployment_enabled, :forward_deployment_enabled=, :forward_deployment_enabled?, to: :ci_cd_settings delegate :forward_deployment_enabled, :forward_deployment_enabled=, :forward_deployment_enabled?, to: :ci_cd_settings
delegate :actual_limits, :actual_plan_name, to: :namespace, allow_nil: true delegate :actual_limits, :actual_plan_name, to: :namespace, allow_nil: true
......
...@@ -6,4 +6,6 @@ class ProjectMetricsSetting < ApplicationRecord ...@@ -6,4 +6,6 @@ class ProjectMetricsSetting < ApplicationRecord
validates :external_dashboard_url, validates :external_dashboard_url,
length: { maximum: 255 }, length: { maximum: 255 },
addressable_url: { enforce_sanitization: true, ascii_only: true } addressable_url: { enforce_sanitization: true, ascii_only: true }
enum dashboard_timezone: { local: 0, utc: 1 }
end end
---
title: Add column dashboard_timezone to project_metrics_setting
merge_request: 33120
author:
type: added
# frozen_string_literal: true
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class RemoveNotNullFromExternalDashboardUrl < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
change_column_null :project_metrics_settings, :external_dashboard_url, true
end
end
# frozen_string_literal: true
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddDashboardTimezoneToProjectMetricsSetting < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :project_metrics_settings, :dashboard_timezone, :integer, limit: 2, null: false, default: 0
end
end
...@@ -5220,7 +5220,8 @@ ALTER SEQUENCE public.project_incident_management_settings_project_id_seq OWNED ...@@ -5220,7 +5220,8 @@ ALTER SEQUENCE public.project_incident_management_settings_project_id_seq OWNED
CREATE TABLE public.project_metrics_settings ( CREATE TABLE public.project_metrics_settings (
project_id integer NOT NULL, project_id integer NOT NULL,
external_dashboard_url character varying NOT NULL external_dashboard_url character varying,
dashboard_timezone smallint DEFAULT 0 NOT NULL
); );
CREATE TABLE public.project_mirror_data ( CREATE TABLE public.project_mirror_data (
...@@ -13798,6 +13799,8 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -13798,6 +13799,8 @@ COPY "schema_migrations" (version) FROM STDIN;
20200528054112 20200528054112
20200528123703 20200528123703
20200528125905 20200528125905
20200528171933
20200601210148
20200602143020 20200602143020
20200603073101 20200603073101
\. \.
......
...@@ -751,6 +751,7 @@ ProjectMetricsSetting: ...@@ -751,6 +751,7 @@ ProjectMetricsSetting:
- external_dashboard_url - external_dashboard_url
- created_at - created_at
- updated_at - updated_at
- dashboard_timezone
Board: Board:
- id - id
- project_id - project_id
......
...@@ -96,7 +96,8 @@ describe Projects::Operations::UpdateService do ...@@ -96,7 +96,8 @@ describe Projects::Operations::UpdateService do
let(:params) do let(:params) do
{ {
metrics_setting_attributes: { metrics_setting_attributes: {
external_dashboard_url: 'http://gitlab.com' external_dashboard_url: 'http://gitlab.com',
dashboard_timezone: 'utc'
} }
} }
end end
...@@ -108,6 +109,7 @@ describe Projects::Operations::UpdateService do ...@@ -108,6 +109,7 @@ describe Projects::Operations::UpdateService do
expect(project.reload.metrics_setting.external_dashboard_url).to eq( expect(project.reload.metrics_setting.external_dashboard_url).to eq(
'http://gitlab.com' 'http://gitlab.com'
) )
expect(project.metrics_setting.dashboard_timezone).to eq('utc')
end end
end end
...@@ -122,6 +124,7 @@ describe Projects::Operations::UpdateService do ...@@ -122,6 +124,7 @@ describe Projects::Operations::UpdateService do
expect(project.reload.metrics_setting.external_dashboard_url).to eq( expect(project.reload.metrics_setting.external_dashboard_url).to eq(
'http://gitlab.com' 'http://gitlab.com'
) )
expect(project.metrics_setting.dashboard_timezone).to eq('utc')
end end
context 'with blank external_dashboard_url in params' do context 'with blank external_dashboard_url in params' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment