Commit bd245291 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'mr-widget-vue' into 'master'

Move archived component to vue file

See merge request gitlab-org/gitlab-ce!16561
parents e4952f17 bf1b26ea
import statusIcon from '../mr_widget_status_icon';
export default {
name: 'MRWidgetArchived',
components: {
statusIcon,
},
template: `
<div class="mr-widget-body media">
<div class="space-children">
<status-icon status="failed" />
<button
type="button"
class="btn btn-success btn-sm"
disabled="true">
Merge
</button>
</div>
<div class="media-body">
<span class="bold">
This project is archived, write access has been disabled
</span>
</div>
</div>
`,
};
<script>
import statusIcon from '../mr_widget_status_icon';
export default {
name: 'MRWidgetArchived',
components: {
statusIcon,
},
};
</script>
<template>
<div class="mr-widget-body media">
<div class="space-children">
<status-icon
status="warning"
/>
<button
type="button"
class="btn btn-success btn-sm"
disabled="true"
>
{{ s__("mrWidget|Merge") }}
</button>
</div>
<div class="media-body">
<span class="bold">
{{ s__("mrWidget|This project is archived, write access has been disabled") }}
</span>
</div>
</div>
</template>
...@@ -21,7 +21,7 @@ export { default as FailedToMerge } from './components/states/mr_widget_failed_t ...@@ -21,7 +21,7 @@ export { default as FailedToMerge } from './components/states/mr_widget_failed_t
export { default as ClosedState } from './components/states/mr_widget_closed'; export { default as ClosedState } from './components/states/mr_widget_closed';
export { default as MergingState } from './components/states/mr_widget_merging'; export { default as MergingState } from './components/states/mr_widget_merging';
export { default as WipState } from './components/states/mr_widget_wip'; export { default as WipState } from './components/states/mr_widget_wip';
export { default as ArchivedState } from './components/states/mr_widget_archived'; export { default as ArchivedState } from './components/states/mr_widget_archived.vue';
export { default as ConflictsState } from './components/states/mr_widget_conflicts'; export { default as ConflictsState } from './components/states/mr_widget_conflicts';
export { default as NothingToMergeState } from './components/states/mr_widget_nothing_to_merge'; export { default as NothingToMergeState } from './components/states/mr_widget_nothing_to_merge';
export { default as MissingBranchState } from './components/states/mr_widget_missing_branch'; export { default as MissingBranchState } from './components/states/mr_widget_missing_branch';
......
...@@ -2,6 +2,9 @@ import { ...@@ -2,6 +2,9 @@ import {
Vue, Vue,
mrWidgetOptions, mrWidgetOptions,
} from './dependencies'; } from './dependencies';
import Translate from '../vue_shared/translate';
Vue.use(Translate);
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
gl.mrWidgetData.gitlabLogo = gon.gitlab_logo; gl.mrWidgetData.gitlabLogo = gon.gitlab_logo;
......
import Vue from 'vue'; import Vue from 'vue';
import archivedComponent from '~/vue_merge_request_widget/components/states/mr_widget_archived'; import archivedComponent from '~/vue_merge_request_widget/components/states/mr_widget_archived.vue';
import mountComponent from '../../../helpers/vue_mount_component_helper';
describe('MRWidgetArchived', () => { describe('MRWidgetArchived', () => {
describe('template', () => { let vm;
it('should have correct elements', () => {
beforeEach(() => {
const Component = Vue.extend(archivedComponent); const Component = Vue.extend(archivedComponent);
const el = new Component({ vm = mountComponent(Component);
el: document.createElement('div'), });
}).$el;
afterEach(() => {
vm.$destroy();
});
expect(el.classList.contains('mr-widget-body')).toBeTruthy(); it('renders a ci status failed icon', () => {
expect(el.querySelector('button').classList.contains('btn-success')).toBeTruthy(); expect(vm.$el.querySelector('.ci-status-icon')).not.toBeNull();
expect(el.querySelector('button').disabled).toBeTruthy();
expect(el.innerText).toContain('This project is archived, write access has been disabled');
}); });
it('renders a disabled button', () => {
expect(vm.$el.querySelector('button').getAttribute('disabled')).toEqual('disabled');
expect(vm.$el.querySelector('button').textContent.trim()).toEqual('Merge');
});
it('renders information', () => {
expect(
vm.$el.querySelector('.bold').textContent.trim(),
).toEqual('This project is archived, write access has been disabled');
}); });
}); });
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