Construct the full custom condition including the prefix Condition contains the change prefix + " is " + the actual value that should be true. Plugins only provide the latter part and we should prefix it with prefix to form the full condition. Verified it works locally. Release-Notes: skip Bug: Google b/482366559 Change-Id: Iab564c1cbb6497a5062d551042ae106941d6862b
diff --git a/polygerrit-ui/app/models/flows/flows-model.ts b/polygerrit-ui/app/models/flows/flows-model.ts index f085fb6..300a1b7 100644 --- a/polygerrit-ui/app/models/flows/flows-model.ts +++ b/polygerrit-ui/app/models/flows/flows-model.ts
@@ -191,15 +191,16 @@ name: SUBMIT_ACTION_NAME, }; + let condition = getSubmitCondition(); + if (autosubmitProvider?.getSubmitCondition()) { + condition = `${getChangePrefix()} is ${autosubmitProvider.getSubmitCondition()}`; + } + await this.restApiService.createFlow(this.changeNum, { stage_expressions: [ { - condition: autosubmitProvider - ? autosubmitProvider.getSubmitCondition()! - : getSubmitCondition(), - action: autosubmitProvider - ? autosubmitProvider.getSubmitAction() - : defaultAction, + condition, + action: autosubmitProvider?.getSubmitAction() ?? defaultAction, }, ], });
diff --git a/polygerrit-ui/app/models/flows/flows-model_test.ts b/polygerrit-ui/app/models/flows/flows-model_test.ts index de729af..2dfe5a7 100644 --- a/polygerrit-ui/app/models/flows/flows-model_test.ts +++ b/polygerrit-ui/app/models/flows/flows-model_test.ts
@@ -6,6 +6,7 @@ import {testResolver} from '../../test/common-test-setup'; import { FlowsModel, + getChangePrefix, getSubmitCondition, SUBMIT_ACTION_NAME, } from './flows-model'; @@ -149,7 +150,7 @@ assert.deepEqual(args[1], { stage_expressions: [ { - condition: 'custom condition', + condition: getChangePrefix() + ' is custom condition', action: {name: 'custom action'}, }, ],