-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web: Add file systems for arbitrary mount points (#1154)
The storage UI only allows adding file systems for the mount points predefined by the product (typicaly */home*, *swap* or */var*). This PR extends the storage UI making possible to add file systems for any mount point. Main changes: * The *Add file system* button is now a menu button, which allows to select either a predefined mount point (if the mount point was not added yet) or an arbitrary one (the *Other* option). * The *Add file system* button turns into a regular button if only the *Other* option is available. * The *Add file system* button is disabled if the product does not admit arbitrary mount points (i.e., transactional system) and there is no pending predefined mount point to be added (i.e., all the predefined mount points were already added). * The *Add file system* is hidden if the product does not admit optional file systems (i.e., transactinal system without predefined mount points). * The file system form validates the mount point: * Validates mount point presence on accept. * Validates mount point format on accept. * Validates whether the entered mount point is already added and offers to edit such a file system. * Validates whether the entered mount point maches any of the predefined mount points and offers to add the predefined mount point. Note: This PR introduces a new validation pattern which was previoulsy discussed and agreed. The form validates its fields on accept and the field error is gone when the field value changes (independently on the field is now valid or not). The rationale of this behavior is: * The form should not complain on the fly (while typing) because the user has not finished until clicking on accept. * If the field shows an error, then remove the error with the first change on its value. We can consider the user has started fixing the field, but the form will not bother the user untill pressing on accept again. In the future we could improve these validations. For example, a wrong field could show a "green check" if the user edit its value and the new value is correct. <details> <summary>Screenshots</summary> ![localhost_8080_ (40)](https://github.com/openSUSE/agama/assets/1112304/b2dc3f2f-a732-479a-95b4-51850f95a95a) ![localhost_8080_ (43)](https://github.com/openSUSE/agama/assets/1112304/79fdfa61-12e0-44b7-b2c6-f1c43977f5e5) ![localhost_8080_ (42)](https://github.com/openSUSE/agama/assets/1112304/43b25082-4881-4a59-a856-e3b5a1e7fcc6) </details>
- Loading branch information
Showing
25 changed files
with
1,927 additions
and
829 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
------------------------------------------------------------------- | ||
Thu Apr 25 15:04:05 UTC 2024 - José Iván López González <[email protected]> | ||
|
||
- Allow adding arbitrary volumes (gh#openSUSE/agama#1154). | ||
|
||
------------------------------------------------------------------- | ||
Thu Apr 25 13:40:06 UTC 2024 - Ancor Gonzalez Sosa <[email protected]> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) [2024] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
// @ts-check | ||
// cspell:ignore labelable | ||
|
||
import React from "react"; | ||
import styles from '@patternfly/react-styles/css/components/Form/form'; | ||
|
||
/** | ||
* Renders a read-only form value with a label that visually looks identically | ||
* that a a label of an editable form value, without using the `label` HTML tag. | ||
* | ||
* Basically, this "mimicking component" is needed for two reasons: | ||
* | ||
* - The HTML specification limits the use of labels to "labelable elements". | ||
* | ||
* > Some elements, not all of them form-associated, are categorized as labelable | ||
* > elements. These are elements that can be associated with a label element. | ||
* > => button, input (if the type attribute is not in the Hidden state), meter, | ||
* > output, progress, select, textarea, form-associated custom elements | ||
* > | ||
* > https://html.spec.whatwg.org/multipage/forms.html#categories | ||
* | ||
* - Agama does not use disabled form controls for rendering a value that users | ||
* have no chance to change by any means, but a raw text instead. | ||
* | ||
* Based on PatternFly Form styles to maintain consistency. | ||
* | ||
* @typedef {import("react").ComponentProps<"div">} HTMLDivProps | ||
* @param {HTMLDivProps & { label: string }} props | ||
*/ | ||
export default function FormReadOnlyField({ label, children, className = "", ...props }) { | ||
return ( | ||
<div className={`${className} ${styles.formGroup}`.trim()} {...props}> | ||
<div className={styles.formGroupLabel} {...props}> | ||
<span className={styles.formLabelText}>{label}</span> | ||
</div> | ||
{children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) [2024] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of version 2 of the GNU General Public License as published | ||
* by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, contact SUSE LLC. | ||
* | ||
* To contact SUSE LLC about this file by physical or electronic mail, you may | ||
* find current contact information at www.suse.com. | ||
*/ | ||
|
||
import React from "react"; | ||
import { screen } from "@testing-library/react"; | ||
import { plainRender } from "~/test-utils"; | ||
import { FormReadOnlyField } from "~/components/core"; | ||
|
||
it("renders label and content wrapped in div nodes using expected PatternFly styles", () => { | ||
plainRender(<FormReadOnlyField label="Product">Agama</FormReadOnlyField>); | ||
const field = screen.getByText("Agama"); | ||
const label = screen.getByText("Product"); | ||
expect(field.classList.contains("pf-v5-c-form__group")).toBe(true); | ||
expect(label.classList.contains("pf-v5-c-form__label-text")).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.