feat: 优化成员权限和发布按钮状态

This commit is contained in:
湛兮
2026-06-12 10:53:30 +08:00
parent 0503ec2e0a
commit 61e6c73f12
6 changed files with 412 additions and 54 deletions
+35 -4
View File
@@ -31,6 +31,14 @@ const selectedProject = computed(() => {
return platform.projects.find((project) => project.key === form.projectKey)
})
const selectedProjectPermissionName = computed(() => {
return platform.projectPermissionLevel(form.projectKey) === 'build'
? '构建权限'
: '只读权限'
})
const canBuildSelectedProject = computed(() => platform.canBuildProject(form.projectKey))
const currentRefs = computed(() => platform.projectRefs[form.projectKey])
const environmentOptions = computed(() => {
@@ -129,7 +137,7 @@ const selectedPullRequestMeta = computed(() => {
})
const canTrigger = computed(() => {
if (!form.projectKey || !form.environment || !form.ref) {
if (!canBuildSelectedProject.value || !form.projectKey || !form.environment || !form.ref) {
return false
}
@@ -141,12 +149,23 @@ const shownRun = computed(() => {
})
const canSyncJenkins = computed(() => {
return shownRun.value?.status === 'queued' || shownRun.value?.status === 'running'
return (
platform.canBuildProject(shownRun.value?.projectKey) &&
(shownRun.value?.status === 'queued' || shownRun.value?.status === 'running')
)
})
const canCancelShownRun = computed(() => shownRun.value?.status === 'queued' || shownRun.value?.status === 'running')
const canCancelShownRun = computed(
() =>
platform.canBuildProject(shownRun.value?.projectKey) &&
(shownRun.value?.status === 'queued' || shownRun.value?.status === 'running'),
)
const canRetryShownRun = computed(() => shownRun.value?.status === 'failed' || shownRun.value?.status === 'canceled')
const canRetryShownRun = computed(
() =>
platform.canBuildProject(shownRun.value?.projectKey) &&
(shownRun.value?.status === 'failed' || shownRun.value?.status === 'canceled'),
)
async function triggerRelease() {
submitting.value = true
@@ -364,6 +383,9 @@ watch(refOptions, (options) => {
:value="project.key"
/>
</ElSelect>
<div v-if="selectedProject" class="field-hint">
当前权限:{{ selectedProjectPermissionName }}
</div>
</ElFormItem>
<ElFormItem label="环境">
<ElSegmented
@@ -441,6 +463,9 @@ watch(refOptions, (options) => {
<ElButton :icon="CircleClose" :disabled="!canRetryShownRun || submitting" @click="retryRelease">
重试
</ElButton>
<span v-if="form.projectKey && !canBuildSelectedProject" class="permission-action-hint">
当前账号只有只读权限,发布操作已禁用
</span>
</div>
</ElForm>
</div>
@@ -498,10 +523,16 @@ watch(refOptions, (options) => {
.action-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
margin-top: 16px;
}
.permission-action-hint {
color: #8a5a00;
font-size: 12px;
}
.commit-preview {
display: grid;
gap: 4px;