Skip to content

Commit 074d2bc

Browse files
committed
feat(secrets): load secrets in var group form
1 parent b9a002e commit 074d2bc

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

api/router.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ func serveFile(w http.ResponseWriter, r *http.Request, name string) {
588588
}
589589

590590
func getSystemInfo(w http.ResponseWriter, r *http.Request) {
591+
user := helpers.GetFromContext(r, "user").(*db.User)
591592

592593
var authMethods LoginAuthMethods
593594

@@ -605,7 +606,7 @@ func getSystemInfo(w http.ResponseWriter, r *http.Request) {
605606

606607
"auth_methods": authMethods,
607608

608-
"premium_features": proFeatures.GetFeatures(),
609+
"premium_features": proFeatures.GetFeatures(user),
609610

610611
"git_client": util.Config.GitClientId,
611612

pro/pkg/features/features.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package features
22

3-
func GetFeatures() map[string]bool {
3+
import "github.com/semaphoreui/semaphore/db"
4+
5+
func GetFeatures(user *db.User) map[string]bool {
46
return map[string]bool{
57
"project_runners": false,
68
"terraform_backend": false,

web/src/components/EnvironmentForm.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -607,17 +607,21 @@ export default {
607607
this.item.secrets = secrets;
608608
},
609609
610-
async beforeLoadData() {
611-
[
612-
this.secretStorages,
613-
] = await Promise.all([
614-
this.loadProjectResources('secret_storages'),
615-
]);
616-
},
617-
618-
afterLoadData() {
610+
async afterLoadData() {
619611
if (this.item) {
620-
return;
612+
this.secretStorages = [];
613+
614+
if (this.item.secret_storage_id) {
615+
this.secretStorages.push(
616+
await this.loadProjectResource('secret_storages', this.item.secret_storage_id),
617+
);
618+
}
619+
} else {
620+
[
621+
this.secretStorages,
622+
] = await Promise.all([
623+
this.loadProjectResources('secret_storages'),
624+
]);
621625
}
622626
623627
this.json = JSON.stringify(JSON.parse(this.item?.json || '{}'), null, 2);

web/src/views/project/Keys.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
:save-button-text="itemId === 'new' ? $t('create') : $t('save')"
66
:title="`${itemId === 'new' ? $t('nnew') : $t('edit')} Key`"
77
:max-width="450"
8-
position="top"
98
@save="loadItems()"
109
>
1110
<template v-slot:form="{ onSave, onError, needSave, needReset }">

0 commit comments

Comments
 (0)