summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-06-01 14:14:33 +0100
committerPhil Hughes <me@iamphill.com>2018-06-06 08:33:03 +0100
commit1d43689e5aa6bcd4f14bdff9e03540d3b3d8ca37 (patch)
tree613cfb63a88c3030e6b58b91963c17cca22bd88d /app/assets/javascripts
parent9827f3db10fc46d902f6670c183c09661ea5da07 (diff)
downloadgitlab-ce-1d43689e5aa6bcd4f14bdff9e03540d3b3d8ca37.tar.gz
reduced duplication of job details
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/ide/components/jobs/detail.vue75
-rw-r--r--app/assets/javascripts/ide/components/jobs/detail/description.vue47
-rw-r--r--app/assets/javascripts/ide/components/jobs/detail/scroll_button.vue61
-rw-r--r--app/assets/javascripts/ide/components/jobs/item.vue26
-rw-r--r--app/assets/javascripts/ide/stores/modules/pipelines/actions.js5
5 files changed, 134 insertions, 80 deletions
diff --git a/app/assets/javascripts/ide/components/jobs/detail.vue b/app/assets/javascripts/ide/components/jobs/detail.vue
index bacf08c5b5c..72daba5486b 100644
--- a/app/assets/javascripts/ide/components/jobs/detail.vue
+++ b/app/assets/javascripts/ide/components/jobs/detail.vue
@@ -1,9 +1,10 @@
<script>
import { mapActions, mapState } from 'vuex';
import _ from 'underscore';
-import CiIcon from '../../../vue_shared/components/ci_icon.vue';
import tooltip from '../../../vue_shared/directives/tooltip';
import Icon from '../../../vue_shared/components/icon.vue';
+import ScrollButton from './detail/scroll_button.vue';
+import JobDescription from './detail/description.vue';
const scrollPositions = {
top: 0,
@@ -15,8 +16,9 @@ export default {
tooltip,
},
components: {
- CiIcon,
Icon,
+ ScrollButton,
+ JobDescription,
},
data() {
return {
@@ -46,7 +48,7 @@ export default {
scrollUp() {
this.$refs.buildTrace.scrollTo(0, 0);
},
- scrollBuildLog: _.throttle(function scrollDebounce() {
+ scrollBuildLog: _.throttle(function buildLogScrollDebounce() {
const scrollTop = this.$refs.buildTrace.scrollTop;
const offsetHeight = this.$refs.buildTrace.offsetHeight;
const scrollHeight = this.$refs.buildTrace.scrollHeight;
@@ -80,28 +82,9 @@ export default {
</button>
</header>
<div class="top-bar d-flex">
- <div class="ide-job-details d-flex align-items-center">
- <ci-icon
- class="append-right-4 d-flex"
- :status="detailJob.status"
- :borderless="true"
- :size="24"
- />
- <span>
- {{ detailJob.name }}
- <a
- :href="detailJob.path"
- target="_blank"
- class="ide-external-link"
- >
- {{ jobId }}
- <icon
- name="external-link"
- :size="12"
- />
- </a>
- </span>
- </div>
+ <job-description
+ :job="detailJob"
+ />
<div class="controllers ml-auto">
<a
v-tooltip
@@ -117,38 +100,16 @@ export default {
class="fa fa-file-text-o"
></i>
</a>
- <div
- v-tooltip
- class="controllers-buttons"
- data-container="body"
- data-placement="top"
- :title="__('Scroll to top')"
- >
- <button
- class="btn-scroll btn-transparent btn-blank"
- type="button"
- :disabled="isScrolledToTop"
- @click="scrollUp"
- >
- <icon name="scroll_up" />
- </button>
- </div>
- <div
- v-tooltip
- class="controllers-buttons"
- data-container="body"
- data-placement="top"
- :title="__('Scroll to bottom')"
- >
- <button
- class="btn-scroll btn-transparent btn-blank"
- type="button"
- :disabled="isScrolledToBottom"
- @click="scrollDown"
- >
- <icon name="scroll_down" />
- </button>
- </div>
+ <scroll-button
+ direction="up"
+ :disabled="isScrolledToTop"
+ @click="scrollUp"
+ />
+ <scroll-button
+ direction="down"
+ :disabled="isScrolledToBottom"
+ @click="scrollDown"
+ />
</div>
</div>
<pre
diff --git a/app/assets/javascripts/ide/components/jobs/detail/description.vue b/app/assets/javascripts/ide/components/jobs/detail/description.vue
new file mode 100644
index 00000000000..def6bac3157
--- /dev/null
+++ b/app/assets/javascripts/ide/components/jobs/detail/description.vue
@@ -0,0 +1,47 @@
+<script>
+import Icon from '../../../../vue_shared/components/icon.vue';
+import CiIcon from '../../../../vue_shared/components/ci_icon.vue';
+
+export default {
+ components: {
+ Icon,
+ CiIcon,
+ },
+ props: {
+ job: {
+ type: Object,
+ required: true,
+ },
+ },
+ computed: {
+ jobId() {
+ return `#${this.job.id}`;
+ },
+ },
+};
+</script>
+
+<template>
+ <div class="d-flex align-items-center">
+ <ci-icon
+ class="d-flex"
+ :status="job.status"
+ :borderless="true"
+ :size="24"
+ />
+ <span class="prepend-left-8">
+ {{ job.name }}
+ <a
+ :href="job.path"
+ target="_blank"
+ class="ide-external-link"
+ >
+ {{ jobId }}
+ <icon
+ name="external-link"
+ :size="12"
+ />
+ </a>
+ </span>
+ </div>
+</template>
diff --git a/app/assets/javascripts/ide/components/jobs/detail/scroll_button.vue b/app/assets/javascripts/ide/components/jobs/detail/scroll_button.vue
new file mode 100644
index 00000000000..3ecb99c581b
--- /dev/null
+++ b/app/assets/javascripts/ide/components/jobs/detail/scroll_button.vue
@@ -0,0 +1,61 @@
+<script>
+import { __ } from '../../../../locale';
+import Icon from '../../../../vue_shared/components/icon.vue';
+import tooltip from '../../../../vue_shared/directives/tooltip';
+
+export default {
+ directives: {
+ tooltip,
+ },
+ components: {
+ Icon,
+ },
+ props: {
+ direction: {
+ type: String,
+ required: true,
+ validator(value) {
+ return ['up', 'down'].includes(value);
+ },
+ },
+ disabled: {
+ type: Boolean,
+ required: true,
+ },
+ },
+ computed: {
+ tooltipTitle() {
+ return this.direction === 'up' ? __('Scroll to top') : __('Scroll to bottom');
+ },
+ iconName() {
+ return `scroll_${this.direction}`;
+ },
+ },
+ methods: {
+ clickedScroll() {
+ this.$emit('click');
+ },
+ },
+};
+</script>
+
+<template>
+ <div
+ v-tooltip
+ class="controllers-buttons"
+ data-container="body"
+ data-placement="top"
+ :title="tooltipTitle"
+ >
+ <button
+ class="btn-scroll btn-transparent btn-blank"
+ type="button"
+ :disabled="disabled"
+ @click="clickedScroll"
+ >
+ <icon
+ :name="iconName"
+ />
+ </button>
+ </div>
+</template>
diff --git a/app/assets/javascripts/ide/components/jobs/item.vue b/app/assets/javascripts/ide/components/jobs/item.vue
index 597b65fa392..224e4d5158b 100644
--- a/app/assets/javascripts/ide/components/jobs/item.vue
+++ b/app/assets/javascripts/ide/components/jobs/item.vue
@@ -1,11 +1,9 @@
<script>
-import Icon from '../../../vue_shared/components/icon.vue';
-import CiIcon from '../../../vue_shared/components/ci_icon.vue';
+import JobDescription from './detail/description.vue';
export default {
components: {
- Icon,
- CiIcon,
+ JobDescription,
},
props: {
job: {
@@ -28,25 +26,9 @@ export default {
<template>
<div class="ide-job-item">
- <ci-icon
- :status="job.status"
- :borderless="true"
- :size="24"
+ <job-description
+ :job="job"
/>
- <span class="prepend-left-8">
- {{ job.name }}
- <a
- :href="job.path"
- target="_blank"
- class="ide-external-link"
- >
- {{ jobId }}
- <icon
- name="external-link"
- :size="12"
- />
- </a>
- </span>
<button
class="btn btn-default btn-sm ml-auto"
@click="clickViewLog"
diff --git a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js
index deb84212fc3..8116c835541 100644
--- a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js
+++ b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js
@@ -86,7 +86,10 @@ export const setDetailJob = ({ commit, dispatch }, job) => {
};
export const requestJobTrace = ({ commit }) => commit(types.REQUEST_JOB_TRACE);
-export const receiveJobTraceError = ({ commit }) => commit(types.RECEIVE_JOB_TRACE_ERROR);
+export const receiveJobTraceError = ({ commit }) => {
+ flash(__('Error fetching job trace'));
+ commit(types.RECEIVE_JOB_TRACE_ERROR);
+};
export const receiveJobTraceSuccess = ({ commit }, data) =>
commit(types.RECEIVE_JOB_TRACE_SUCCESS, data);