feat(tf): update workspace

This commit is contained in:
Denis Gukov 2024-12-21 14:41:33 +05:00
parent b071663889
commit 65a42609a5
No known key found for this signature in database
GPG Key ID: 044381366A5D4731
3 changed files with 30 additions and 20 deletions

View File

@ -177,15 +177,13 @@ func UpdateInventory(w http.ResponseWriter, r *http.Request) {
}
switch inventory.Type {
case db.InventoryTerraformWorkspace, db.InventoryTofuWorkspace:
case db.InventoryStatic, db.InventoryStaticYaml:
break
case db.InventoryFile:
if !IsValidInventoryPath(inventory.Inventory) {
helpers.WriteErrorStatus(w, "Invalid inventory file pathname. Must be: path/to/inventory.", http.StatusBadRequest)
return
}
case db.InventoryTerraformWorkspace:
break
default:
helpers.WriteErrorStatus(w,
"unknown inventory type: "+string(inventory.Type),

View File

@ -3,7 +3,7 @@
ref="form"
lazy-validation
v-model="formValid"
v-if="item != null"
v-if="item != null && keys != null"
>
<v-alert
:value="formError"
@ -19,6 +19,18 @@
:disabled="formSaving"
></v-text-field>
<v-select
v-model="item.ssh_key_id"
label="SSH key for private modules *"
:rules="[v => !!v || 'Key is required']"
dense
required
:items="keys"
item-value="id"
item-text="name"
:disabled="formSaving"
></v-select>
</v-form>
</template>
<style>
@ -52,7 +64,7 @@ export default {
method: 'get',
url: `/api/project/${this.projectId}/keys`,
responseType: 'json',
}));
})).data;
},
methods: {

View File

@ -30,7 +30,7 @@
<EditDialog
v-model="inventoryDialog"
:save-button-text="$t('create')"
:save-button-text="itemId === 'new' ? $t('create') : $t('save')"
:icon="getAppIcon(template.app)"
:icon-color="getAppColor(template.app)"
:title="`${$t('nnew')} ${APP_INVENTORY_TITLE[template.app]}`"
@ -42,7 +42,7 @@
:template-id="template.id"
:project-id="template.project_id"
:name-prefix="`${template.name} - `"
:item-id="'new'"
:item-id="itemId"
:type="`${template.app}-workspace`"
@save="onSave"
@error="onError"
@ -72,7 +72,7 @@
</template>
</EditDialog>
<div class="px-4 py-3" style="max-width: 1000px; margin: auto;">
<div class="px-4 py-3 CenterToScreen" style="max-width: 1000px; margin: auto;">
<div class="mb-6">
<v-btn-toggle
dense
@ -116,7 +116,7 @@
</v-btn>
</template>
<v-list>
<v-list-item @click="inventoryDialog = true">
<v-list-item @click="itemId = 'new'; inventoryDialog = true">
<v-list-item-icon>
<v-icon>mdi-pencil</v-icon>
</v-list-item-icon>
@ -132,7 +132,7 @@
</v-menu>
</div>
<v-divider class="mb-6" />
<v-divider class="mb-6"/>
<div class="mb-6 d-flex justify-space-between align-center" v-if="inventories.length > 0">
@ -141,7 +141,7 @@
<div>
<v-btn
class="mr-4 mb-2"
class="mr-4"
:disabled="inventoryId === template.inventory_id"
color="success"
@click="setDefaultInventory()"
@ -150,8 +150,8 @@
</v-btn>
<v-btn
class="mr-4"
color="primary"
class="mr-4 mb-2"
:disabled="inventoryId === template.inventory_id"
@click="detachInventory()"
>
@ -159,21 +159,20 @@
</v-btn>
<v-btn
class="mb-2"
icon
class="mr-2"
color="error"
:disabled="inventoryId === template.inventory_id"
@click="deleteInventoryDialog = true;"
>
Change
<v-icon>mdi-delete</v-icon>
</v-btn>
<v-btn
class="mb-2"
color="error"
:disabled="inventoryId === template.inventory_id"
@click="deleteInventoryDialog = true;"
icon
@click="itemId = inventoryId; inventoryDialog = true;"
>
Delete
<v-icon>mdi-pencil</v-icon>
</v-btn>
</div>
</div>
@ -322,7 +321,7 @@ export default {
watch: {
async inventoryId() {
this.inventory = this.inventories.find((inv) => inv.id === this.inventoryId);
this.inventory = (this.inventories || []).find((inv) => inv.id === this.inventoryId);
await this.loadAliases();
await this.loadStates();
},
@ -362,6 +361,7 @@ export default {
width: '0%',
},
],
itemId: null,
};
},