debian-mirror-gitlab/app/assets/javascripts/environments/components/environment_pin.vue

46 lines
981 B
Vue
Raw Normal View History

2020-03-13 15:44:24 +05:30
<script>
/**
* Renders a prevent auto-stop button.
* Used in environments table.
*/
2021-11-18 22:05:49 +05:30
import { GlDropdownItem } from '@gitlab/ui';
2020-03-13 15:44:24 +05:30
import { __ } from '~/locale';
import eventHub from '../event_hub';
2022-04-04 11:22:00 +05:30
import cancelAutoStopMutation from '../graphql/mutations/cancel_auto_stop.mutation.graphql';
2020-03-13 15:44:24 +05:30
export default {
components: {
2021-11-18 22:05:49 +05:30
GlDropdownItem,
2020-03-13 15:44:24 +05:30
},
props: {
autoStopUrl: {
type: String,
required: true,
},
2022-04-04 11:22:00 +05:30
graphql: {
type: Boolean,
required: false,
default: false,
},
2020-03-13 15:44:24 +05:30
},
methods: {
onPinClick() {
2022-04-04 11:22:00 +05:30
if (this.graphql) {
this.$apollo.mutate({
mutation: cancelAutoStopMutation,
variables: { autoStopUrl: this.autoStopUrl },
});
} else {
eventHub.$emit('cancelAutoStop', this.autoStopUrl);
}
2020-03-13 15:44:24 +05:30
},
},
2021-11-18 22:05:49 +05:30
title: __('Prevent auto-stopping'),
2020-03-13 15:44:24 +05:30
};
</script>
<template>
2021-11-18 22:05:49 +05:30
<gl-dropdown-item @click="onPinClick">
{{ $options.title }}
</gl-dropdown-item>
2020-03-13 15:44:24 +05:30
</template>