Commit cb0f024c authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'ce-7013-add-epics-close-support' into 'master'

CE port of Adding state to epics

See merge request gitlab-org/gitlab-ce!21771
parents b55f8aeb 398921b6
...@@ -293,6 +293,7 @@ ...@@ -293,6 +293,7 @@
:show-delete-button="showDeleteButton" :show-delete-button="showDeleteButton"
:can-attach-file="canAttachFile" :can-attach-file="canAttachFile"
:enable-autocomplete="enableAutocomplete" :enable-autocomplete="enableAutocomplete"
:issuable-type="issuableType"
/> />
<recaptcha-modal <recaptcha-modal
......
<script> <script>
import { __, sprintf } from '~/locale';
import updateMixin from '../mixins/update'; import updateMixin from '../mixins/update';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
const issuableTypes = {
issue: __('Issue'),
epic: __('Epic'),
};
export default { export default {
mixins: [updateMixin], mixins: [updateMixin],
props: { props: {
...@@ -18,6 +24,10 @@ ...@@ -18,6 +24,10 @@
required: false, required: false,
default: true, default: true,
}, },
issuableType: {
type: String,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -37,8 +47,11 @@ ...@@ -37,8 +47,11 @@
eventHub.$emit('close.form'); eventHub.$emit('close.form');
}, },
deleteIssuable() { deleteIssuable() {
const confirmMessage = sprintf(__('%{issuableType} will be removed! Are you sure?'), {
issuableType: issuableTypes[this.issuableType],
});
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
if (window.confirm('Issue will be removed! Are you sure?')) { if (window.confirm(confirmMessage)) {
this.deleteLoading = true; this.deleteLoading = true;
eventHub.$emit('delete.issuable'); eventHub.$emit('delete.issuable');
......
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
required: false, required: false,
default: () => [], default: () => [],
}, },
issuableType: {
type: String,
required: true,
},
markdownPreviewPath: { markdownPreviewPath: {
type: String, type: String,
required: true, required: true,
...@@ -110,6 +114,7 @@ ...@@ -110,6 +114,7 @@
:form-state="formState" :form-state="formState"
:can-destroy="canDestroy" :can-destroy="canDestroy"
:show-delete-button="showDeleteButton" :show-delete-button="showDeleteButton"
:issuable-type="issuableType"
/> />
</form> </form>
</template> </template>
...@@ -107,6 +107,9 @@ msgstr "" ...@@ -107,6 +107,9 @@ msgstr ""
msgid "%{group_docs_link_start}Groups%{group_docs_link_end} allow you to manage and collaborate across multiple projects. Members of a group have access to all of its projects." msgid "%{group_docs_link_start}Groups%{group_docs_link_end} allow you to manage and collaborate across multiple projects. Members of a group have access to all of its projects."
msgstr "" msgstr ""
msgid "%{issuableType} will be removed! Are you sure?"
msgstr ""
msgid "%{loadingIcon} Started" msgid "%{loadingIcon} Started"
msgstr "" msgstr ""
...@@ -2553,6 +2556,9 @@ msgstr "" ...@@ -2553,6 +2556,9 @@ msgstr ""
msgid "Environments|You don't have any environments right now." msgid "Environments|You don't have any environments right now."
msgstr "" msgstr ""
msgid "Epic"
msgstr ""
msgid "Error" msgid "Error"
msgstr "" msgstr ""
...@@ -3296,6 +3302,9 @@ msgstr "" ...@@ -3296,6 +3302,9 @@ msgstr ""
msgid "Invite" msgid "Invite"
msgstr "" msgstr ""
msgid "Issue"
msgstr ""
msgid "Issue Boards" msgid "Issue Boards"
msgstr "" msgstr ""
......
...@@ -21,6 +21,7 @@ describe('Edit Actions components', () => { ...@@ -21,6 +21,7 @@ describe('Edit Actions components', () => {
propsData: { propsData: {
canDestroy: true, canDestroy: true,
formState: store.formState, formState: store.formState,
issuableType: 'issue',
}, },
}).$mount(); }).$mount();
......
...@@ -15,6 +15,7 @@ describe('Inline edit form component', () => { ...@@ -15,6 +15,7 @@ describe('Inline edit form component', () => {
description: 'a', description: 'a',
lockedWarningVisible: false, lockedWarningVisible: false,
}, },
issuableType: 'issue',
markdownPreviewPath: '/', markdownPreviewPath: '/',
markdownDocsPath: '/', markdownDocsPath: '/',
projectPath: '/', projectPath: '/',
......
...@@ -84,15 +84,32 @@ describe Issue do ...@@ -84,15 +84,32 @@ describe Issue do
end end
end end
describe '#closed_at' do describe '#close' do
it 'sets closed_at to Time.now when issue is closed' do subject(:issue) { create(:issue, state: 'opened') }
issue = create(:issue, state: 'opened')
expect(issue.closed_at).to be_nil it 'sets closed_at to Time.now when an issue is closed' do
expect { issue.close }.to change { issue.closed_at }.from(nil)
end
issue.close it 'changes the state to closed' do
expect { issue.close }.to change { issue.state }.from('opened').to('closed')
end
end
describe '#reopen' do
let(:user) { create(:user) }
let(:issue) { create(:issue, state: 'closed', closed_at: Time.now, closed_by: user) }
it 'sets closed_at to nil when an issue is reopend' do
expect { issue.reopen }.to change { issue.closed_at }.to(nil)
end
it 'sets closed_by to nil when an issue is reopend' do
expect { issue.reopen }.to change { issue.closed_by }.from(user).to(nil)
end
expect(issue.closed_at).to be_present it 'changes the state to opened' do
expect { issue.reopen }.to change { issue.state }.from('closed').to('opened')
end end
end end
......
...@@ -3,6 +3,10 @@ module MigrationsHelpers ...@@ -3,6 +3,10 @@ module MigrationsHelpers
Class.new(ActiveRecord::Base) do Class.new(ActiveRecord::Base) do
self.table_name = name self.table_name = name
self.inheritance_column = :_type_disabled self.inheritance_column = :_type_disabled
def self.name
table_name.singularize.camelcase
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