Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-04-20 14:48:54 +0300
committerPhil Hughes <me@iamphill.com>2017-04-20 14:48:54 +0300
commitd4021122c51d61251ec774fb449c2f15e94b04d6 (patch)
treed6c85d9677df77350d191d9f8e197e82d56ab941 /app/assets/javascripts/environments/components/environment_rollback.vue
parent9c59667fc422d1ceb22f804609f6d9873e1ad651 (diff)
Refactor into .vue files
Diffstat (limited to 'app/assets/javascripts/environments/components/environment_rollback.vue')
-rw-r--r--app/assets/javascripts/environments/components/environment_rollback.vue74
1 files changed, 74 insertions, 0 deletions
diff --git a/app/assets/javascripts/environments/components/environment_rollback.vue b/app/assets/javascripts/environments/components/environment_rollback.vue
new file mode 100644
index 00000000000..f139f24036f
--- /dev/null
+++ b/app/assets/javascripts/environments/components/environment_rollback.vue
@@ -0,0 +1,74 @@
+<script>
+/* global Flash */
+/* eslint-disable no-new */
+/**
+ * Renders Rollback or Re deploy button in environments table depending
+ * of the provided property `isLastDeployment`.
+ *
+ * Makes a post request when the button is clicked.
+ */
+import eventHub from '../event_hub';
+
+export default {
+ props: {
+ retryUrl: {
+ type: String,
+ default: '',
+ },
+
+ isLastDeployment: {
+ type: Boolean,
+ default: true,
+ },
+
+ service: {
+ type: Object,
+ required: true,
+ },
+ },
+
+ data() {
+ return {
+ isLoading: false,
+ };
+ },
+
+ methods: {
+ onClick() {
+ this.isLoading = true;
+
+ $(this.$el).tooltip('destroy');
+
+ this.service.postAction(this.retryUrl)
+ .then(() => {
+ this.isLoading = false;
+ eventHub.$emit('refreshEnvironments');
+ })
+ .catch(() => {
+ this.isLoading = false;
+ new Flash('An error occured while making the request.');
+ });
+ },
+ },
+};
+</script>
+<template>
+ <button
+ type="button"
+ class="btn"
+ @click="onClick"
+ :disabled="isLoading">
+
+ <span v-if="isLastDeployment">
+ Re-deploy
+ </span>
+ <span v-else>
+ Rollback
+ </span>
+
+ <i
+ v-if="isLoading"
+ class="fa fa-spinner fa-spin"
+ aria-hidden="true" />
+ </button>
+</template>