Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,12 @@

const repoData = data.value.data
repoDetailStore.initialize(repoData, props.repoType)

setRepoTab({
currentBranch: props.currentBranch ? props.currentBranch : repoDetailStore.defaultBranch,
})

if (!isUpdate) {
setRepoTab({
currentBranch: props.currentBranch || repoDetailStore.defaultBranch
})
}
return true
} catch (error) {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,37 @@
/>
</div>
</div>

<!-- 更新默认分支 -->
<div class="flex xl:flex-col gap-[32px]">
<div class="w-[380px] sm:w-full flex flex-col">
<div class="text-sm text-gray-700 leading-5 font-medium">
{{ $t('application_spaces.edit.defaultBranch') }}
</div>
<div class="text-sm text-gray-600 leading-5">
{{ $t('application_spaces.edit.defaultBranchDesc') }}
</div>
</div>
<div class="flex flex-col gap-1.5">
<el-select
v-model="theDefaultBranch"
size="large"
class="!w-[512px] sm:!w-full">
<el-option
v-for="branch in branchList"
:key="branch.name"
:label="branch.name"
:value="branch.name" />
</el-select>
<CsgButton
v-if="hasDefaultBranchChanged"
@click="updateDefaultBranch"
class="btn btn-secondary-gray btn-sm"
style="width:fit-content"
:name="$t('all.update')"
/>
</div>
</div>

<el-divider />

Expand Down Expand Up @@ -600,6 +631,9 @@
theMinReplica: this.minReplica != null ? this.minReplica : 0,
originalApplicationSpaceNickname: this.applicationSpaceNickname || '',
originalApplicationSpaceDesc: this.applicationSpaceDesc || '',
originalDefaultBranch: this.default_branch || '',
theDefaultBranch: this.default_branch || '',
branchList: [],
originalVariables: JSON.stringify(this.variables || {}),
originalClusterId: this.clusterId || '',
originalCloudResource: this.cloudResource != null ? String(this.cloudResource) : '',
Expand Down Expand Up @@ -684,6 +718,9 @@
hasDescChanged() {
return this.theApplicationSpaceDesc.trim() !== this.originalApplicationSpaceDesc.trim()
},
hasDefaultBranchChanged() {
return this.theDefaultBranch.trim() !== this.originalDefaultBranch.trim()
},
hasVariablesChanged() {
return JSON.stringify(this.theVariables) !== this.originalVariables
},
Expand Down Expand Up @@ -713,6 +750,10 @@
applicationSpaceDesc(newDesc, _) {
this.theApplicationSpaceDesc = newDesc
},
default_branch(newBranch) {
this.theDefaultBranch = newBranch
this.originalDefaultBranch = newBranch
},
cloudResource(newResource, _) {
this.theCloudResource = /^\d+$/.test(newResource) ? Number(newResource) : this.cloudResource
},
Expand All @@ -737,8 +778,12 @@
emits: ['showSpaceLogs'],
async mounted() {
await this.fetchClusters()
// this.fetchSpaceResources()
this.fetchSpaceDetail()
// Fetch space detail first to get the latest cloudResource value
await this.fetchSpaceDetail()
// Then fetch resources with the updated cloudResource
await this.fetchSpaceResources()
await this.fetchBranches()

if (this.tags && Object.keys(this.tags).length > 0) {
this.getSelectTags()
}
Expand Down Expand Up @@ -1135,6 +1180,17 @@
}
},

async updateDefaultBranch() {
const branch = this.theDefaultBranch.trim()
if (!branch) return
this.updateApplicationSpace({ default_branch: branch }, this.$t('application_spaces.edit.defaultBranch'))
},

async fetchBranches() {
const { data } = await useFetchApi(`/spaces/${this.path}/branches`).json()
this.branchList = data.value?.data || []
},

