1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<script>
import { mapActions, mapState } from 'vuex';
import { GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
import { isEndingStatus } from '../../stores/modules/terminal/utils';
import Terminal from './terminal.vue';
export default {
components: {
Terminal,
GlButton,
},
computed: {
...mapState('terminal', ['session']),
actionButton() {
if (isEndingStatus(this.session.status)) {
return {
action: () => this.restartSession(),
variant: 'info',
category: 'primary',
text: __('Restart Terminal'),
};
}
return {
action: () => this.stopSession(),
variant: 'danger',
category: 'secondary',
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">
<gl-button
v-if="actionButton"
:variant="actionButton.variant"
:category="actionButton.category"
@click="actionButton.action"
>{{ actionButton.text }}</gl-button
>
</div>
</header>
<terminal :terminal-path="session.terminalPath" :status="session.status" />
</div>
</template>
|