-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathAdminSettings.vue
709 lines (697 loc) · 23.2 KB
/
AdminSettings.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
<template>
<div id="openproject_prefs" class="section">
<SettingsTitle />
<div class="openproject-server-host">
<FormHeading index="1"
:title="t('integration_openproject', 'OpenProject server')"
:is-complete="isServerHostFormComplete" />
<FieldValue v-if="isServerHostFormInView"
is-required
class="pb-1"
:title="t('integration_openproject', 'OpenProject host')"
:value="state.openproject_instance_url" />
<TextInput v-else
id="openproject-oauth-instance"
ref="openproject-oauth-instance-input"
v-model="serverHostUrlForEdit"
is-required
:read-only="isServerHostUrlReadOnly"
class="pb-1"
:label="t('integration_openproject', 'OpenProject host')"
place-holder="https://www.my-openproject.com"
:hint-text="t('integration_openproject', 'Please introduce your OpenProject host name')"
:error-message="serverHostErrorMessage"
:error-message-details="openProjectNotReachableErrorMessageDetails"
@click="isServerHostUrlReadOnly = false"
@input="isOpenProjectInstanceValid = null" />
<div class="form-actions">
<NcButton v-if="isServerHostFormInView"
data-test-id="reset-server-host-btn"
@click="setServerHostFormToEditMode">
<template #icon>
<PencilIcon :size="20" />
</template>
{{ t('integration_openproject', 'Edit server information') }}
</NcButton>
<NcButton v-if="isServerHostFormComplete && isServerHostFormInEdit"
class="mr-2"
data-test-id="cancel-edit-server-host-btn"
@click="setServerHostFormToViewMode">
{{ t('integration_openproject', 'Cancel') }}
</NcButton>
<NcButton v-if="isServerHostFormInEdit"
type="primary"
data-test-id="submit-server-host-form-btn"
:disabled="!serverHostUrlForEdit || serverHostUrlForEdit === state.openproject_instance_url"
@click="saveOpenProjectHostUrl">
<template #icon>
<LoadingIcon v-if="loadingServerHostForm" class="loading-spinner" :size="20" />
<CheckBoldIcon v-else :size="20" />
</template>
{{ t('integration_openproject', 'Save') }}
</NcButton>
</div>
</div>
<div class="openproject-oauth-values">
<FormHeading index="2"
:title="t('integration_openproject', 'OpenProject OAuth settings')"
:is-complete="isOPOAuthFormComplete"
:is-disabled="isOPOAuthFormInDisableMode" />
<div v-if="isServerHostFormComplete">
<FieldValue v-if="isOPOAuthFormInView"
is-required
:value="state.openproject_client_id"
title="OpenProject OAuth client ID" />
<TextInput v-else
id="openproject-oauth-client-id"
v-model="state.openproject_client_id"
class="py-1"
is-required
label="OpenProject OAuth client ID"
:hint-text="openProjectClientHint" />
<FieldValue v-if="isOPOAuthFormInView"
is-required
class="pb-1"
encrypt-value
title="OpenProject OAuth client secret"
:value="state.openproject_client_secret" />
<TextInput v-else
id="openproject-oauth-client-secret"
v-model="state.openproject_client_secret"
is-required
class="py-1"
label="OpenProject OAuth client secret"
:hint-text="openProjectClientHint" />
<div class="form-actions">
<NcButton v-if="isOPOAuthFormComplete && isOPOAuthFormInView"
data-test-id="reset-op-oauth-btn"
@click="resetOPOAuthClientValues">
<template #icon>
<AutoRenewIcon :size="20" />
</template>
{{ t('integration_openproject', 'Replace OpenProject OAuth values') }}
</NcButton>
<NcButton v-else
data-test-id="submit-op-oauth-btn"
type="primary"
:disabled="!state.openproject_client_id || !state.openproject_client_secret"
@click="saveOPOAuthClientValues">
<template #icon>
<LoadingIcon v-if="loadingOPOauthForm" class="loading-spinner" :size="20" />
<CheckBoldIcon v-else :size="20" />
</template>
{{ t('integration_openproject', 'Save') }}
</NcButton>
</div>
</div>
</div>
<div class="nextcloud-oauth-values">
<FormHeading index="3"
:title="t('integration_openproject', 'Nextcloud OAuth client')"
:is-complete="isNcOAuthFormComplete"
:is-disabled="isNcOAuthFormInDisableMode" />
<div v-if="state.nc_oauth_client">
<TextInput v-if="isNcOAuthFormInEdit"
id="nextcloud-oauth-client-id"
v-model="state.nc_oauth_client.nextcloud_client_id"
class="py-1"
read-only
is-required
with-copy-btn
label="Nextcloud OAuth client ID"
:hint-text="nextcloudClientHint" />
<FieldValue v-else
title="Nextcloud OAuth client ID"
:value="state.nc_oauth_client.nextcloud_client_id"
is-required />
<TextInput v-if="isNcOAuthFormInEdit"
id="nextcloud-oauth-client-secret"
v-model="state.nc_oauth_client.nextcloud_client_secret"
class="py-1"
read-only
is-required
with-copy-btn
label="Nextcloud OAuth client secret"
:hint-text="nextcloudClientHint" />
<FieldValue v-else
title="Nextcloud OAuth client secret"
is-required
encrypt-value
with-inspection
:value="ncClientSecret" />
<div class="form-actions">
<NcButton v-if="isNcOAuthFormInEdit"
type="primary"
:disabled="!ncClientId || !ncClientSecret"
data-test-id="submit-nc-oauth-values-form-btn"
@click="setNCOAuthFormToViewMode">
<template #icon>
<CheckBoldIcon :size="20" />
</template>
{{ t('integration_openproject', 'Yes, I have copied these values') }}
</NcButton>
<NcButton v-else
data-test-id="reset-nc-oauth-btn"
@click="resetNcOauthValues">
<template #icon>
<AutoRenewIcon :size="20" />
</template>
{{ t('integration_openproject', 'Replace Nextcloud OAuth values') }}
</NcButton>
</div>
</div>
</div>
<NcButton id="reset-all-app-settings-btn"
type="error"
:disabled="isResetButtonDisabled"
@click="resetAllAppValuesConfirmation">
<template #icon>
<RestoreIcon :size="20" />
</template>
{{ t('integration_openproject', 'Reset') }}
</NcButton>
<div v-if="isIntegrationComplete" class="default-prefs">
<h2>{{ t('integration_openproject', 'Default user settings') }}</h2>
<p>
{{ t('integration_openproject', 'A new user will receive these defaults and they will be applied to the integration app till the user changes them.') }}
</p>
<br>
<CheckBox v-model="state.default_enable_navigation"
input-id="default-prefs--link"
:label="t('integration_openproject', 'Enable navigation link')"
@input="setDefaultConfig" />
<CheckBox v-model="state.default_enable_unified_search"
input-id="default-prefs--u-search"
:label="t('integration_openproject', 'Enable unified search for tickets')"
@input="setDefaultConfig" />
</div>
</div>
</template>
<script>
import util from 'util'
import axios from '@nextcloud/axios'
import { loadState } from '@nextcloud/initial-state'
import { generateUrl } from '@nextcloud/router'
import { showSuccess, showError } from '@nextcloud/dialogs'
import '@nextcloud/dialogs/styles/toast.scss'
import CheckBoldIcon from 'vue-material-design-icons/CheckBold.vue'
import PencilIcon from 'vue-material-design-icons/Pencil.vue'
import LoadingIcon from 'vue-material-design-icons/Loading.vue'
import RestoreIcon from 'vue-material-design-icons/Restore.vue'
import AutoRenewIcon from 'vue-material-design-icons/Autorenew.vue'
import TextInput from './admin/TextInput.vue'
import FieldValue from './admin/FieldValue.vue'
import FormHeading from './admin/FormHeading.vue'
import CheckBox from '../components/settings/CheckBox.vue'
import SettingsTitle from '../components/settings/SettingsTitle.vue'
import { F_MODES } from '../utils.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
export default {
name: 'AdminSettings',
components: {
NcButton,
FieldValue,
FormHeading,
TextInput,
SettingsTitle,
CheckBoldIcon,
PencilIcon,
LoadingIcon,
AutoRenewIcon,
RestoreIcon,
CheckBox,
},
data() {
return {
formMode: {
// server host form is never disabled.
// it's either editable or view only
server: F_MODES.EDIT,
opOauth: F_MODES.DISABLE,
ncOauth: F_MODES.DISABLE,
},
isFormCompleted: {
server: false, opOauth: false, ncOauth: false,
},
loadingServerHostForm: false,
loadingOPOauthForm: false,
isOpenProjectInstanceValid: null,
openProjectNotReachableErrorMessage: null,
openProjectNotReachableErrorMessageDetails: null,
state: loadState('integration_openproject', 'admin-config'),
isAdminConfigOk: loadState('integration_openproject', 'admin-config-status'),
serverHostUrlForEdit: null,
isServerHostUrlReadOnly: true,
oPOAuthTokenRevokeStatus: null,
}
},
computed: {
ncClientId() {
return this.state.nc_oauth_client?.nextcloud_client_id
},
ncClientSecret() {
return this.state.nc_oauth_client?.nextcloud_client_secret
},
serverHostErrorMessage() {
if (
this.serverHostUrlForEdit === ''
|| this.isOpenProjectInstanceValid === null
|| this.isOpenProjectInstanceValid
) return null
return this.openProjectNotReachableErrorMessage
},
isServerHostFormComplete() {
return this.isFormCompleted.server
},
isOPOAuthFormComplete() {
return this.isFormCompleted.opOauth
},
isNcOAuthFormComplete() {
return this.isFormCompleted.ncOauth
},
isServerHostFormInView() {
return this.formMode.server === F_MODES.VIEW
},
isOPOAuthFormInView() {
return this.formMode.opOauth === F_MODES.VIEW
},
isServerHostFormInEdit() {
return this.formMode.server === F_MODES.EDIT
},
isNcOAuthFormInEdit() {
return this.formMode.ncOauth === F_MODES.EDIT
},
isOPOAuthFormInDisableMode() {
return this.formMode.opOauth === F_MODES.DISABLE
},
isNcOAuthFormInDisableMode() {
return this.formMode.ncOauth === F_MODES.DISABLE
},
adminFileStorageHref() {
let hostPart = ''
const urlPart = '%sadmin/settings/storages'
if (this.state?.openproject_instance_url.endsWith('/')) {
hostPart = this.state.openproject_instance_url
} else hostPart = this.state.openproject_instance_url + '/'
return util.format(urlPart, hostPart)
},
openProjectClientHint() {
const linkText = t('integration_openproject', 'Administration > File storages')
const htmlLink = `<a class="link" href="${this.adminFileStorageHref}" target="_blank" title="${linkText}">${linkText}</a>`
return t('integration_openproject', 'Go to your OpenProject {htmlLink} as an Administrator and start the setup and copy the values here.', { htmlLink }, null, { escape: false, sanitize: false })
},
nextcloudClientHint() {
const linkText = t('integration_openproject', 'Administration > File storages')
const htmlLink = `<a class="link" href="${this.adminFileStorageHref}" target="_blank" title="${linkText}">${linkText}</a>`
return t('integration_openproject', 'Copy the following values back into the OpenProject {htmlLink} as an Administrator.', { htmlLink }, null, { escape: false, sanitize: false })
},
isIntegrationComplete() {
return (this.isServerHostFormComplete
&& this.isOPOAuthFormComplete
&& this.isNcOAuthFormComplete)
},
isResetButtonDisabled() {
return !(this.state.openproject_client_id || this.state.openproject_client_secret || this.state.openproject_instance_url)
},
},
created() {
this.init()
},
methods: {
init() {
if (this.state) {
if (this.state.openproject_instance_url) {
this.formMode.server = F_MODES.VIEW
this.isFormCompleted.server = true
}
if (!!this.state.openproject_client_id && !!this.state.openproject_client_secret) {
this.formMode.opOauth = F_MODES.VIEW
this.isFormCompleted.opOauth = true
}
if (this.state.openproject_instance_url) {
if (!this.state.openproject_client_id || !this.state.openproject_client_secret) {
this.formMode.opOauth = F_MODES.EDIT
}
}
if (this.state.nc_oauth_client) {
this.formMode.ncOauth = F_MODES.VIEW
this.isFormCompleted.ncOauth = true
}
}
},
setServerHostFormToViewMode() {
this.formMode.server = F_MODES.VIEW
},
setServerHostFormToEditMode() {
this.formMode.server = F_MODES.EDIT
// set the edit variable to the current saved value
this.serverHostUrlForEdit = this.state.openproject_instance_url
this.isOpenProjectInstanceValid = null
},
setNCOAuthFormToViewMode() {
this.formMode.ncOauth = F_MODES.VIEW
this.isFormCompleted.ncOauth = true
},
async saveOpenProjectHostUrl() {
this.loadingServerHostForm = true
await this.validateOpenProjectInstance()
if (this.isOpenProjectInstanceValid) {
const saved = await this.saveOPOptions()
if (saved) {
this.state.openproject_instance_url = this.serverHostUrlForEdit
this.formMode.server = F_MODES.VIEW
this.isFormCompleted.server = true
if (!this.isFormCompleted.opOauth) {
this.formMode.opOauth = F_MODES.EDIT
}
}
}
this.loadingServerHostForm = false
},
async saveOPOAuthClientValues() {
await this.saveOPOptions()
if (this.isAdminConfigOk) {
this.formMode.opOauth = F_MODES.VIEW
this.isFormCompleted.opOauth = true
// if we do not have Nextcloud OAuth client yet, a new client is created
if (!this.state.nc_oauth_client) {
this.createNCOAuthClient()
}
}
},
resetOPOAuthClientValues() {
OC.dialogs.confirmDestructive(
t('integration_openproject', 'If you proceed you will need to update these settings with the new OpenProject OAuth credentials. Also, all users will need to reauthorize access to their OpenProject account.'),
t('integration_openproject', 'Replace OpenProject OAuth values'),
{
type: OC.dialogs.YES_NO_BUTTONS,
confirm: t('integration_openproject', 'Yes, replace'),
confirmClasses: 'error',
cancel: t('integration_openproject', 'Cancel'),
},
async (result) => {
if (result) {
await this.clearOPOAuthClientValues()
}
},
true
)
},
async clearOPOAuthClientValues() {
this.formMode.opOauth = F_MODES.EDIT
this.isFormCompleted.opOauth = false
this.state.openproject_client_id = null
this.state.openproject_client_secret = null
const saved = await this.saveOPOptions()
if (!saved) {
this.formMode.opOauth = F_MODES.VIEW
this.isFormCompleted.opOauth = true
}
},
resetAllAppValuesConfirmation() {
OC.dialogs.confirmDestructive(
t('integration_openproject', 'Are you sure that you want to reset this app and delete all settings and all connections of all Nextcloud users to OpenProject?'),
t('integration_openproject', 'Reset OpenProject integration'),
{
type: OC.dialogs.YES_NO_BUTTONS,
confirm: t('integration_openproject', 'Yes, reset'),
confirmClasses: 'error',
cancel: t('integration_openproject', 'Cancel'),
},
async (result) => {
if (result) {
await this.resetAllAppValues()
}
},
true
)
},
async resetAllAppValues() {
// to avoid general console errors, we need to set the form to
// editor mode so that we can update the form fields with null values
// also, form completeness should be set to false
this.formMode.opOauth = F_MODES.EDIT
this.isFormCompleted.opOauth = false
this.formMode.server = F_MODES.EDIT
this.isFormCompleted.server = false
this.state.openproject_client_id = null
this.state.openproject_client_secret = null
this.state.openproject_instance_url = null
this.state.default_enable_navigation = false
this.state.default_enable_unified_search = false
await this.saveOPOptions()
window.location.reload()
},
async validateOpenProjectInstance() {
const url = generateUrl('/apps/integration_openproject/is-valid-op-instance')
const response = await axios.post(url, { url: this.serverHostUrlForEdit })
this.openProjectNotReachableErrorMessageDetails = null
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'Please introduce a valid OpenProject host name'
)
if (response.data.result === true) {
this.isOpenProjectInstanceValid = true
this.state.openproject_instance_url = this.serverHostUrlForEdit
} else {
switch (response.data.result) {
case 'invalid':
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'URL is invalid',
)
this.openProjectNotReachableErrorMessageDetails = t(
'integration_openproject',
'The URL should have the form "https://openproject.org"'
)
break
case 'not_valid_body':
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'There is no valid OpenProject instance listening at that URL, please check the Nextcloud logs'
)
break
case 'client_exception': {
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'There is no valid OpenProject instance listening at that URL, please check the Nextcloud logs'
)
this.openProjectNotReachableErrorMessageDetails = t(
'integration_openproject',
'Response:'
) + ' "' + response.data.details + '"'
break
}
case 'server_exception': {
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'Server replied with an error message, please check the Nextcloud logs'
)
this.openProjectNotReachableErrorMessageDetails = response.data.details
break
}
case 'local_remote_servers_not_allowed': {
const linkText = t('integration_openproject', 'Documentation')
const htmlLink = `<a class="link" href="https://www.openproject.org/docs/system-admin-guide/integrations/nextcloud/" target="_blank" title="${linkText}">${linkText}</a>`
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'Accessing OpenProject servers with local addresses is not allowed.'
)
this.openProjectNotReachableErrorMessageDetails = t(
'integration_openproject',
'To be able to use an OpenProject server with a local address, enable the `allow_local_remote_servers` setting. {htmlLink}.',
{ htmlLink },
null,
{ escape: false, sanitize: false }
)
break
}
case 'redirected':
{
const location = response.data.details
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'The given URL redirects to \'{location}\'. Please do not use a URL that leads to a redirect.',
{ location }
)
break
}
case 'unexpected_error':
case 'network_error':
case 'request_exception':
default: {
this.openProjectNotReachableErrorMessage = t(
'integration_openproject',
'Could not connect to the given URL, please check the Nextcloud logs'
)
this.openProjectNotReachableErrorMessageDetails = response.data.details
break
}
}
this.isOpenProjectInstanceValid = false
await this.$nextTick()
await this.$refs['openproject-oauth-instance-input']?.$refs?.textInput?.focus()
}
},
async saveOPOptions() {
let success = false
const url = generateUrl('/apps/integration_openproject/admin-config')
const req = {
values: {
openproject_client_id: this.state.openproject_client_id,
openproject_client_secret: this.state.openproject_client_secret,
openproject_instance_url: this.state.openproject_instance_url,
default_enable_navigation: this.state.default_enable_navigation,
default_enable_unified_search: this.state.default_enable_unified_search,
},
}
try {
const response = await axios.put(url, req)
// after successfully saving the admin credentials, the admin config status needs to be updated
this.isAdminConfigOk = response?.data?.status === true
this.oPOAuthTokenRevokeStatus = response?.data?.oPOAuthTokenRevokeStatus
showSuccess(t('integration_openproject', 'OpenProject admin options saved'))
success = true
} catch (error) {
this.isAdminConfigOk = null
this.oPOAuthTokenRevokeStatus = null
console.error(error)
showError(
t('integration_openproject', 'Failed to save OpenProject admin options')
)
}
this.notifyAboutOPOAuthTokenRevoke()
return success
},
notifyAboutOPOAuthTokenRevoke() {
switch (this.oPOAuthTokenRevokeStatus) {
case 'connection_error':
showError(
t('integration_openproject', 'Failed to perform revoke request due to connection error with the OpenProject server')
)
break
case 'other_error':
showError(
t('integration_openproject', 'Failed to revoke some users\' OpenProject OAuth access tokens')
)
break
case 'success':
showSuccess(
t('integration_openproject', 'Successfully revoked users\' OpenProject OAuth access tokens')
)
break
default:
break
}
},
resetNcOauthValues() {
OC.dialogs.confirmDestructive(
t('integration_openproject', 'If you proceed you will need to update the settings in your OpenProject with the new Nextcloud OAuth credentials. Also, all users in OpenProject will need to reauthorize access to their Nextcloud account.'),
t('integration_openproject', 'Replace Nextcloud OAuth values'),
{
type: OC.dialogs.YES_NO_BUTTONS,
confirm: t('integration_openproject', 'Yes, replace'),
confirmClasses: 'error',
cancel: t('integration_openproject', 'Cancel'),
},
async (result) => {
if (result) {
this.state.nc_oauth_client = null
this.createNCOAuthClient()
}
},
true
)
},
createNCOAuthClient() {
const url = generateUrl('/apps/integration_openproject/nc-oauth')
axios.post(url).then((response) => {
this.state.nc_oauth_client = response.data
// generate part is complete but still the NC OAuth form is set to
// edit mode and not completed state so that copy buttons will be available for the user
this.formMode.ncOauth = F_MODES.EDIT
this.isFormCompleted.ncOauth = false
}).catch((error) => {
showError(
t('integration_openproject', 'Failed to create Nextcloud OAuth client')
+ ': ' + error.response.request.responseText
)
})
},
setDefaultConfig() {
const url = generateUrl('/apps/integration_openproject/admin-config')
const req = {
values: {
default_enable_navigation: !!this.state.default_enable_navigation,
default_enable_unified_search: !!this.state.default_enable_unified_search,
},
}
axios.put(url, req).then((res) => {
showSuccess(t('integration_openproject', 'Default user configuration saved'))
}).catch(error => {
showError(
t('integration_openproject', 'Failed to save default user configuration')
+ ': ' + error.response.request.responseText
)
})
},
},
}
</script>
<style scoped lang="scss">
@import '../../css/tab.css';
#reset-all-app-settings-btn {
position: absolute;
top: 30px;
right: 22px;
}
#openproject_prefs {
div {
width: 100%;
}
.d-flex {
display: flex;
align-items: center;
}
.pb-1 {
padding-bottom: .5rem;
}
.py-1 {
padding: .3rem 0;
}
.mr-2 {
margin-right: .5rem;
}
.default-prefs {
padding-top: 1.2rem;
}
}
</style>
<style lang="scss">
#openproject_prefs {
.button-vue {
height: 32px !important;
min-height: 32px !important;
&--vue-primary {
.button-vue__text {
color: #fff !important;
}
}
&--vue-error {
.button-vue__text {
color: #fff !important;
}
}
&__text {
font-weight: 400 !important;
font-size: 14px !important;
line-height: 20px !important;
}
}
.form-actions {
display: flex;
align-items: center;
padding: 15px 0;
}
}
</style>