Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:semaphoreui/semaphore into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Apr 28, 2024
2 parents 3282bc7 + a2f2f37 commit eed4586
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 72 deletions.
2 changes: 1 addition & 1 deletion api/projects/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func UpdateInventory(w http.ResponseWriter, r *http.Request) {
}
default:
helpers.WriteErrorStatus(w,
"unknown inventory type: %s"+string(inventory.Type),
"unknown inventory type: "+string(inventory.Type),
http.StatusBadRequest)
return
}
Expand Down
1 change: 1 addition & 0 deletions db/Repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (r Repository) ClearCache() error {
if err != nil {
return err
}
defer dir.Close()

files, err := dir.ReadDir(0)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/EditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Can use used in tandem with ItemFormBase.js. See KeyForm.vue for example.
<slot name="title">{{ title }}</slot>
</v-card-title>

<v-card-text class="pb-0">
<v-card-text class="pb-0" :style="{minHeight: minContentHeight + 'px'}">
<slot
name="form"
:onSave="close"
Expand Down Expand Up @@ -67,6 +67,7 @@ export default {
saveButtonText: String,
value: Boolean,
maxWidth: Number,
minContentHeight: Number,
eventName: String,
hideButtons: Boolean,
},
Expand Down
76 changes: 76 additions & 0 deletions web/src/components/EditTemplateDialogue.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<template>
<EditDialog
:max-width="700"
:min-content-height="457"
v-model="dialog"
:save-button-text="itemId === 'new' ? $t('create') : $t('save')"
:icon="APP_ICONS[itemApp].icon"
:icon-color="$vuetify.theme.dark ? APP_ICONS[itemApp].darkColor : APP_ICONS[itemApp].color"
:title="(itemId === 'new' ? $t('newTemplate') : $t('editTemplate')) +
' \'' + APP_TITLE[itemApp] + '\''"
@save="onSave"
>
<template v-slot:form="{ onSave, onError, needSave, needReset }">
<TemplateForm
:project-id="projectId"
:item-id="itemId"
@save="onSave"
@error="onError"
:need-save="needSave"
:need-reset="needReset"
:source-item-id="sourceItemId"
/>
</template>
</EditDialog>
</template>

<style scoped lang="scss">
</style>

<script>
import { APP_ICONS, APP_TITLE } from '../lib/constants';
import TemplateForm from './TemplateForm.vue';
import EditDialog from './EditDialog.vue';
export default {
components: {
TemplateForm,
EditDialog,
},
props: {
value: Boolean,
itemApp: String,
projectId: Number,
itemId: [String, Number],
sourceItemId: Number,
},
data() {
return {
APP_TITLE,
APP_ICONS,
dialog: false,
};
},
watch: {
async dialog(val) {
this.$emit('input', val);
},
async value(val) {
this.dialog = val;
},
},
methods: {
onSave(e) {
this.$emit('save', e);
},
},
};
</script>
16 changes: 15 additions & 1 deletion web/src/components/TemplateForm.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
<template>
<div v-if="!isLoaded">
<v-row>
<v-col>
<v-skeleton-loader
type="table-heading, list-item-two-line, image, table-tfoot"
></v-skeleton-loader>
</v-col>
<v-col>
<v-skeleton-loader
type="table-heading, list-item-two-line, image, table-tfoot"
></v-skeleton-loader>
</v-col>
</v-row>
</div>
<v-form
v-else
ref="form"
lazy-validation
v-model="formValid"
v-if="isLoaded"
>
<v-dialog
v-model="helpDialog"
Expand Down
29 changes: 29 additions & 0 deletions web/src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,32 @@ export const EXTRACT_VALUE_BODY_DATA_TYPE_ICONS = {
json: 'mdi-code-json',
str: 'mdi-text',
};

export const APP_ICONS = {
'': {
icon: 'mdi-ansible',
color: 'black',
darkColor: 'white',
},
terraform: {
icon: 'mdi-terraform',
color: '#7b42bc',
darkColor: '#7b42bc',
},
bash: {
icon: 'mdi-bash',
color: 'black',
darkColor: 'white',
},
};

export const APP_TITLE = {
'': 'Ansible Playbook',
terraform: 'Terraform Code',
bash: 'Bash Script',
};

export const APP_INVENTORY_TITLE = {
'': 'Ansible Inventory',
terraform: 'Terraform Workspace',
};
63 changes: 22 additions & 41 deletions web/src/views/project/TemplateView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,22 @@
:template-type="item.type"
/>

<EditDialog
:max-width="700"
v-model="editDialog"
:save-button-text="$t('save')"
:title="$t('editTemplate')"
@save="loadData()"
>
<template v-slot:form="{ onSave, onError, needSave, needReset }">
<TemplateForm
:project-id="projectId"
:item-id="itemId"
@save="onSave"
@error="onError"
:need-save="needSave"
:need-reset="needReset"
/>
</template>
</EditDialog>

<EditDialog
:max-width="700"
v-model="copyDialog"
:save-button-text="$t('create')"
:title="$t('newTemplate2')"
@save="onTemplateCopied"
>
<template v-slot:form="{ onSave, onError, needSave, needReset }">
<TemplateForm
:project-id="projectId"
item-id="new"
:source-item-id="itemId"
@save="onSave"
@error="onError"
:need-save="needSave"
:need-reset="needReset"
/>
</template>
</EditDialog>
<EditTemplateDialogue
v-model="editDialog"
:project-id="projectId"
:item-app="item.app"
:item-id="itemId"
@save="loadData()"
></EditTemplateDialogue>

<EditTemplateDialogue
v-model="copyDialog"
:project-id="projectId"
:item-app="item.app"
item-id="new"
:source-item-id="itemId"
@save="onTemplateCopied"
></EditTemplateDialogue>

<ObjectRefsDialog
object-title="template"
Expand Down Expand Up @@ -214,8 +192,6 @@ import axios from 'axios';
import EventBus from '@/event-bus';
import { getErrorMessage } from '@/lib/error';
import YesNoDialog from '@/components/YesNoDialog.vue';
import EditDialog from '@/components/EditDialog.vue';
import TemplateForm from '@/components/TemplateForm.vue';
import TaskList from '@/components/TaskList.vue';
import {
TEMPLATE_TYPE_ACTION_TITLES,
Expand All @@ -225,10 +201,15 @@ import {
} from '@/lib/constants';
import ObjectRefsDialog from '@/components/ObjectRefsDialog.vue';
import NewTaskDialog from '@/components/NewTaskDialog.vue';
import EditTemplateDialogue from '@/components/EditTemplateDialogue.vue';
export default {
components: {
YesNoDialog, EditDialog, TemplateForm, TaskList, ObjectRefsDialog, NewTaskDialog,
YesNoDialog,
TaskList,
ObjectRefsDialog,
NewTaskDialog,
EditTemplateDialogue,
},
props: {
Expand Down
Loading

0 comments on commit eed4586

Please sign in to comment.