Commit 61e7ce60 authored by Alexandru Croitor's avatar Alexandru Croitor

Show correct warning on issue when project is archived

When viewing an issue in an archived project show
corresponding warning message.
parent 262bcdd6
...@@ -12,6 +12,9 @@ export default { ...@@ -12,6 +12,9 @@ export default {
}, },
mixins: [Issuable, issuableStateMixin], mixins: [Issuable, issuableStateMixin],
computed: { computed: {
projectArchivedWarning() {
return __('This project is archived and cannot be commented on.');
},
lockedIssueWarning() { lockedIssueWarning() {
return sprintf( return sprintf(
__('This %{issuableDisplayName} is locked. Only project members can comment.'), __('This %{issuableDisplayName} is locked. Only project members can comment.'),
...@@ -26,9 +29,15 @@ export default { ...@@ -26,9 +29,15 @@ export default {
<div class="disabled-comment text-center"> <div class="disabled-comment text-center">
<span class="issuable-note-warning inline"> <span class="issuable-note-warning inline">
<icon :size="16" name="lock" class="icon" /> <icon :size="16" name="lock" class="icon" />
<span> <span v-if="isProjectArchived">
{{ lockedIssueWarning }} {{ projectArchivedWarning }}
<gl-link :href="archivedProjectDocsPath" target="_blank" class="learn-more">
{{ __('Learn more') }}
</gl-link>
</span>
<span v-else>
{{ lockedIssueWarning }}
<gl-link :href="lockedIssueDocsPath" target="_blank" class="learn-more"> <gl-link :href="lockedIssueDocsPath" target="_blank" class="learn-more">
{{ __('Learn more') }} {{ __('Learn more') }}
</gl-link> </gl-link>
......
...@@ -3,6 +3,12 @@ import { mapGetters } from 'vuex'; ...@@ -3,6 +3,12 @@ import { mapGetters } from 'vuex';
export default { export default {
computed: { computed: {
...mapGetters(['getNoteableDataByProp']), ...mapGetters(['getNoteableDataByProp']),
isProjectArchived() {
return this.getNoteableDataByProp('is_project_archived');
},
archivedProjectDocsPath() {
return this.getNoteableDataByProp('archived_project_docs_path');
},
lockedIssueDocsPath() { lockedIssueDocsPath() {
return this.getNoteableDataByProp('locked_discussion_docs_path'); return this.getNoteableDataByProp('locked_discussion_docs_path');
}, },
......
...@@ -64,4 +64,12 @@ class IssueEntity < IssuableEntity ...@@ -64,4 +64,12 @@ class IssueEntity < IssuableEntity
expose :locked_discussion_docs_path, if: -> (issue) { issue.discussion_locked? } do |issue| expose :locked_discussion_docs_path, if: -> (issue) { issue.discussion_locked? } do |issue|
help_page_path('user/discussions/index.md', anchor: 'lock-discussions') help_page_path('user/discussions/index.md', anchor: 'lock-discussions')
end end
expose :is_project_archived do |issue|
issue.project.archived?
end
expose :archived_project_docs_path, if: -> (issue) { issue.project.archived? } do |issue|
help_page_path('user/project/settings/index.md', anchor: 'archiving-a-project')
end
end end
...@@ -42,6 +42,18 @@ class MergeRequestNoteableEntity < IssuableEntity ...@@ -42,6 +42,18 @@ class MergeRequestNoteableEntity < IssuableEntity
end end
end end
expose :locked_discussion_docs_path, if: -> (merge_request) { merge_request.discussion_locked? } do |merge_request|
help_page_path('user/discussions/index.md', anchor: 'lock-discussions')
end
expose :is_project_archived do |merge_request|
merge_request.project.archived?
end
expose :archived_project_docs_path, if: -> (merge_request) { merge_request.project.archived? } do |merge_request|
help_page_path('user/project/settings/index.md', anchor: 'archiving-a-project')
end
private private
delegate :current_user, to: :request delegate :current_user, to: :request
......
---
title: Show correct warning on issue when project is archived
merge_request: 20078
author:
type: fixed
...@@ -18256,6 +18256,9 @@ msgstr "" ...@@ -18256,6 +18256,9 @@ msgstr ""
msgid "This project does not have billing enabled. To create a cluster, <a href=%{linkToBilling} target=\"_blank\" rel=\"noopener noreferrer\">enable billing <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a> and try again." msgid "This project does not have billing enabled. To create a cluster, <a href=%{linkToBilling} target=\"_blank\" rel=\"noopener noreferrer\">enable billing <i class=\"fa fa-external-link\" aria-hidden=\"true\"></i></a> and try again."
msgstr "" msgstr ""
msgid "This project is archived and cannot be commented on."
msgstr ""
msgid "This project path either does not exist or is private." msgid "This project path either does not exist or is private."
msgstr "" msgstr ""
......
{ {
"type": "object", "type": "object",
"properties" : { "required": ["id", "iid", "title", "description", "merge_params", "state", "source_branch", "target_branch",
"diff_head_sha", "create_note_path", "preview_note_path", "can_receive_suggestion", "create_issue_to_resolve_discussions_path",
"new_blob_path", "current_user", "is_project_archived"],
"properties": {
"id": { "type": "integer" }, "id": { "type": "integer" },
"iid": { "type": "integer" }, "iid": { "type": "integer" },
"title": { "type": "string" }, "title": { "type": "string" },
...@@ -26,7 +29,10 @@ ...@@ -26,7 +29,10 @@
"can_update": { "type": "boolean" } "can_update": { "type": "boolean" }
}, },
"additionalProperties": false "additionalProperties": false
} },
"is_project_archived": { "type": "boolean" },
"locked_discussion_docs_path": { "type": "string" },
"archived_project_docs_path": { "type": "string" }
}, },
"additionalProperties": false "additionalProperties": false
} }
...@@ -92,4 +92,36 @@ describe IssueEntity do ...@@ -92,4 +92,36 @@ describe IssueEntity do
end end
end end
end end
context 'when issuable in active or archived project' do
before do
project.add_developer(user)
end
context 'when project is active' do
it 'returns archived false' do
expect(subject[:is_project_archived]).to eq(false)
end
it 'returns nil for archived project doc' do
response = described_class.new(resource, request: request).as_json
expect(response[:archived_project_docs_path]).to be nil
end
end
context 'when project is archived' do
before do
project.update(archived: true)
end
it 'returns archived true' do
expect(subject[:is_project_archived]).to eq(true)
end
it 'returns archived project doc' do
expect(subject[:archived_project_docs_path]).to eq('/help/user/project/settings/index.md#archiving-a-project')
end
end
end
end end
...@@ -48,7 +48,24 @@ describe MergeRequestSerializer do ...@@ -48,7 +48,24 @@ describe MergeRequestSerializer do
let(:serializer) { 'noteable' } let(:serializer) { 'noteable' }
it 'matches noteable merge request json schema' do it 'matches noteable merge request json schema' do
expect(json_entity).to match_schema('entities/merge_request_noteable', strict: true) expect(json_entity).to match_schema('entities/merge_request_noteable')
end
context 'when merge_request is locked' do
let(:resource) { create(:merge_request, :locked, description: "Description") }
it 'matches noteable merge request json schema' do
expect(json_entity).to match_schema('entities/merge_request_noteable')
end
end
context 'when project is archived' do
let(:project) { create(:project, :archived, :repository) }
let(:resource) { create(:merge_request, source_project: project, target_project: project, description: "Description") }
it 'matches noteable merge request json schema' do
expect(json_entity).to match_schema('entities/merge_request_noteable')
end
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