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
project_params = {
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: [
:enabled,
......
......@@ -367,6 +367,10 @@ module ProjectsHelper
@project.metrics_setting_external_dashboard_url
end
def metrics_dashboard_timezone
@project.metrics_setting_dashboard_timezone
end
def grafana_integration_url
@project.grafana_integration&.grafana_url
end
......
......@@ -372,6 +372,7 @@ class Project < ApplicationRecord
delegate :root_ancestor, to: :namespace, allow_nil: true
delegate :last_pipeline, to: :commit, allow_nil: 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 :forward_deployment_enabled, :forward_deployment_enabled=, :forward_deployment_enabled?, to: :ci_cd_settings
delegate :actual_limits, :actual_plan_name, to: :namespace, allow_nil: true
......
......@@ -6,4 +6,6 @@ class ProjectMetricsSetting < ApplicationRecord
validates :external_dashboard_url,
length: { maximum: 255 },
addressable_url: { enforce_sanitization: true, ascii_only: true }
enum dashboard_timezone: { local: 0, utc: 1 }
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
CREATE TABLE public.project_metrics_settings (
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 (
......@@ -13798,6 +13799,8 @@ COPY "schema_migrations" (version) FROM STDIN;
20200528054112
20200528123703
20200528125905
20200528171933
20200601210148
20200602143020
20200603073101
\.
......
......@@ -751,6 +751,7 @@ ProjectMetricsSetting:
- external_dashboard_url
- created_at
- updated_at
- dashboard_timezone
Board:
- id
- project_id
......
......@@ -96,7 +96,8 @@ describe Projects::Operations::UpdateService do
let(:params) do
{
metrics_setting_attributes: {
external_dashboard_url: 'http://gitlab.com'
external_dashboard_url: 'http://gitlab.com',
dashboard_timezone: 'utc'
}
}
end
......@@ -108,6 +109,7 @@ describe Projects::Operations::UpdateService do
expect(project.reload.metrics_setting.external_dashboard_url).to eq(
'http://gitlab.com'
)
expect(project.metrics_setting.dashboard_timezone).to eq('utc')
end
end
......@@ -122,6 +124,7 @@ describe Projects::Operations::UpdateService do
expect(project.reload.metrics_setting.external_dashboard_url).to eq(
'http://gitlab.com'
)
expect(project.metrics_setting.dashboard_timezone).to eq('utc')
end
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