updateApplicationSpaceCloudResource() {
const payload = { resource_id: this.theCloudResource }
this.updateApplicationSpace(payload,this.$t('application_spaces.edit.cloudResource'))
Expand Down
54 changes: 53 additions & 1 deletion frontend/src/components/codes/CodeSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,35 @@
</div>
</div>

<!-- 更新默认分支 -->
<div class="flex xl:flex-col gap-8">
<div class="w-[380px] sm:w-full flex flex-col">
<div class="text-sm text-gray-700 leading-5 font-medium">
{{ $t('codes.edit.defaultBranch') }}
</div>
<div class="text-sm text-gray-600 leading-5">
{{ $t('codes.edit.defaultBranchDesc') }}
</div>
</div>
<div class="flex flex-col gap-1.5">
<el-select
v-model="theDefaultBranch"
size="large"
class="!w-[512px] sm:!w-full">
<el-option
v-for="branch in branchList"
:key="branch.name"
:label="branch.name"
:value="branch.name" />
</el-select>
<CsgButton
v-if="hasDefaultBranchChanged"
@click="updateDefaultBranch"
class="btn btn-secondary-gray btn-sm w-fit"
:name="$t('all.update')" />
</div>
</div>

<el-divider />

<!-- 修改可见性 -->
Expand Down Expand Up @@ -179,6 +208,9 @@
codePath: this.path,
originalCodeNickname: this.codeNickname || '',
originalCodeDesc: this.codeDesc || '',
originalDefaultBranch: this.default_branch || '',
theDefaultBranch: this.default_branch || '',
branchList: [],
options: [
{ value: 'Private', label: this.$t('all.private') },
{ value: 'Public', label: this.$t('all.public') }
Expand All @@ -194,6 +226,9 @@
hasDescChanged() {
return this.theCodeDesc.trim() !== this.originalCodeDesc.trim()
},
hasDefaultBranchChanged() {
return this.theDefaultBranch.trim() !== this.originalDefaultBranch.trim()
},
visibilityName: {
get() {
return !!this.privateVisibility ? 'Private' : 'Public'
Expand All @@ -209,9 +244,15 @@
},
codeDesc(newDesc, _) {
this.theCodeDesc = newDesc
},
default_branch(newBranch) {
this.theDefaultBranch = newBranch
this.originalDefaultBranch = newBranch
}
},
mounted() {},
mounted() {
this.fetchBranches()
},
inject: ['fetchRepoDetail'],
methods: {
...mapActions(useRepoDetailStore, ['updateVisibility']),
Expand Down Expand Up @@ -294,6 +335,17 @@
}
},

async updateDefaultBranch() {
const branch = this.theDefaultBranch.trim()
if (!branch) return
this.updateCode({ default_branch: branch })
},

async fetchBranches() {
const { data } = await useFetchApi(`/codes/${this.path}/branches`).json()
this.branchList = data.value?.data || []
},

async updateCode(payload) {
const codeUpdateEndpoint = `/codes/${this.path}`
const options = {
Expand Down
53 changes: 52 additions & 1 deletion frontend/src/components/datasets/DatasetSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,36 @@
</div>
</div>

<!-- 更新默认分支 -->
<div class="flex xl:flex-col gap-8">
<div class="w-[380px] sm:w-full flex flex-col">
<div class="text-sm text-gray-700 leading-5 font-medium">
{{ $t('datasets.edit.defaultBranch') }}
</div>
<div class="text-sm text-gray-600 leading-5">
{{ $t('datasets.edit.defaultBranchDesc') }}
</div>
</div>
<div class="flex flex-col gap-1.5">
<el-select
v-model="theDefaultBranch"
size="large"
class="!w-[512px] sm:!w-full">
<el-option
v-for="branch in branchList"
:key="branch.name"
:label="branch.name"
:value="branch.name" />
</el-select>
<CsgButton
v-if="hasDefaultBranchChanged"
@click="updateDefaultBranch"
class="btn btn-secondary-gray btn-sm w-fit"
:name="$t('all.update')"
/>
</div>
</div>

<el-divider />

<!-- 数据集标签 -->
Expand Down Expand Up @@ -330,6 +360,9 @@
isUpdatingIndustryTags: false,
originalDatasetNickname: this.datasetNickname || '',
originalDatasetDesc: this.datasetDesc || '',
originalDefaultBranch: this.default_branch || '',
theDefaultBranch: this.default_branch || '',
branchList: [],
originalTags: [],
originalIndustryTags: [],
options: [
Expand All @@ -347,6 +380,9 @@
hasDescChanged() {
return this.theDatasetDesc.trim() !== this.originalDatasetDesc.trim()
},
hasDefaultBranchChanged() {
return this.theDefaultBranch.trim() !== this.originalDefaultBranch.trim()
},
hasTagsChanged() {
if (this.originalTags.length !== this.selectedTags.length) return true
const originalTagIds = this.originalTags.map(tag => tag.uid).sort()
Expand All @@ -372,10 +408,10 @@
if (Object.keys(this.tags).length > 0) {
this.getSelectTags()
}
// 监听全局点击事件
document.addEventListener('click', this.collapseTagList)
this.getIndustryTags()
this.fetchReadme()
this.fetchBranches()
},
watch: {
datasetNickname(newNickname, _) {
Expand All @@ -384,6 +420,10 @@
datasetDesc(newDesc, _) {
this.theDatasetDesc = newDesc
},
default_branch(newBranch) {
this.theDefaultBranch = newBranch
this.originalDefaultBranch = newBranch
},
tagList(newTagList, _) {
this.theTagList = newTagList
},
Expand Down Expand Up @@ -742,6 +782,17 @@
}
},

async updateDefaultBranch() {
const branch = this.theDefaultBranch.trim()
if (!branch) return
this.updateDataset({ default_branch: branch })
},

async fetchBranches() {
const { data } = await useFetchApi(`/datasets/${this.path}/branches`).json()
this.branchList = data.value?.data || []
},

async updateDataset(payload) {
const datasetUpdateEndpoint = `/datasets/${this.path}`
const options = {
Expand Down
Loading
Loading