OT creation form deprecation trial bug fix (#4338)

* conditional prop access and TS definitions

* move prefix logic into conditional block

* lint-fix
This commit is contained in:
Daniel Smith 2024-09-06 17:39:15 +00:00 коммит произвёл GitHub
Родитель b88d7f9b77
Коммит c552277eb8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 24 добавлений и 22 удалений

Просмотреть файл

@ -356,15 +356,16 @@ export class ChromedashOTCreationPage extends LitElement {
this.featureId
);
// We only need the single stage changes.
const stageSubmitBody = featureSubmitBody.stages[0] as Object;
const stageSubmitBody = featureSubmitBody.stages[0];
// Add on the appropriate use counter prefix.
const useCounterPrefix =
this.webfeatureUseCounterType === USE_COUNTER_TYPE_WEBFEATURE
? ''
: 'WebDXFeature::';
stageSubmitBody['ot_webfeature_use_counter'].value =
`${useCounterPrefix}${stageSubmitBody['ot_webfeature_use_counter'].value}`;
if ('ot_webfeature_use_counter' in stageSubmitBody) {
// Add on the appropriate use counter prefix.
const useCounterPrefix =
this.webfeatureUseCounterType === USE_COUNTER_TYPE_WEBFEATURE
? ''
: 'WebDXFeature::';
stageSubmitBody.ot_webfeature_use_counter.value = `${useCounterPrefix}${stageSubmitBody.ot_webfeature_use_counter.value}`;
}
this.submitting = true;
window.csClient

Просмотреть файл

@ -541,21 +541,22 @@ export interface FieldInfo {
checkMessage?: string;
}
/**
* @typedef {Object} UpdateSubmitBody
* @property {Object.<string, *>} feature_changes An object with feature changes.
* key=field name, value=new field value.
* @property {Array.<Object>} stages The list of changes to specific stages.
* @property {boolean} has_changes Whether any valid changes are present for submission.
*/
interface UpdateSubmitBody {
feature_changes: FeatureUpdateInfo;
stages: StageUpdateInfo[];
has_changes: boolean;
}
/**
* Prepare feature/stage changes to be submitted.
* @param {Array.<FieldInfo>} fieldValues List of fields in the form.
* @param {number} featureId The ID of the feature being updated.
* @return {UpdateSubmitBody} Formatted body of new PATCH request.
*/
export function formatFeatureChanges(fieldValues, featureId) {
interface StageUpdateInfo {
[stageField: string]: any;
}
interface FeatureUpdateInfo {
[featureField: string]: any;
}
// Prepare feature/stage changes to be submitted.
export function formatFeatureChanges(fieldValues, featureId): UpdateSubmitBody {
let hasChanges = false;
const featureChanges = {id: featureId};
// Multiple stages can be mutated, so this object is a stage of stages.