Skip to content

Commit

Permalink
fix: unspecific risk source (#11992)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmadao committed May 15, 2024
1 parent 2a5f6d3 commit 7652e70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ const riskListGroupBySource = computed(() => {
});
const addRisk = () => {
const risk = Risk.fromJSON({
let source = filter.source.value;
if (source === Risk_Source.SOURCE_UNSPECIFIED) {
source = SupportedSourceList[0];
}
const risk = Risk.fromPartial({
level: PresetRiskLevelList[0].level,
source: filter.source.value || SupportedSourceList[0],
source,
active: true,
});
if (!hasFeature.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@ const { allowAdmin } = context;
const currentUser = useCurrentUserV1();
const state = ref<LocalState>({
risk: Risk.fromJSON({}),
expr: wrapAsGroup(resolveCELExpr(CELExpr.fromJSON({}))),
risk: Risk.fromPartial({}),
expr: wrapAsGroup(resolveCELExpr(CELExpr.fromPartial({}))),
});
const mode = computed(() => context.dialog.value?.mode ?? "CREATE");
const resolveLocalState = async () => {
const risk = cloneDeep(context.dialog.value!.risk);
let expr = CELExpr.fromJSON({});
let expr = CELExpr.fromPartial({});
if (risk.condition?.expression) {
const parsedExprs = await batchConvertCELStringToParsedExpr([
risk.condition.expression,
]);
expr = parsedExprs[0].expr ?? CELExpr.fromJSON({});
expr = parsedExprs[0].expr ?? CELExpr.fromPartial({});
}
state.value = {
Expand Down Expand Up @@ -200,11 +200,11 @@ const handleUpsert = async () => {
const risk = cloneDeep(state.value.risk);
const expressions = await batchConvertParsedExprToCELString([
ParsedExpr.fromJSON({
ParsedExpr.fromPartial({
expr: buildCELExpr(state.value.expr),
}),
]);
risk.condition = Expr.fromJSON({
risk.condition = Expr.fromPartial({
expression: expressions[0],
});
emit("save", risk);
Expand Down

0 comments on commit 7652e70

Please sign in to comment.