-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web: Reuse devices #1165
Merged
joseivanlopez
merged 32 commits into
agama-project:master
from
joseivanlopez:reuse-device
May 3, 2024
Merged
web: Reuse devices #1165
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4c082bf
web: Put "Delete" volume option at the end
dgdavid 1a107bd
web: Add the "Reset location" volume action
dgdavid 0a18ab9
web: Refactor VolumeActions internal component
dgdavid dd8ce25
web: Extract few components from VolumeRow
dgdavid dc24960
web: Improvements in tables
joseivanlopez d88d1f0
web: Fix a bunch of typos
dgdavid 7fb343b
web: WIP first version of the new location dialog
joseivanlopez 66b9b00
service: Fix bug converting settings from Y2Storage
joseivanlopez 4bcef6b
web: Improve wording
joseivanlopez 7a4f457
service: Always export the file system human string
joseivanlopez dc6c80f
web: Remove unnecessary conversion for file system type
joseivanlopez 07f850d
web: Do not consider reused devices as installation devices
joseivanlopez bded1d0
wer: Add alert when editing volume
joseivanlopez a9b8d0d
web: Several improvements
joseivanlopez 3d479a8
web: Force two rows layout in VolumeLocationDialog
dgdavid 78a57ae
web: Increase a bit the size of radio labels
dgdavid d458000
web: Add spaces between VolumeLocationDialog elements
dgdavid 9bfedf7
web: CSS tweaks for VolumeLocationDialog table
dgdavid 98a46ac
service: Do not set device if reusing a device
joseivanlopez b2d3512
web: Small fixes in styles
joseivanlopez fd5d7be
web: Small visual fix at DeviceSelectorTable
ancorgs 82f7be5
web: Add tests for VolumeLocationDialog
joseivanlopez b397231
web: Small fixes
joseivanlopez 1460a2d
web: Fix some tests
joseivanlopez a848039
Merge branch 'master' into reuse-device
joseivanlopez e77b83a
web: Fix and adapt some tests
joseivanlopez e2ae65d
web: Make scrollable table more discoverable
dgdavid 546f82c
web: Please CSpell
dgdavid 068e7b3
web: Add and adapt tests
joseivanlopez f4ce92b
web: Minor fixes
joseivanlopez 2dddefa
web: Changelog
joseivanlopez ca7e244
web: Improvements from review
joseivanlopez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -71,6 +71,7 @@ | |
"subvolume", | ||
"subvolumes", | ||
"svgrrc", | ||
"scrollbox", | ||
"teleporter", | ||
"testfile", | ||
"testsuite", | ||
|
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
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 |
---|---|---|
|
@@ -24,6 +24,11 @@ | |
import React, { useState } from "react"; | ||
import { Table, Thead, Tr, Th, Tbody, Td, ExpandableRowContent, RowSelectVariant } from "@patternfly/react-table"; | ||
|
||
/** | ||
* @typedef {import("@patternfly/react-table").TableProps} TableProps | ||
* @typedef {import("react").RefAttributes<HTMLTableElement>} HTMLTableProps | ||
*/ | ||
|
||
/** | ||
* An object for sharing data across nested maps | ||
* | ||
|
@@ -93,23 +98,26 @@ const sanitizeSelection = (selection, allowMultiple) => { | |
}; | ||
|
||
/** | ||
* Build a expandable table with selectable items | ||
* Build a expandable table with selectable items. | ||
* @component | ||
* | ||
* @note It only accepts one nesting level. | ||
* | ||
* @param {object} props | ||
* @param {ExpandableSelectorColumn[]} props.columns - Collection of objects defining columns. | ||
* @param {boolean} [props.isMultiple=false] - Whether multiple selection is allowed. | ||
* @param {object[]} props.items - Collection of items to be rendered. | ||
* @param {string} [props.itemIdKey="id"] - The key for retrieving the item id. | ||
* @param {(item: object) => Array<object>} [props.itemChildren=() => []] - Lookup method to retrieve children from given item. | ||
* @param {(item: object) => boolean} [props.itemSelectable=() => true] - Whether an item will be selectable or not. | ||
* @param {(item: object) => (string|undefined)} [props.itemClassNames=() => ""] - Callback that allows adding additional CSS class names to item row. | ||
* @param {object[]} [props.itemsSelected=[]] - Collection of selected items. | ||
* @param {string[]} [props.initialExpandedKeys=[]] - Ids of initially expanded items. | ||
* @param {(selection: Array<object>) => void} [props.onSelectionChange=noop] - Callback to be triggered when selection changes. | ||
* @param {object} [props.tableProps] - Props for {@link https://www.patternfly.org/components/table/#table PF/Table}. | ||
* @typedef {object} ExpandableSelectorBaseProps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NP: Just a note not related with this PR. We are following this pattern of defining ComponentBaseProp and for now it is ok. But I wonder if, since it is something internal, we could call them just BaseProp instead. I see two problems, however:
|
||
* @property {ExpandableSelectorColumn[]} [columns=[]] - Collection of objects defining columns. | ||
* @property {boolean} [isMultiple=false] - Whether multiple selection is allowed. | ||
* @property {object[]} [items=[]] - Collection of items to be rendered. | ||
* @property {string} [itemIdKey="id"] - The key for retrieving the item id. | ||
* @property {(item: object) => Array<object>} [itemChildren=() => []] - Lookup method to retrieve children from given item. | ||
* @property {(item: object) => boolean} [itemSelectable=() => true] - Whether an item will be selectable or not. | ||
* @property {(item: object) => (string|undefined)} [itemClassNames=() => ""] - Callback that allows adding additional CSS class names to item row. | ||
* @property {object[]} [itemsSelected=[]] - Collection of selected items. | ||
* @property {any[]} [initialExpandedKeys=[]] - Ids of initially expanded items. | ||
* @property {(selection: Array<object>) => void} [onSelectionChange=noop] - Callback to be triggered when selection changes. | ||
* | ||
* @typedef {ExpandableSelectorBaseProps & TableProps & HTMLTableProps} ExpandableSelectorProps | ||
* | ||
* @param {ExpandableSelectorProps} props | ||
*/ | ||
export default function ExpandableSelector({ | ||
columns = [], | ||
|
@@ -126,7 +134,14 @@ export default function ExpandableSelector({ | |
}) { | ||
const [expandedItemsKeys, setExpandedItemsKeys] = useState(initialExpandedKeys); | ||
const selection = sanitizeSelection(itemsSelected, isMultiple); | ||
const isItemSelected = (item) => selection.includes(item); | ||
const isItemSelected = (item) => { | ||
const selected = selection.find((selectionItem) => { | ||
return Object.hasOwn(selectionItem, itemIdKey) && | ||
selectionItem[itemIdKey] === item[itemIdKey]; | ||
}); | ||
|
||
return selected !== undefined || selection.includes(item); | ||
}; | ||
const isItemExpanded = (key) => expandedItemsKeys.includes(key); | ||
const toggleExpanded = (key) => { | ||
if (isItemExpanded(key)) { | ||
|
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: If I'm not wrong, we already have a
isChildren
function somewhere. Anyway, this kind of functions looks like a potential util that should live elsewhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is a
#deviceChildren
function to generate the list of children. In this case the function checks if it is a children of a device. Anyway, I think we need to improve this part, see https://github.com/openSUSE/agama/pull/1165/files#diff-8cfada04978222410b4703fc1ca52a1ff139c6497329b3ca2e4e176ba5d14d00R26.