|
| 1 | +/* |
| 2 | +Copyright (C) 2026 Cloudbase Solutions SRL |
| 3 | +This program is free software: you can redistribute it and/or modify |
| 4 | +it under the terms of the GNU Affero General Public License as |
| 5 | +published by the Free Software Foundation, either version 3 of the |
| 6 | +License, or (at your option) any later version. |
| 7 | +This program is distributed in the hope that it will be useful, |
| 8 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | +GNU Affero General Public License for more details. |
| 11 | +You should have received a copy of the GNU Affero General Public License |
| 12 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | +*/ |
| 14 | + |
| 15 | +import type { Field } from "@src/@types/Field"; |
| 16 | +import type { SchemaProperties, SchemaDefinitions } from "@src/@types/Schema"; |
| 17 | +import OptionsSchemaPluginBase from "../default/OptionsSchemaPlugin"; |
| 18 | + |
| 19 | +export default class OptionsSchemaParser extends OptionsSchemaPluginBase { |
| 20 | + override parseSchemaToFields(opts: { |
| 21 | + schema: SchemaProperties; |
| 22 | + schemaDefinitions?: SchemaDefinitions | null | undefined; |
| 23 | + dictionaryKey?: string; |
| 24 | + requiresWindowsImage?: boolean; |
| 25 | + }) { |
| 26 | + return super.parseSchemaToFields(opts); |
| 27 | + } |
| 28 | + |
| 29 | + override sortFields(fields: Field[]) { |
| 30 | + super.sortFields(fields); |
| 31 | + fields.sort((f1, f2) => { |
| 32 | + // sort zone field first |
| 33 | + if (f1.name === "zone") { |
| 34 | + return -1; |
| 35 | + } |
| 36 | + if (f2.name === "zone") { |
| 37 | + return 1; |
| 38 | + } |
| 39 | + return 0; |
| 40 | + }); |
| 41 | + } |
| 42 | +} |
0 commit comments