debian-mirror-gitlab/app/assets/javascripts/ide/components/terminal/session.vue

56 lines
1.4 KiB
Vue
Raw Normal View History

2020-06-23 00:09:42 +05:30
<script>
2021-02-22 17:27:13 +05:30
import { GlButton } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions, mapState } from 'vuex';
2020-06-23 00:09:42 +05:30
import { __ } from '~/locale';
import { isEndingStatus } from '../../stores/modules/terminal/utils';
2021-03-11 19:13:27 +05:30
import Terminal from './terminal.vue';
2020-06-23 00:09:42 +05:30
export default {
components: {
Terminal,
2021-02-22 17:27:13 +05:30
GlButton,
2020-06-23 00:09:42 +05:30
},
computed: {
...mapState('terminal', ['session']),
actionButton() {
if (isEndingStatus(this.session.status)) {
return {
action: () => this.restartSession(),
2021-02-22 17:27:13 +05:30
variant: 'info',
category: 'primary',
2020-06-23 00:09:42 +05:30
text: __('Restart Terminal'),
};
}
return {
action: () => this.stopSession(),
2021-02-22 17:27:13 +05:30
variant: 'danger',
category: 'secondary',
2020-06-23 00:09:42 +05:30
text: __('Stop Terminal'),
};
},
},
methods: {
...mapActions('terminal', ['restartSession', 'stopSession']),
},
};
</script>
<template>
<div v-if="session" class="ide-terminal d-flex flex-column">
<header class="ide-job-header d-flex align-items-center">
<h5>{{ __('Web Terminal') }}</h5>
<div class="ml-auto align-self-center">
2021-02-22 17:27:13 +05:30
<gl-button
2020-06-23 00:09:42 +05:30
v-if="actionButton"
2021-02-22 17:27:13 +05:30
:variant="actionButton.variant"
:category="actionButton.category"
2020-06-23 00:09:42 +05:30
@click="actionButton.action"
2021-02-22 17:27:13 +05:30
>{{ actionButton.text }}</gl-button
2020-06-23 00:09:42 +05:30
>
</div>
</header>
<terminal :terminal-path="session.terminalPath" :status="session.status" />
</div>
</template>