Skip to content

Commit

Permalink
web: Remove unused components
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Apr 24, 2024
1 parent abef3ab commit b6199c6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 134 deletions.
22 changes: 0 additions & 22 deletions web/src/assets/styles/blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -329,28 +329,6 @@ ul[data-type="agama/list"][role="grid"] {
}
}

// Each kind of list/selector has its way of laying out their items
[data-items-type="agama/storage-devices"] {
display: grid;
gap: var(--spacer-smaller);
grid-template-columns: 1fr 2fr 2fr;
grid-template-areas: "type-and-size drive-info drive-content";

svg {
vertical-align: inherit;
}

> div {
margin-block-end: 0;
}

> :first-child {
align-self: center;
text-align: center;
justify-self: start;
}
}

[data-items-type="agama/space-policies"] {
// It works with the default styling
}
Expand Down
113 changes: 2 additions & 111 deletions web/src/components/storage/device-utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import React from "react";
import { sprintf } from "sprintf-js";

import { _ } from "~/i18n";
import { noop } from "~/utils";
import { Icon } from "~/components/layout";
import { If, Selector, Tag } from "~/components/core";
import { deviceSize } from "~/components/storage/utils";
import { If, Tag } from "~/components/core";
import { deviceBaseName } from "~/components/storage/utils";

/**
Expand Down Expand Up @@ -198,111 +196,4 @@ const DeviceContentInfo = ({ device }) => {
);
};

/**
* Content for a device item
* @component
*
* @param {Object} props
* @param {StorageDevice} props.device
*/
const DeviceItem = ({ device }) => {
const BasicInfo = () => {
const DeviceIcon = () => {
const names = {
raid: "storage",
md: "storage"
};

const name = names[device.type] || "hard_drive";

return <Icon name={name} />;
};

const DeviceSize = () => {
if (device.size === undefined) return null;

return <div>{deviceSize(device.size)}</div>;
};

return (
<div>
<DeviceIcon />
<DeviceSize />
</div>
);
};

return (
<div data-items-type="agama/storage-devices">
<BasicInfo data-type="type-and-size" />
<DeviceExtendedInfo device={device} />
<DeviceContentInfo device={device} />
</div>
);
};

/**
* @todo This component is not used anymore. Remove it.
*
* Component for listing storage devices.
* @component
*
* TODO: re-evaluate the need of this component when addressing
* https://github.com/openSUSE/agama/pull/1031
*
* @param {Object} props
* @param {StorageDevice[]} props.devices - Devices to show.
* @param {Object} props.itemProps - common props, if any, for list items.
*/
const DeviceList = ({ devices, ...itemProps }) => {
return (
<ul data-type="agama/list">
{ devices.map(device => (
<li aria-label={device.name} key={device.sid} {...itemProps}>
<DeviceItem device={device} />
</li>
))}
</ul>
);
};

const renderDeviceOption = (device) => <DeviceItem device={device} />;

/**
* @todo This component is not used anymore. Remove it.
*
* Component for selecting storage devices.
* @component
*
* @param {Object} props
* @param {StorageDevice[]} props.devices - Devices to show in the selector.
* @param {StorageDevice|StorageDevice[]} [props.selected] - Currently selected device. In case of
* multi selection, an array of devices can be used.
* @param {boolean} [props.isMultiple=false] - Activate multi selection.
* @param {onChangeFn} [props.onChange] - Callback to be called when the selected devices changes.
*
* @callback onChangeFn
* @param {StorageDevice|StorageDevice[]} selected - Selected device, or array of selected devices
* in case of multi selection.
*/
const DeviceSelector = ({ devices, selected, isMultiple = false, onChange = noop }) => {
const selectedDevices = [selected].flat().filter(Boolean);

const onSelectionChange = (selection) => {
isMultiple ? onChange(selection) : onChange(selection[0]);
};

return (
<Selector
aria-label={_("Available devices")}
isMultiple={isMultiple}
options={devices}
optionIdKey="sid"
renderOption={renderDeviceOption}
selectedIds={selectedDevices.map(d => d.sid)}
onSelectionChange={onSelectionChange}
/>
);
};

export { DeviceList, DeviceSelector, DeviceContentInfo, DeviceExtendedInfo, FilesystemLabel };
export { DeviceContentInfo, DeviceExtendedInfo, FilesystemLabel };
2 changes: 1 addition & 1 deletion web/src/components/storage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export { default as DASDFormatProgress } from "./DASDFormatProgress";
export { default as ZFCPPage } from "./ZFCPPage";
export { default as ZFCPDiskForm } from "./ZFCPDiskForm";
export { default as ISCSIPage } from "./ISCSIPage";
export { DeviceList, DeviceSelector, DeviceContentInfo, DeviceExtendedInfo, FilesystemLabel } from "./device-utils";
export { DeviceContentInfo, DeviceExtendedInfo, FilesystemLabel } from "./device-utils";
export { default as VolumeForm } from "./VolumeForm";
export { default as BootSelectionDialog } from "./BootSelectionDialog";
export { default as DeviceSelectionDialog } from "./DeviceSelectionDialog";
Expand Down

0 comments on commit b6199c6

Please sign in to comment.