-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
/
Copy pathProjectConfigurationDetails.vue
197 lines (172 loc) · 4.2 KB
/
ProjectConfigurationDetails.vue
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<template>
<div class="project-configuration-details">
<template v-if="configuration">
<div v-if="configuration.tabs.length > 1" class="tabs">
<VueGroup
v-model="currentTab"
class="tabs-selector"
>
<VueGroupButton
v-for="tab of configuration.tabs"
:key="tab.id"
:value="tab.id"
:icon-left="tab.icon"
:label="$t(tab.label)"
/>
</VueGroup>
</div>
<div class="content">
<ConfigurationTab
v-for="tab of configuration.tabs"
v-show="tab.id === currentTab"
:key="tab.id"
:configuration="configuration"
:tab="tab"
@has-changes="value => tabsHaveChanges[tab.id] = value"
/>
</div>
</template>
<VueLoadingIndicator
v-else
class="loading"
/>
<div class="actions-bar">
<VueButton
v-if="configuration && configuration.link"
icon-right="open_in_new"
class="big flat success"
:label="$t('org.vue.views.project-configuration-details.actions.more-info')"
:href="configuration.link"
target="_blank"
/>
<div class="vue-ui-spacer"/>
<VueButton
:disabled="!hasPromptsChanged"
icon-left="cancel"
class="big"
:label="$t('org.vue.views.project-configuration-details.actions.cancel')"
@click="cancel()"
/>
<VueButton
v-if="configuration && !hasPromptsChanged"
icon-left="refresh"
class="big primary"
:label="$t('org.vue.views.project-configuration-details.actions.refresh')"
@click="refetch()"
/>
<VueButton
v-else
icon-left="save"
class="primary big"
:label="$t('org.vue.views.project-configuration-details.actions.save')"
@click="save()"
/>
</div>
</div>
</template>
<script>
import CONFIGURATION from '@/graphql/configuration/configuration.gql'
import CONFIGURATION_SAVE from '@/graphql/configuration/configurationSave.gql'
import CONFIGURATION_CANCEL from '@/graphql/configuration/configurationCancel.gql'
export default {
metaInfo () {
return {
title: this.configuration && `${this.configuration.name} - ${this.$t('org.vue.views.project-configurations.title')}`
}
},
props: {
id: {
type: String,
required: true
}
},
data () {
return {
configuration: null,
currentTab: '__default',
tabsHaveChanges: {}
}
},
apollo: {
configuration: {
query: CONFIGURATION,
variables () {
return {
id: this.id
}
},
async result ({ data, loading }) {
if (!this.$_init && !loading && data && data.configuration) {
this.$_init = true
this.tabsHaveChanges = data.configuration.tabs.reduce((obj, tab) => {
obj[tab.id] = false
return obj
}, {})
await this.$nextTick()
this.currentTab = data.configuration.tabs[0].id
}
}
}
},
computed: {
hasPromptsChanged () {
for (const key in this.tabsHaveChanges) {
if (this.tabsHaveChanges[key]) return true
}
return false
}
},
watch: {
id: 'init'
},
created () {
this.init()
},
methods: {
init (tab) {
this.currentTab = '__default'
this.configuration = null
this.$_init = false
},
async cancel () {
await this.$apollo.mutate({
mutation: CONFIGURATION_CANCEL,
variables: {
id: this.id
}
})
this.refetch()
},
async save () {
await this.$apollo.mutate({
mutation: CONFIGURATION_SAVE,
variables: {
id: this.id
}
})
this.refetch()
},
refetch () {
this.$apollo.queries.configuration.refetch()
}
}
}
</script>
<style lang="stylus" scoped>
.project-configuration-details
v-box()
align-items stretch
height 100%
background $vue-ui-color-light
.vue-ui-dark-mode &
background $vue-ui-color-darker
.content,
.loading
flex 100% 1 1
height 0
.content
overflow-x hidden
overflow-y auto
.tabs
margin $padding-item 0
</style>