summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/graphql/types/base_field.rb24
-rw-r--r--app/graphql/types/commit_type.rb4
-rw-r--r--app/graphql/types/grafana_integration_type.rb4
-rw-r--r--app/graphql/types/merge_request_type.rb5
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/views/shared/issuable/_sort_dropdown.html.haml3
6 files changed, 32 insertions, 10 deletions
diff --git a/app/graphql/types/base_field.rb b/app/graphql/types/base_field.rb
index 1b296f8d52b..148675e9d9e 100644
--- a/app/graphql/types/base_field.rb
+++ b/app/graphql/types/base_field.rb
@@ -12,6 +12,7 @@ module Types
kwargs[:complexity] = field_complexity(kwargs[:resolver_class], kwargs[:complexity])
@feature_flag = kwargs[:feature_flag]
kwargs = check_feature_flag(kwargs)
+ kwargs = handle_deprecated(kwargs)
super(*args, **kwargs, &block)
end
@@ -41,7 +42,7 @@ module Types
attr_reader :feature_flag
def feature_documentation_message(key, description)
- "#{description}. Available only when feature flag `#{key}` is enabled."
+ "#{description}. Available only when feature flag `#{key}` is enabled"
end
def check_feature_flag(args)
@@ -51,6 +52,27 @@ module Types
args
end
+ def handle_deprecated(kwargs)
+ if kwargs[:deprecation_reason].present?
+ raise ArgumentError, 'Use `deprecated` property instead of `deprecation_reason`. ' \
+ 'See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#deprecating-fields'
+ end
+
+ deprecation = kwargs.delete(:deprecated)
+ return kwargs unless deprecation
+
+ milestone, reason = deprecation.values_at(:milestone, :reason).map(&:presence)
+
+ raise ArgumentError, 'Please provide a `milestone` within `deprecated`' unless milestone
+ raise ArgumentError, 'Please provide a `reason` within `deprecated`' unless reason
+
+ deprecated_in = "Deprecated in #{milestone}"
+ kwargs[:deprecation_reason] = "#{reason}. #{deprecated_in}"
+ kwargs[:description] += ". #{deprecated_in}: #{reason}" if kwargs[:description]
+
+ kwargs
+ end
+
def field_complexity(resolver_class, current)
return current if current.present? && current > 0
diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb
index eb25e3651a8..437da3bb585 100644
--- a/app/graphql/types/commit_type.rb
+++ b/app/graphql/types/commit_type.rb
@@ -44,8 +44,8 @@ module Types
field :latest_pipeline,
type: Types::Ci::PipelineType,
null: true,
- description: "Latest pipeline of the commit",
- deprecation_reason: 'Use pipelines',
+ deprecated: { reason: 'Use `pipelines`', milestone: 12.5 },
+ description: 'Latest pipeline of the commit',
resolver: Resolvers::CommitPipelinesResolver.last
end
end
diff --git a/app/graphql/types/grafana_integration_type.rb b/app/graphql/types/grafana_integration_type.rb
index f234008ee0d..71018f6ce0a 100644
--- a/app/graphql/types/grafana_integration_type.rb
+++ b/app/graphql/types/grafana_integration_type.rb
@@ -18,8 +18,8 @@ module Types
description: 'Timestamp of the issue\'s last activity'
field :token, GraphQL::STRING_TYPE, null: false,
- deprecation_reason: 'Plain text token has been masked for security reasons',
- description: 'API token for the Grafana integration. Field is permanently masked.'
+ deprecated: { reason: 'Plain text token has been masked for security reasons', milestone: 12.7 },
+ description: 'API token for the Grafana integration'
def token
object.masked_token
diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb
index 0da95b367d8..8cb439cb465 100644
--- a/app/graphql/types/merge_request_type.rb
+++ b/app/graphql/types/merge_request_type.rb
@@ -74,8 +74,9 @@ module Types
description: 'Rebase commit SHA of the merge request'
field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true,
description: 'Indicates if there is a rebase currently in progress for the merge request'
- field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true, deprecation_reason: "Renamed to defaultMergeCommitMessage",
- description: 'Deprecated - renamed to defaultMergeCommitMessage'
+ field :merge_commit_message, GraphQL::STRING_TYPE, method: :default_merge_commit_message, null: true,
+ deprecated: { reason: 'Use `defaultMergeCommitMessage`', milestone: 11.8 },
+ description: 'Default merge commit message of the merge request'
field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true,
description: 'Default merge commit message of the merge request'
field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false,
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index aae45144f1a..2deece8c7cd 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -130,7 +130,7 @@ class Namespace < ApplicationRecord
return unless host.ends_with?(gitlab_host)
name = host.delete_suffix(gitlab_host)
- Namespace.where(parent_id: nil).find_by_path(name)
+ Namespace.where(parent_id: nil).by_path(name)
end
# overridden in ee
diff --git a/app/views/shared/issuable/_sort_dropdown.html.haml b/app/views/shared/issuable/_sort_dropdown.html.haml
index 8260915c2ab..9c151dc96f3 100644
--- a/app/views/shared/issuable/_sort_dropdown.html.haml
+++ b/app/views/shared/issuable/_sort_dropdown.html.haml
@@ -1,7 +1,6 @@
- sort_value = @sort
- sort_title = issuable_sort_option_title(sort_value)
- viewing_issues = controller.controller_name == 'issues' || controller.action_name == 'issues'
-- manual_sorting = viewing_issues && controller.controller_name != 'dashboard'
.dropdown.inline.prepend-left-10.issue-sort-dropdown
.btn-group{ role: 'group' }
@@ -18,6 +17,6 @@
= sortable_item(sort_title_due_date, page_filter_path(sort: sort_value_due_date), sort_title) if viewing_issues
= sortable_item(sort_title_popularity, page_filter_path(sort: sort_value_popularity), sort_title)
= sortable_item(sort_title_label_priority, page_filter_path(sort: sort_value_label_priority), sort_title)
- = sortable_item(sort_title_relative_position, page_filter_path(sort: sort_value_relative_position), sort_title) if manual_sorting
+ = sortable_item(sort_title_relative_position, page_filter_path(sort: sort_value_relative_position), sort_title) if viewing_issues
= render_if_exists('shared/ee/issuable/sort_dropdown', viewing_issues: viewing_issues, sort_title: sort_title)
= issuable_sort_direction_button(sort_value)