Skip to content

Commit 68bca44

Browse files
authored
Merge pull request #386 from fractal-analytics-platform/layout-improvements
Layout improvements
2 parents 5d78699 + 56aa770 commit 68bca44

34 files changed

+811
-503
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# Unreleased
44

5+
* Users registered by the admin are automatically verified (\#386).
6+
* A warning message is displayed to unverified users (\#386).
7+
* Made page headers more homogeneous (\#386).
8+
* Replaced some icons with more suitable ones (\#386).
9+
* Added search boxes on datasets, workflows and workflow tasks selection (\#386).
10+
* Moved "Create new workflow" to a modal (\#386).
511
* Added search project field on projects list page (\#379).
612
* Used modal to create new project (\#379).
713
* Sorted users in admin-area page (\#379).

package-lock.json

Lines changed: 51 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
"dompurify": "^3.0.5",
4545
"jose": "^4.14.4",
4646
"marked": "^7.0.4",
47-
"slim-select": "^2.5.1"
47+
"slim-select": "^2.8.1"
4848
}
4949
}

playwright.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default defineConfig({
3838

3939
webServer: [
4040
{
41-
command: './tests/start-test-server.sh 1.4.1a2',
41+
command: './tests/start-test-server.sh 1.4.2a0',
4242
port: 8000,
4343
waitForPort: true,
4444
stdout: 'pipe',

src/lib/common/errors.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function responseError(response) {
1414
* Used for example to handle the displaying of the error alert when using the ConfirmActionButton.
1515
*/
1616
export class AlertError extends Error {
17-
/** @type {null | { loc: string[], msg: string }} */
17+
/** @type {null | { loc: string[], msg: string } | string} */
1818
simpleValidationMessage;
1919

2020
/**
@@ -35,6 +35,9 @@ export class AlertError extends Error {
3535
if (!this.simpleValidationMessage) {
3636
return null;
3737
}
38+
if (typeof this.simpleValidationMessage === 'string') {
39+
return this.simpleValidationMessage;
40+
}
3841
if (this.simpleValidationMessage.loc.length !== loc.length) {
3942
return null;
4043
}
@@ -52,10 +55,16 @@ export class AlertError extends Error {
5255
*
5356
* @param {any} reason
5457
* @param {number | null} statusCode
55-
* @returns {null | { loc: string[], msg: string }}
58+
* @returns {null | { loc: string[], msg: string } | string}
5659
*/
5760
function getSimpleValidationMessage(reason, statusCode) {
58-
if (!isValidationError(reason, statusCode) || reason.detail.length !== 1) {
61+
if (!isValidationError(reason, statusCode)) {
62+
return null;
63+
}
64+
if (typeof reason.detail === 'string') {
65+
return reason.detail;
66+
}
67+
if (reason.detail.length !== 1) {
5968
return null;
6069
}
6170
const err = reason.detail[0];
@@ -74,7 +83,10 @@ function getSimpleValidationMessage(reason, statusCode) {
7483
* @returns {null | { [key: string]: string }}
7584
*/
7685
export function getValidationMessagesMap(reason, statusCode) {
77-
if (!isValidationError(reason, statusCode) || reason.detail.length === 0) {
86+
if (!isValidationError(reason, statusCode)) {
87+
return null;
88+
}
89+
if (!Array.isArray(reason.detail) || reason.detail.length === 0) {
7890
return null;
7991
}
8092
/** @type {{[key: string]: string}} */
@@ -97,7 +109,11 @@ export function getValidationMessagesMap(reason, statusCode) {
97109
* @returns {boolean}
98110
*/
99111
function isValidationError(reason, statusCode) {
100-
return statusCode === 422 && 'detail' in reason && Array.isArray(reason.detail);
112+
return (
113+
statusCode === 422 &&
114+
'detail' in reason &&
115+
(Array.isArray(reason.detail) || typeof reason.detail === 'string')
116+
);
101117
}
102118

103119
/**

src/lib/components/common/Modal.svelte

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import { displayStandardErrorAlert } from '$lib/common/errors';
2+
import { AlertError, displayStandardErrorAlert } from '$lib/common/errors';
33
import { onMount } from 'svelte';
44
55
export let id;
@@ -11,6 +11,7 @@
1111
export let centered = false;
1212
export let scrollable = false;
1313
export let bodyCss = '';
14+
/** @type {import('$lib/components/common/StandardErrorAlert.svelte').default|undefined} */
1415
let errorAlert;
1516
1617
onMount(async () => {
@@ -57,7 +58,7 @@
5758
await confirm();
5859
modal.hide();
5960
} catch (/** @type {any} */ error) {
60-
errorAlert = displayStandardErrorAlert(error, `errorAlert-${id}`);
61+
displayErrorAlert(error);
6162
}
6263
}
6364
@@ -68,6 +69,9 @@
6869
}
6970
7071
export function displayErrorAlert(/** @type {any} */ error) {
72+
if (error instanceof AlertError && error.getSimpleValidationMessage()) {
73+
error = error.getSimpleValidationMessage();
74+
}
7175
errorAlert = displayStandardErrorAlert(error, `errorAlert-${id}`);
7276
}
7377
@@ -87,7 +91,9 @@
8791

8892
<!-- Note: tabindex="-1" is needed to fix escape key not working in some cases -->
8993
<!-- (see https://stackoverflow.com/a/12630531) -->
90-
<div class="modal {size ? 'modal-' + size : ''}" {id} tabindex="-1">
94+
<!-- Note: data-bs-focus="false" is needed to avoid conflicts with slim-select -->
95+
<!-- (see https://github.com/brianvoe/slim-select/issues/475#issuecomment-1736440245) -->
96+
<div class="modal {size ? 'modal-' + size : ''}" {id} tabindex="-1" data-bs-focus="false">
9197
<div
9298
class="modal-dialog"
9399
class:modal-fullscreen={fullscreen}
@@ -103,9 +109,9 @@
103109
<slot name="body" />
104110
</div>
105111
{#if !!$$slots.footer}
106-
<div class="modal-footer">
107-
<slot name="footer" />
108-
</div>
112+
<div class="modal-footer">
113+
<slot name="footer" />
114+
</div>
109115
{/if}
110116
</div>
111117
</div>

0 commit comments

Comments
 (0)