feat(apps): add default apps

This commit is contained in:
Denis Gukov 2024-07-09 16:47:07 +05:00
parent d3d34041da
commit b5ba69f4f6
3 changed files with 22 additions and 1 deletions

View File

@ -79,6 +79,18 @@ func appMiddleware(next http.Handler) http.Handler {
}
func getApps(w http.ResponseWriter, r *http.Request) {
defaultApps := map[string]util.App{
string(db.TemplateAnsible): {},
string(db.TemplateTerraform): {},
string(db.TemplateTofu): {},
string(db.TemplateBash): {},
string(db.TemplatePowerShell): {},
string(db.TemplatePython): {},
}
for k, a := range util.Config.Apps {
defaultApps[k] = a
}
type app struct {
ID string `json:"id"`
@ -91,7 +103,7 @@ func getApps(w http.ResponseWriter, r *http.Request) {
apps := make([]app, 0)
for k, a := range util.Config.Apps {
for k, a := range defaultApps {
apps = append(apps, app{
ID: k,

View File

@ -114,3 +114,5 @@ export const APP_INVENTORY_TITLE = {
terraform: 'Terraform Workspace',
tofu: 'OpenTofu Workspace',
};
export const DEFAULT_APPS = Object.keys(APP_ICONS);

View File

@ -58,6 +58,7 @@
<template v-slot:item.actions="{ item }">
<div style="white-space: nowrap">
<v-btn
v-if="!isDefaultApp(item.id)"
icon
class="mr-1"
@click="askDeleteItem(item.id)"
@ -67,6 +68,7 @@
</v-btn>
<v-btn
v-if="!isDefaultApp(item.id)"
icon
class="mr-1"
@click="editItem(item.id)"
@ -85,6 +87,7 @@ import ItemListPageBase from '@/components/ItemListPageBase';
import EditDialog from '@/components/EditDialog.vue';
import axios from 'axios';
import AppForm from '../components/AppForm.vue';
import { DEFAULT_APPS } from '../lib/constants';
export default {
mixins: [ItemListPageBase],
@ -140,6 +143,10 @@ export default {
},
});
},
isDefaultApp(appId) {
return DEFAULT_APPS.includes(appId);
},
},
};
</script>