Commit 7bfa0963 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch '332408-display-icon-for-issues-created-by-banned-users-on-boards' into 'master'

Add `hidden` field to GraphQL `Issue` type

See merge request gitlab-org/gitlab!69323
parents 5b951df0 2c7c87c0
......@@ -53,6 +53,9 @@ module Types
description: 'Due date of the issue.'
field :confidential, GraphQL::Types::Boolean, null: false,
description: 'Indicates the issue is confidential.'
field :hidden, GraphQL::Types::Boolean, null: true, resolver_method: :hidden?,
description: 'Indicates the issue is hidden because the author has been banned. ' \
'Will always return `null` if `ban_user_feature_flag` feature flag is disabled.'
field :discussion_locked, GraphQL::Types::Boolean, null: false,
description: 'Indicates discussion is locked on the issue.'
......@@ -156,6 +159,10 @@ module Types
def create_note_email
object.creatable_note_email_address(context[:current_user])
end
def hidden?
object.hidden? if Feature.enabled?(:ban_user_feature_flag)
end
end
end
......
......@@ -9430,6 +9430,7 @@ Relationship between an epic and an issue.
| <a id="epicissueepic"></a>`epic` | [`Epic`](#epic) | Epic to which this issue belongs. |
| <a id="epicissueepicissueid"></a>`epicIssueId` | [`ID!`](#id) | ID of the epic-issue relation. |
| <a id="epicissuehealthstatus"></a>`healthStatus` | [`HealthStatus`](#healthstatus) | Current health status. |
| <a id="epicissuehidden"></a>`hidden` | [`Boolean`](#boolean) | Indicates the issue is hidden because the author has been banned. Will always return `null` if `ban_user_feature_flag` feature flag is disabled. |
| <a id="epicissuehumantimeestimate"></a>`humanTimeEstimate` | [`String`](#string) | Human-readable time estimate of the issue. |
| <a id="epicissuehumantotaltimespent"></a>`humanTotalTimeSpent` | [`String`](#string) | Human-readable total time reported as spent on the issue. |
| <a id="epicissueid"></a>`id` | [`ID`](#id) | Global ID of the epic-issue relation. |
......@@ -10556,6 +10557,7 @@ Returns [`VulnerabilitySeveritiesCount`](#vulnerabilityseveritiescount).
| <a id="issueemailsdisabled"></a>`emailsDisabled` | [`Boolean!`](#boolean) | Indicates if a project has email notifications disabled: `true` if email notifications are disabled. |
| <a id="issueepic"></a>`epic` | [`Epic`](#epic) | Epic to which this issue belongs. |
| <a id="issuehealthstatus"></a>`healthStatus` | [`HealthStatus`](#healthstatus) | Current health status. |
| <a id="issuehidden"></a>`hidden` | [`Boolean`](#boolean) | Indicates the issue is hidden because the author has been banned. Will always return `null` if `ban_user_feature_flag` feature flag is disabled. |
| <a id="issuehumantimeestimate"></a>`humanTimeEstimate` | [`String`](#string) | Human-readable time estimate of the issue. |
| <a id="issuehumantotaltimespent"></a>`humanTotalTimeSpent` | [`String`](#string) | Human-readable total time reported as spent on the issue. |
| <a id="issueid"></a>`id` | [`ID!`](#id) | ID of the issue. |
......
......@@ -15,7 +15,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
it 'has specific fields' do
fields = %i[id iid title description state reference author assignees updated_by participants labels milestone due_date
confidential discussion_locked upvotes downvotes merge_requests_count user_notes_count user_discussions_count web_path web_url relative_position
confidential hidden discussion_locked upvotes downvotes merge_requests_count user_notes_count user_discussions_count web_path web_url relative_position
emails_disabled subscribed time_estimate total_time_spent human_time_estimate human_total_time_spent closed_at created_at updated_at task_completion_status
design_collection alert_management_alert severity current_user_todos moved moved_to
create_note_email timelogs project_id]
......@@ -201,4 +201,54 @@ RSpec.describe GitlabSchema.types['Issue'] do
end
end
end
describe 'hidden', :enable_admin_mode do
let_it_be(:admin) { create(:user, :admin)}
let_it_be(:banned_user) { create(:user, :banned) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:hidden_issue) { create(:issue, project: project, author: banned_user) }
let_it_be(:visible_issue) { create(:issue, project: project, author: user) }
let(:issue) { hidden_issue }
let(:query) do
%(
query {
project(fullPath: "#{project.full_path}") {
issue(iid: "#{issue.iid}") {
hidden
}
}
}
)
end
subject { GitlabSchema.execute(query, context: { current_user: admin }).as_json }
context 'when `ban_user_feature_flag` is enabled' do
context 'when issue is hidden' do
it 'returns `true`' do
expect(subject.dig('data', 'project', 'issue', 'hidden')).to eq(true)
end
end
context 'when issue is visible' do
let(:issue) { visible_issue }
it 'returns `false`' do
expect(subject.dig('data', 'project', 'issue', 'hidden')).to eq(false)
end
end
end
context 'when `ban_user_feature_flag` is disabled' do
before do
stub_feature_flags(ban_user_feature_flag: false)
end
it 'returns `nil`' do
expect(subject.dig('data', 'project', 'issue', 'hidden')).to be_nil
end
end
end
end
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