refactor(项目管理): 项目设置同步需求去掉同步限制

This commit is contained in:
guoyuqi 2024-10-16 18:40:30 +08:00 committed by Craftsman
parent c2ad5dfa6a
commit abedfece3c
3 changed files with 3 additions and 47 deletions

View File

@ -29,11 +29,8 @@ public class DemandScheduleServiceImpl implements BaseDemandScheduleService {
public void updateDemandSyncScheduleConfig(List<ProjectApplication> bugSyncConfigs, String projectId, String currentUser) {
List<ProjectApplication> syncCron = bugSyncConfigs.stream().filter(config -> config.getType().equals(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + "_" + ProjectApplicationType.CASE_RELATED_CONFIG.CRON_EXPRESSION.name())).toList();
List<ProjectApplication> caseEnable = bugSyncConfigs.stream().filter(config -> config.getType().equals(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + "_" + ProjectApplicationType.CASE_RELATED_CONFIG.CASE_ENABLE.name())).toList();
List<ProjectApplication> syncEnable = bugSyncConfigs.stream().filter(config -> config.getType().equals(ProjectApplicationType.CASE_RELATED_CONFIG.CASE_RELATED.name() + "_" + ProjectApplicationType.CASE_RELATED_CONFIG.SYNC_ENABLE.name())).toList();
if (CollectionUtils.isNotEmpty(syncCron)) {
Boolean enableCase = Boolean.valueOf(caseEnable.getFirst().getTypeValue());
Boolean enableSync = Boolean.valueOf(syncEnable.getFirst().getTypeValue());
Boolean enable = enableCase && enableSync;
Boolean enable = Boolean.valueOf(caseEnable.getFirst().getTypeValue());
String typeValue = syncCron.getFirst().getTypeValue();
Schedule schedule = scheduleService.getScheduleByResource(projectId, DemandSyncJob.class.getName());
Optional<Schedule> optional = Optional.ofNullable(schedule);

View File

@ -466,7 +466,6 @@ public class ProjectApplicationControllerTests extends BaseTest {
Map<String, String> configs = new HashMap<>();
configs.put("DEMAND_PLATFORM_CONFIG", jsonConfig);
configs.put("CASE_ENABLE", "true");
configs.put("SYNC_ENABLE", "true");
configs.put("CRON_EXPRESSION", "0 0 0 * * ?");
return configs;
}
@ -476,7 +475,6 @@ public class ProjectApplicationControllerTests extends BaseTest {
Map<String, String> configs = new HashMap<>();
configs.put("DEMAND_PLATFORM_CONFIG", jsonConfig);
configs.put("CASE_ENABLE", "false");
configs.put("SYNC_ENABLE", "true");
configs.put("CRON_EXPRESSION", "0 0 0/1 * * ?");
return configs;
}

View File

@ -35,38 +35,8 @@
:form-rule="platformRules"
@mounted="handleMounted"
/>
<a-form-item>
<a-tooltip v-if="okDisabled" :content="t('project.menu.defect.enableAfterConfig')">
<a-switch size="small" type="line" disabled />
</a-tooltip>
<a-switch
v-else
v-model="form.SYNC_ENABLE"
checked-value="true"
unchecked-value="false"
size="small"
type="line"
@change="handleSwitchChange"
/>
<span class="ml-[8px] text-[var(--color-text-1)]">
{{ t('project.menu.updateSync') }}
</span>
<a-tooltip position="tl" :content-style="{ maxWidth: '500px' }">
<template #content>
<div class="flex flex-col">
<div>{{ t('project.menu.updateSyncTip') }}</div>
</div>
</template>
<div>
<MsIcon
class="ml-[8px] text-[var(--color-text-4)] hover:text-[rgb(var(--primary-5))]"
type="icon-icon-maybe_outlined"
/>
</div>
</a-tooltip>
</a-form-item>
<!-- 同步频率 -->
<a-form-item v-if="hasChange" field="CRON_EXPRESSION" :label="t('project.menu.CRON_EXPRESSION')">
<a-form-item field="CRON_EXPRESSION" :label="t('project.menu.CRON_EXPRESSION')">
<MsCronSelect v-model:model-value="form.CRON_EXPRESSION" />
</a-form-item>
</a-form>
@ -147,12 +117,10 @@
const form = reactive({
PLATFORM_KEY: '',
CASE_ENABLE: 'false', //
SYNC_ENABLE: 'false', //
SYNC_ENABLE: 'true', //
CRON_EXPRESSION: '0 0 0 * * ?', //
});
const hasChange = ref(false);
const formCreateValue = ref<Record<string, any>>({});
const okDisabled = computed(() => !form.PLATFORM_KEY);
@ -241,7 +209,6 @@
// keychange
await handlePlatformChange(res.platform_key);
form.CASE_ENABLE = res.case_enable;
hasChange.value = res.sync_enable === 'true';
form.PLATFORM_KEY = res.platform_key;
form.SYNC_ENABLE = res.sync_enable;
form.CRON_EXPRESSION = res.cron_expression;
@ -267,12 +234,6 @@
setValue();
}
function handleSwitchChange(value: string | number | boolean) {
if (typeof value === 'string') {
hasChange.value = value === 'true';
}
}
watch(
() => props.visible,
(val) => {