Skip to content

Commit d7f7808

Browse files
ymh6315431minghao.yanghiveer
authored
Add UI for managing Docker space variables and enhance localization (#977)
* Add Docker space variables management - Introduce UI for managing Docker space variables - Add props sdk and variables - Enhance localization for space variables - Ensure compatibility with existing application space settings * feat(application_spaces): improve variable input layout - Adjusted layout for variable inputs - Changed input size to small for better UX - Updated variable display structure * feat(application_spaces): improve layout and styling - Adjust flex direction for better layout - Update input size for consistency - Enhance spacing between elements * feat(application_spaces): improve layout and spacing - Adjusted flex gap for better alignment - Updated label spacing for clarity - Fixed typo in update variables button --------- Co-authored-by: minghao.yang <[email protected]> Co-authored-by: Hiveer <[email protected]>
1 parent 0ebd240 commit d7f7808

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

frontend/src/components/application_spaces/ApplicationSpaceSettings.vue

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,30 @@
198198
</div>
199199
</div>
200200

201+
<!-- docker space variables -->
202+
<el-divider v-if="theSdk === 'docker'"/>
203+
<div v-if="theSdk === 'docker'">
204+
<div class="flex xl:flex-col gap-8">
205+
<div class="w-[380px] sm:w-full flex flex-col">
206+
<div class="text-sm text-gray-700 leading-[20px] font-medium">
207+
{{ $t('application_spaces.edit.spaceVariables') }}
208+
</div>
209+
<div class="text-sm text-gray-600 leading-[20px]">
210+
{{ $t('application_spaces.edit.spaceVariablesDesc') }}
211+
</div>
212+
</div>
213+
<div class="flex flex-col gap-[6px]">
214+
<div v-for="(_, name) in theVariables" :key="name" class="flex gap-4 items-center mb-2">
215+
<label :for="name" class="text-gray-600 font-light text-xs">{{ name }}</label>
216+
<el-input v-model="theVariables[name]" size="large" class="!w-[400px] sm:!w-full"></el-input>
217+
</div>
218+
<el-button @click="updateVaribles" class="w-[100px]" data-test="update-varibles">
219+
{{ $t('all.update') }}
220+
</el-button>
221+
</div>
222+
</div>
223+
</div>
224+
201225
<el-divider />
202226

203227
<!-- 修改可见性 -->
@@ -351,7 +375,9 @@
351375
default_branch: String,
352376
appStatus: String,
353377
cloudResource: String,
354-
coverImage: String
378+
coverImage: String,
379+
sdk: String,
380+
variables: Object
355381
},
356382
357383
components: {},
@@ -362,6 +388,8 @@
362388
applicationSpacePath: this.path,
363389
theApplicationSpaceNickname: this.applicationSpaceNickname || '',
364390
theApplicationSpaceDesc: this.applicationSpaceDesc || '',
391+
theSdk: this.sdk || '',
392+
theVariables: this.variables || {},
365393
theCloudResource: /^\d+$/.test(this.cloudResource)
366394
? Number(this.cloudResource)
367395
: this.cloudResource,
@@ -435,6 +463,9 @@
435463
},
436464
cloudResource(newResource, _) {
437465
this.theCloudResource = /^\d+$/.test(newResource) ? Number(newResource) : this.cloudResource
466+
},
467+
variables(newVariables, _) {
468+
this.theVariables = newVariables
438469
}
439470
},
440471
@@ -654,6 +685,11 @@
654685
this.updateApplicationSpace(payload)
655686
},
656687
688+
updateVaribles() {
689+
const payload = { variables: JSON.stringify(this.theVariables) }
690+
this.updateApplicationSpace(payload)
691+
},
692+
657693
async updateApplicationSpace(payload) {
658694
const applicationSpaceUpdateEndpoint = `/spaces/${this.path}`
659695
const options = {

frontend/src/components/shared/RepoTabs.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@
215215
:cloudResource="repoDetail.sku || repoDetail.hardware"
216216
:coverImage="repoDetail.cover_image_url"
217217
@showSpaceLogs="showSpaceLogs"
218+
:sdk="sdk"
219+
:variables="repoDetail.variables ? JSON.parse(repoDetail.variables) : {}"
218220
/>
219221
<code-settings
220222
v-if="repoType === 'code'"

frontend/src/locales/en_js/application_spaces.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export const application_spaces = {
8686
spaceVariables: "Space Variables"
8787
},
8888
edit: {
89+
spaceVariables: "Space Variables",
90+
spaceVariablesDesc: "You can modify the space variables",
8991
cloudResource: 'Cloud resource',
9092
cloudResourceDesc: 'Switch to different cloud resources. When you switch to a paid resource, you will be charged based on how long you use it',
9193
currentCloudResource: 'Current cloud resources',

frontend/src/locales/zh_js/application_spaces.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export const application_spaces = {
8686
spaceVariables: "空间变量"
8787
},
8888
edit: {
89+
spaceVariables: "空间变量",
90+
spaceVariablesDesc: "你可以修改空间变量",
8991
cloudResource: '空间云资源',
9092
cloudResourceDesc: '可切换到不同的空间云资源。切换到付费资源后,将根据使用时长向您收取费用。',
9193
currentCloudResource: '当前云资源',

0 commit comments

Comments
 (0)