|
2 | 2 | import { FormErrorHandler } from '$lib/common/errors'; |
3 | 3 | import TaskGroupSelector from './TaskGroupSelector.svelte'; |
4 | 4 | import { recentActivities } from '$lib/stores'; |
| 5 | + import { PropertyDescription } from 'fractal-components'; |
5 | 6 |
|
6 | 7 | /** |
7 | 8 | * @typedef {Object} Props |
|
16 | 17 | let package_version = $state(''); |
17 | 18 | let python_version = $state(''); |
18 | 19 | let package_extras = $state(''); |
19 | | - /** @type {{key: string, value: string}[]} */ |
| 20 | + /** @type {Array<{key: string, value: string, type: 'pre' | 'post'}>} */ |
20 | 21 | let pinnedPackageVersions = $state([]); |
21 | 22 | let privateTask = $state(false); |
22 | 23 | let selectedGroup = $state(null); |
|
78 | 79 | formData.append('package_version', package_version); |
79 | 80 | } |
80 | 81 |
|
81 | | - const ppv = getPinnedPackageVersionsMap(); |
82 | | - if (ppv) { |
83 | | - formData.append('pinned_package_versions', JSON.stringify(ppv)); |
| 82 | + const ppvPre = getPinnedPackageVersionsMap('pre'); |
| 83 | + if (ppvPre) { |
| 84 | + formData.append('pinned_package_versions_pre', JSON.stringify(ppvPre)); |
| 85 | + } |
| 86 | + const ppvPost = getPinnedPackageVersionsMap('post'); |
| 87 | + if (ppvPost) { |
| 88 | + formData.append('pinned_package_versions_post', JSON.stringify(ppvPost)); |
84 | 89 | } |
85 | 90 |
|
86 | 91 | let url = `/api/v2/task/collect/pip?private=${privateTask}`; |
|
115 | 120 | } |
116 | 121 |
|
117 | 122 | /** |
| 123 | + * @param {'pre'|'post'} type |
118 | 124 | * @returns {{[key: string]: string}|undefined} |
119 | 125 | */ |
120 | | - function getPinnedPackageVersionsMap() { |
| 126 | + function getPinnedPackageVersionsMap(type) { |
121 | 127 | /** @type {{[key: string]: string}} */ |
122 | 128 | const map = {}; |
123 | 129 | for (const ppv of pinnedPackageVersions) { |
124 | | - if (ppv.key && ppv.value) { |
| 130 | + if (ppv.key && ppv.value && ppv.type === type) { |
125 | 131 | map[ppv.key] = ppv.value; |
126 | 132 | } |
127 | 133 | } |
|
132 | 138 | } |
133 | 139 |
|
134 | 140 | function addPackageVersion() { |
135 | | - pinnedPackageVersions = [...pinnedPackageVersions, { key: '', value: '' }]; |
| 141 | + pinnedPackageVersions = [...pinnedPackageVersions, { key: '', value: '', type: 'post' }]; |
136 | 142 | } |
137 | 143 |
|
138 | 144 | /** |
|
275 | 281 | {/if} |
276 | 282 | {#each pinnedPackageVersions as ppv, i (i)} |
277 | 283 | <div class="row"> |
278 | | - <div class="col-xl-6 col-lg-8 col-md-12 mb-2"> |
| 284 | + <div class="col-xl-8 col-lg-10 col-md-12 mb-2"> |
279 | 285 | <div class="input-group"> |
280 | 286 | <label class="input-group-text" for="ppv_key_{i}">Name</label> |
281 | 287 | <input |
282 | 288 | type="text" |
283 | | - class="form-control" |
| 289 | + class="form-control ppv-input" |
284 | 290 | id="ppv_key_{i}" |
285 | 291 | bind:value={ppv.key} |
286 | 292 | required |
287 | 293 | /> |
288 | 294 | <label class="input-group-text" for="ppv_value_{i}">Version</label> |
289 | 295 | <input |
290 | 296 | type="text" |
291 | | - class="form-control" |
| 297 | + class="form-control ppv-input" |
292 | 298 | id="ppv_value_{i}" |
293 | 299 | bind:value={ppv.value} |
294 | 300 | required |
295 | 301 | /> |
| 302 | + <span class="input-group-text"> |
| 303 | + <div class="form-check form-check-inline"> |
| 304 | + <input |
| 305 | + class="form-check-input" |
| 306 | + type="radio" |
| 307 | + name="ppv-type-{i}" |
| 308 | + id="ppv-pre-{i}" |
| 309 | + value="pre" |
| 310 | + bind:group={ppv.type} |
| 311 | + /> |
| 312 | + <label class="form-check-label" for="ppv-pre-{i}">Pre</label> |
| 313 | + </div> |
| 314 | + <div class="form-check form-check-inline me-1"> |
| 315 | + <input |
| 316 | + class="form-check-input" |
| 317 | + type="radio" |
| 318 | + name="ppv-type-{i}" |
| 319 | + id="ppv-post-{i}" |
| 320 | + value="post" |
| 321 | + bind:group={ppv.type} |
| 322 | + /> |
| 323 | + <label class="form-check-label" for="ppv-post-{i}">Post</label> |
| 324 | + </div> |
| 325 | + <PropertyDescription |
| 326 | + description="Whether the pinned dependency should be installed before or after the main package" |
| 327 | + /> |
| 328 | + </span> |
296 | 329 | <button |
297 | 330 | class="btn btn-outline-secondary" |
298 | 331 | type="button" |
|
347 | 380 | </div> |
348 | 381 | </form> |
349 | 382 | </div> |
| 383 | +
|
| 384 | +<style> |
| 385 | + .ppv-input { |
| 386 | + min-width: 100px; |
| 387 | + } |
| 388 | +</style> |
0 commit comments