2019-04-02 16:08:03 +00:00
|
|
|
<template>
|
2019-05-21 12:55:43 +00:00
|
|
|
<div v-if="projectGroup">
|
2019-05-21 10:13:21 +00:00
|
|
|
<div class="panel">
|
|
|
|
|
<p class="panel-title">Project Group Settings</p>
|
|
|
|
|
<div class="p-4">
|
|
|
|
|
<div v-if="!isRootProjectGroup" class="mb-4">
|
|
|
|
|
<label class="block font-bold mb-2">Project Group Name</label>
|
2019-05-14 16:05:17 +00:00
|
|
|
<div class="control">
|
2019-05-21 10:13:21 +00:00
|
|
|
<input
|
|
|
|
|
class="appearance-none border rounded py-2 px-3 leading-tight focus:outline-none focus:shadow-outline"
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="Project Group Name"
|
|
|
|
|
v-model="projectGroup.name"
|
2019-07-09 12:20:03 +00:00
|
|
|
/>
|
2019-05-14 16:05:17 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
<div class="mb-4">
|
|
|
|
|
<label class="checkbox">
|
2019-07-09 12:20:03 +00:00
|
|
|
<input type="checkbox" v-model="projectGroupIsPrivate" />
|
2019-05-21 10:13:21 +00:00
|
|
|
Private
|
|
|
|
|
</label>
|
2019-05-14 16:05:17 +00:00
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
<button class="btn btn-blue" @click="updateProjectGroup()">Update</button>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
v-if="updateProjectGroupError"
|
|
|
|
|
class="mb-10 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
|
|
|
|
|
role="alert"
|
|
|
|
|
>
|
|
|
|
|
<span class="block sm:inline">{{ updateProjectGroupError }}</span>
|
2019-05-14 16:05:17 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
</div>
|
|
|
|
|
|
2019-07-09 12:20:03 +00:00
|
|
|
<div class="panel">
|
|
|
|
|
<p class="panel-title">Secrets</p>
|
|
|
|
|
<div class="p-4">
|
|
|
|
|
<projectsecrets :secrets="secrets" :allsecrets="allsecrets" type="projectgroup" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2019-05-21 10:13:21 +00:00
|
|
|
<div class="panel">
|
|
|
|
|
<p class="panel-title">Variables</p>
|
|
|
|
|
<div class="p-4">
|
2019-07-09 12:20:03 +00:00
|
|
|
<projectvars :variables="variables" :allvariables="allvariables" type="projectgroup" />
|
2019-05-13 15:03:27 +00:00
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="!isRootProjectGroup" class="panel">
|
|
|
|
|
<p class="panel-title">Danger Zone</p>
|
|
|
|
|
<div class="p-4">
|
|
|
|
|
<h4 class="mb-4 title text-xl">Delete This Project Group</h4>
|
|
|
|
|
<div
|
|
|
|
|
class="mb-4 bg-red-100 border-l-4 border-red-500 text-red-700 p-4 rounded"
|
|
|
|
|
role="alert"
|
|
|
|
|
>
|
|
|
|
|
<p>
|
|
|
|
|
This operation
|
|
|
|
|
<strong>CANNOT</strong> be undone.
|
|
|
|
|
This operation will remove
|
|
|
|
|
<strong>{{projectGroupPath}}</strong>
|
|
|
|
|
</p>
|
2019-05-11 13:12:10 +00:00
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
<label class="block mb-2">
|
|
|
|
|
Please type the project group name for confirmation:
|
|
|
|
|
<span
|
|
|
|
|
class="text-red-500 font-bold"
|
|
|
|
|
>{{ projectGroupName }}</span>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="mb-4">
|
|
|
|
|
<input
|
|
|
|
|
class="appearance-none border rounded py-2 px-3 leading-tight focus:outline-none focus:shadow-outline"
|
|
|
|
|
v-model="projectGroupNameToDelete"
|
|
|
|
|
type="email"
|
|
|
|
|
placeholder="Project Group name to delete"
|
2019-07-09 12:20:03 +00:00
|
|
|
/>
|
2019-05-13 14:29:47 +00:00
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
<button
|
|
|
|
|
class="btn btn-red"
|
|
|
|
|
@click="deleteProjectGroup()"
|
|
|
|
|
:disabled="!deleteButtonEnabled"
|
|
|
|
|
>Delete Project Group</button>
|
2019-05-11 13:12:10 +00:00
|
|
|
</div>
|
2019-05-21 10:13:21 +00:00
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
v-if="deleteProjectGroupError"
|
|
|
|
|
class="mb-10 bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative"
|
|
|
|
|
role="alert"
|
|
|
|
|
>
|
|
|
|
|
<span class="block sm:inline">{{ deleteProjectGroupError }}</span>
|
|
|
|
|
</div>
|
2019-04-02 16:08:03 +00:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-05-14 16:05:17 +00:00
|
|
|
import {
|
|
|
|
|
fetchProjectGroup,
|
2019-07-09 12:20:03 +00:00
|
|
|
fetchSecrets,
|
2019-05-14 16:05:17 +00:00
|
|
|
fetchVariables,
|
|
|
|
|
updateProjectGroup,
|
|
|
|
|
deleteProjectGroup
|
|
|
|
|
} from "@/util/data.js";
|
2019-05-11 13:12:10 +00:00
|
|
|
|
|
|
|
|
import { projectGroupLink } from "@/util/link.js";
|
2019-04-02 16:08:03 +00:00
|
|
|
|
2019-07-09 12:20:03 +00:00
|
|
|
import projectsecrets from "@/components/projectsecrets";
|
2019-04-02 16:08:03 +00:00
|
|
|
import projectvars from "@/components/projectvars";
|
|
|
|
|
|
|
|
|
|
export default {
|
2019-07-09 12:20:03 +00:00
|
|
|
components: { projectsecrets, projectvars },
|
2019-04-02 16:08:03 +00:00
|
|
|
name: "projectgroupsettings",
|
|
|
|
|
props: {
|
|
|
|
|
ownertype: String,
|
|
|
|
|
ownername: String,
|
|
|
|
|
projectgroupref: Array
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2019-05-14 16:05:17 +00:00
|
|
|
updateProjectGroupError: null,
|
2019-05-13 14:29:47 +00:00
|
|
|
deleteProjectGroupError: null,
|
2019-05-14 16:05:17 +00:00
|
|
|
projectGroup: null,
|
|
|
|
|
projectGroupIsPrivate: false,
|
2019-07-09 12:20:03 +00:00
|
|
|
secrets: [],
|
|
|
|
|
allsecrets: [],
|
2019-04-02 16:08:03 +00:00
|
|
|
variables: [],
|
2019-05-11 13:12:10 +00:00
|
|
|
allvariables: [],
|
|
|
|
|
projectGroupNameToDelete: ""
|
2019-04-02 16:08:03 +00:00
|
|
|
};
|
|
|
|
|
},
|
2019-05-11 13:12:10 +00:00
|
|
|
computed: {
|
|
|
|
|
projectGroupName: function() {
|
|
|
|
|
return this.projectgroupref[this.projectgroupref.length - 1];
|
|
|
|
|
},
|
|
|
|
|
projectGroupPath: function() {
|
|
|
|
|
return ["", this.ownertype, this.ownername, ...this.projectgroupref].join(
|
|
|
|
|
"/"
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
deleteButtonEnabled: function() {
|
|
|
|
|
return this.projectGroupNameToDelete == this.projectGroupName;
|
2019-05-14 13:47:35 +00:00
|
|
|
},
|
|
|
|
|
isRootProjectGroup() {
|
|
|
|
|
return this.projectgroupref.length == 0;
|
2019-05-11 13:12:10 +00:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2019-05-13 14:29:47 +00:00
|
|
|
resetErrors() {
|
2019-05-14 16:05:17 +00:00
|
|
|
this.updateProjectGroupError = null;
|
2019-05-13 14:29:47 +00:00
|
|
|
this.deleteProjectGroupError = null;
|
|
|
|
|
},
|
2019-05-14 16:05:17 +00:00
|
|
|
async updateProjectGroup() {
|
|
|
|
|
this.resetErrors();
|
|
|
|
|
|
|
|
|
|
let projectgroupref = [
|
|
|
|
|
this.ownertype,
|
|
|
|
|
this.ownername,
|
|
|
|
|
...this.projectgroupref
|
|
|
|
|
].join("/");
|
|
|
|
|
|
|
|
|
|
let visibility = "public";
|
|
|
|
|
if (this.projectGroupIsPrivate) {
|
|
|
|
|
visibility = "private";
|
|
|
|
|
}
|
|
|
|
|
let { error } = await updateProjectGroup(
|
|
|
|
|
projectgroupref,
|
|
|
|
|
this.projectGroup.name,
|
|
|
|
|
visibility
|
|
|
|
|
);
|
|
|
|
|
if (error) {
|
|
|
|
|
this.updateProjectGroupError = error;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-05-11 13:12:10 +00:00
|
|
|
async deleteProjectGroup() {
|
|
|
|
|
let projectgroupref = [
|
|
|
|
|
this.ownertype,
|
|
|
|
|
this.ownername,
|
|
|
|
|
...this.projectgroupref
|
|
|
|
|
].join("/");
|
|
|
|
|
|
|
|
|
|
if (this.projectGroupNameToDelete == this.projectGroupName) {
|
2019-05-13 14:29:47 +00:00
|
|
|
let { error } = await deleteProjectGroup(projectgroupref);
|
|
|
|
|
if (error) {
|
|
|
|
|
this.deleteProjectGroupError = error;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-05-11 13:12:10 +00:00
|
|
|
this.$router.push(
|
|
|
|
|
projectGroupLink(
|
|
|
|
|
this.ownertype,
|
|
|
|
|
this.ownername,
|
|
|
|
|
this.projectgroupref.slice(0, -1)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-04-02 16:08:03 +00:00
|
|
|
created: async function() {
|
2019-05-13 14:29:47 +00:00
|
|
|
let projectgroupref = [
|
|
|
|
|
this.ownertype,
|
|
|
|
|
this.ownername,
|
|
|
|
|
...this.projectgroupref
|
|
|
|
|
].join("/");
|
|
|
|
|
|
2019-05-14 16:05:17 +00:00
|
|
|
let { data, error } = await fetchProjectGroup(projectgroupref);
|
|
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.projectGroup = data;
|
|
|
|
|
this.projectGroupIsPrivate = this.projectGroup.visibility == "private";
|
|
|
|
|
|
2019-07-09 12:20:03 +00:00
|
|
|
({ data, error } = await fetchSecrets(
|
|
|
|
|
"projectgroup",
|
|
|
|
|
projectgroupref,
|
|
|
|
|
false
|
|
|
|
|
));
|
|
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.secrets = data;
|
|
|
|
|
|
|
|
|
|
({ data, error } = await fetchSecrets(
|
|
|
|
|
"projectgroup",
|
|
|
|
|
projectgroupref,
|
|
|
|
|
true
|
|
|
|
|
));
|
|
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.allsecrets = data;
|
|
|
|
|
|
2019-05-14 16:05:17 +00:00
|
|
|
({ data, error } = await fetchVariables(
|
2019-04-02 16:08:03 +00:00
|
|
|
"projectgroup",
|
2019-05-13 14:29:47 +00:00
|
|
|
projectgroupref,
|
2019-04-02 16:08:03 +00:00
|
|
|
false
|
2019-05-14 16:05:17 +00:00
|
|
|
));
|
2019-05-13 14:29:47 +00:00
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.variables = data;
|
|
|
|
|
|
|
|
|
|
({ data, error } = await fetchVariables(
|
2019-04-02 16:08:03 +00:00
|
|
|
"projectgroup",
|
2019-05-13 14:29:47 +00:00
|
|
|
projectgroupref,
|
2019-04-02 16:08:03 +00:00
|
|
|
true
|
2019-05-13 14:29:47 +00:00
|
|
|
));
|
|
|
|
|
if (error) {
|
|
|
|
|
this.$store.dispatch("setError", error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.allvariables = data;
|
2019-04-02 16:08:03 +00:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
</style>
|
|
|
|
|
|