|
| 1 | +import { componentTypes } from '@@ddf'; |
| 2 | + |
| 3 | +const createSchema = (options, dropdownValue, setDropdownValue, values) => { |
| 4 | + const fields = [ |
| 5 | + { |
| 6 | + component: componentTypes.SUB_FORM, |
| 7 | + id: 'col1', |
| 8 | + name: 'col1', |
| 9 | + className: 'col1', |
| 10 | + fields: [ |
| 11 | + { |
| 12 | + component: componentTypes.PLAIN_TEXT, |
| 13 | + id: 'menu_item_label', |
| 14 | + name: 'menu_item_label', |
| 15 | + className: 'menu-item-label', |
| 16 | + label: __('Menu item label'), |
| 17 | + style: { fontSize: '16px' }, |
| 18 | + }, |
| 19 | + { |
| 20 | + component: componentTypes.PLAIN_TEXT, |
| 21 | + id: 'divider_2', |
| 22 | + name: 'divider_2', |
| 23 | + label: '', |
| 24 | + className: 'left-divider', |
| 25 | + }, |
| 26 | + { |
| 27 | + component: componentTypes.TEXT_FIELD, |
| 28 | + id: 'item_label_1', |
| 29 | + name: 'item_label_1', |
| 30 | + className: 'item-label', |
| 31 | + placeholder: __('Documentation'), |
| 32 | + initialValue: values[0].title, |
| 33 | + maxLength: 128, |
| 34 | + isRequired: true, |
| 35 | + }, |
| 36 | + { |
| 37 | + component: componentTypes.PLAIN_TEXT, |
| 38 | + id: 'divider_3', |
| 39 | + name: 'divider_3', |
| 40 | + label: '', |
| 41 | + className: 'left-divider', |
| 42 | + }, |
| 43 | + { |
| 44 | + component: componentTypes.TEXT_FIELD, |
| 45 | + id: 'item_label_2', |
| 46 | + name: 'item_label_2', |
| 47 | + className: 'item-label', |
| 48 | + placeholder: __('ManageIQ.org'), |
| 49 | + initialValue: values[1].title, |
| 50 | + maxLength: 128, |
| 51 | + isRequired: true, |
| 52 | + }, |
| 53 | + { |
| 54 | + component: componentTypes.PLAIN_TEXT, |
| 55 | + id: 'divider_4', |
| 56 | + name: 'divider_4', |
| 57 | + label: '', |
| 58 | + className: 'left-divider', |
| 59 | + }, |
| 60 | + { |
| 61 | + component: componentTypes.TEXT_FIELD, |
| 62 | + id: 'item_label_3', |
| 63 | + name: 'item_label_3', |
| 64 | + className: 'item-label', |
| 65 | + placeholder: __('About'), |
| 66 | + initialValue: values[2].title, |
| 67 | + maxLength: 128, |
| 68 | + isRequired: true, |
| 69 | + }, |
| 70 | + ], |
| 71 | + }, |
| 72 | + { |
| 73 | + component: componentTypes.SUB_FORM, |
| 74 | + id: 'col2', |
| 75 | + name: 'col2', |
| 76 | + className: 'col2', |
| 77 | + fields: [ |
| 78 | + { |
| 79 | + component: componentTypes.PLAIN_TEXT, |
| 80 | + id: 'url_label', |
| 81 | + name: 'url_label', |
| 82 | + className: 'url-label', |
| 83 | + label: __('URL'), |
| 84 | + style: { fontSize: '16px' }, |
| 85 | + }, |
| 86 | + { |
| 87 | + component: componentTypes.PLAIN_TEXT, |
| 88 | + id: 'divider_5', |
| 89 | + name: 'divider_5', |
| 90 | + label: '', |
| 91 | + className: 'middle-divider', |
| 92 | + }, |
| 93 | + { |
| 94 | + component: componentTypes.TEXT_FIELD, |
| 95 | + id: 'url_1', |
| 96 | + name: 'url_1', |
| 97 | + className: 'url', |
| 98 | + placeholder: __('https://www.manageiq.org/docs/'), |
| 99 | + initialValue: values[0].href, |
| 100 | + maxLength: 128, |
| 101 | + isDisabled: dropdownValue[0] === 'modal', |
| 102 | + }, |
| 103 | + { |
| 104 | + component: componentTypes.PLAIN_TEXT, |
| 105 | + id: 'divider_6', |
| 106 | + name: 'divider_6', |
| 107 | + label: '', |
| 108 | + className: 'middle-divider', |
| 109 | + }, |
| 110 | + { |
| 111 | + component: componentTypes.TEXT_FIELD, |
| 112 | + id: 'url_2', |
| 113 | + name: 'url_2', |
| 114 | + className: 'url', |
| 115 | + placeholder: __('https://www.manageiq.org'), |
| 116 | + maxLength: 128, |
| 117 | + initialValue: values[0].href, |
| 118 | + isDisabled: dropdownValue[1] === 'modal', |
| 119 | + }, |
| 120 | + { |
| 121 | + component: componentTypes.PLAIN_TEXT, |
| 122 | + id: 'divider_7', |
| 123 | + name: 'divider_7', |
| 124 | + label: '', |
| 125 | + className: 'middle-divider', |
| 126 | + }, |
| 127 | + { |
| 128 | + component: componentTypes.TEXT_FIELD, |
| 129 | + id: 'url_3', |
| 130 | + name: 'url_3', |
| 131 | + className: 'url', |
| 132 | + maxLength: 128, |
| 133 | + initialValue: values[0].href, |
| 134 | + isDisabled: dropdownValue[2] === 'modal', |
| 135 | + }, |
| 136 | + ], |
| 137 | + }, |
| 138 | + { |
| 139 | + component: componentTypes.SUB_FORM, |
| 140 | + id: 'col3', |
| 141 | + name: 'col3', |
| 142 | + className: 'col3', |
| 143 | + fields: [ |
| 144 | + { |
| 145 | + component: componentTypes.PLAIN_TEXT, |
| 146 | + id: 'open_label', |
| 147 | + name: 'open_label', |
| 148 | + className: 'open-label', |
| 149 | + label: __('Open in'), |
| 150 | + style: { fontSize: '16px' }, |
| 151 | + }, |
| 152 | + { |
| 153 | + component: componentTypes.PLAIN_TEXT, |
| 154 | + id: 'divider_8', |
| 155 | + name: 'divider_8', |
| 156 | + label: '', |
| 157 | + className: 'right-divider', |
| 158 | + }, |
| 159 | + { |
| 160 | + component: componentTypes.SELECT, |
| 161 | + id: 'select_dropdown_1', |
| 162 | + name: 'select_dropdown_1', |
| 163 | + className: 'dropdown', |
| 164 | + hideLabel: true, |
| 165 | + options, |
| 166 | + maxLength: 128, |
| 167 | + isRequired: true, |
| 168 | + initialValue: dropdownValue[0], |
| 169 | + onChange: (value) => { |
| 170 | + setDropdownValue((prevValues) => { |
| 171 | + const updatedValues = [...prevValues]; |
| 172 | + updatedValues[0] = value; |
| 173 | + return updatedValues; |
| 174 | + }); |
| 175 | + }, |
| 176 | + }, |
| 177 | + { |
| 178 | + component: componentTypes.PLAIN_TEXT, |
| 179 | + id: 'divider_9', |
| 180 | + name: 'divider_9', |
| 181 | + label: '', |
| 182 | + className: 'right-divider', |
| 183 | + }, |
| 184 | + { |
| 185 | + component: componentTypes.SELECT, |
| 186 | + id: 'select_dropdown_2', |
| 187 | + name: 'select_dropdown_2', |
| 188 | + className: 'dropdown', |
| 189 | + hideLabel: true, |
| 190 | + options, |
| 191 | + initialValue: dropdownValue[1], |
| 192 | + maxLength: 128, |
| 193 | + onChange: (value) => { |
| 194 | + setDropdownValue((prevValues) => { |
| 195 | + const updatedValues = [...prevValues]; |
| 196 | + updatedValues[1] = value; |
| 197 | + return updatedValues; |
| 198 | + }); |
| 199 | + }, |
| 200 | + }, |
| 201 | + { |
| 202 | + component: componentTypes.PLAIN_TEXT, |
| 203 | + id: 'divider_10', |
| 204 | + name: 'divider_10', |
| 205 | + label: '', |
| 206 | + className: 'right-divider', |
| 207 | + }, |
| 208 | + { |
| 209 | + component: componentTypes.SELECT, |
| 210 | + id: 'select_dropdown_3', |
| 211 | + name: 'select_dropdown_3', |
| 212 | + className: 'dropdown', |
| 213 | + hideLabel: true, |
| 214 | + options, |
| 215 | + initialValue: dropdownValue[2], |
| 216 | + maxLength: 128, |
| 217 | + onChange: (value) => { |
| 218 | + setDropdownValue((prevValues) => { |
| 219 | + const updatedValues = [...prevValues]; |
| 220 | + updatedValues[2] = value; |
| 221 | + return updatedValues; |
| 222 | + }); |
| 223 | + }, |
| 224 | + }, |
| 225 | + ], |
| 226 | + }, |
| 227 | + ]; |
| 228 | + |
| 229 | + return { |
| 230 | + fields, |
| 231 | + }; |
| 232 | +}; |
| 233 | + |
| 234 | +export default createSchema; |
0 commit comments