Skip to content

Commit

Permalink
storage: Move "Format" action one card up
Browse files Browse the repository at this point in the history
Offer it on the "Partition" card instead of the "Filesystem" card, for
example.

This makes more sense. One formats a partition, but mounts the
filesystem.
  • Loading branch information
mvollmer committed Jan 24, 2024
1 parent cc4bfd3 commit efddee6
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 77 deletions.
2 changes: 1 addition & 1 deletion pkg/lib/cockpit-components-dynamic-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class DynamicListForm extends React.Component {

addItem() {
this.setState(state => {
return { list: [...state.list, {key: this.keyCounter++, ...this.props.default}] };
return { list: [...state.list, { key: this.keyCounter++, ...this.props.default }] };
}, () => this.props.onChange(this.state.list));
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/storaged/block/other.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.

import { StorageCard, StorageDescription, new_card } from "../pages.jsx";
import { block_name, should_ignore } from "../utils.js";
import { partitionable_block_actions } from "../partitions/actions.jsx";
import { partitionable_block_actions } from "./actions.jsx";
import { OtherIcon } from "../icons/gnome-icons.jsx";

import { make_block_page } from "../block/create-pages.jsx";
Expand Down
3 changes: 0 additions & 3 deletions pkg/storaged/block/unformatted-data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
*/

import cockpit from "cockpit";
import client from "../client";

import { StorageCard, new_card } from "../pages.jsx";
import { format_dialog } from "./format-dialog.jsx";
import { std_lock_action } from "../crypto/actions.jsx";

const _ = cockpit.gettext;
Expand All @@ -33,7 +31,6 @@ export function make_unformatted_data_card(next, backing_block, content_block) {
component: StorageCard,
actions: [
std_lock_action(backing_block, content_block),
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
]
});
}
3 changes: 0 additions & 3 deletions pkg/storaged/block/unrecognized-data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

import cockpit from "cockpit";
import React from "react";
import client from "../client";

import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.js";
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";

import { StorageCard, StorageDescription, new_card } from "../pages.jsx";
import { format_dialog } from "./format-dialog.jsx";
import { std_lock_action } from "../crypto/actions.jsx";

const _ = cockpit.gettext;
Expand All @@ -38,7 +36,6 @@ export function make_unrecognized_data_card(next, backing_block, content_block)
props: { backing_block, content_block },
actions: [
std_lock_action(backing_block, content_block),
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
]
});
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/storaged/btrfs/device.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { DescriptionList } from "@patternfly/react-core/dist/esm/components/Desc
import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { StorageUsageBar } from "../storage-controls.jsx";
import { std_lock_action } from "../crypto/actions.jsx";
import { format_dialog } from "../block/format-dialog.jsx";
import { btrfs_device_usage } from "./utils.jsx";

const _ = cockpit.gettext;
Expand All @@ -46,7 +45,6 @@ export function make_btrfs_device_card(next, backing_block, content_block, block
props: { backing_block, content_block },
actions: [
std_lock_action(backing_block, content_block),
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
],
});

Expand Down
3 changes: 0 additions & 3 deletions pkg/storaged/crypto/locked-encrypted-data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
*/

import cockpit from "cockpit";
import client from "../client";

import { StorageCard, new_card } from "../pages.jsx";
import { format_dialog } from "../block/format-dialog.jsx";
import { unlock } from "./actions.jsx";

const _ = cockpit.gettext;
Expand All @@ -35,7 +33,6 @@ export function make_locked_encrypted_data_card(next, block) {
props: { block },
actions: [
{ title: _("Unlock"), action: () => unlock(block) },
{ title: _("Format"), action: () => format_dialog(client, block.path), danger: true },
]
});
}
4 changes: 2 additions & 2 deletions pkg/storaged/drive/drive.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { HDDIcon, SSDIcon, MediaDriveIcon } from "../icons/gnome-icons.jsx";
import { StorageCard, StorageDescription, new_card, new_page } from "../pages.jsx";
import { block_name, drive_name, format_temperature, fmt_size_long, should_ignore } from "../utils.js";
import { make_block_page } from "../block/create-pages.jsx";
import { partitionable_block_actions } from "../partitions/actions.jsx";
import { partitionable_block_actions } from "../block/actions.jsx";

const _ = cockpit.gettext;

Expand Down Expand Up @@ -81,7 +81,7 @@ export function make_drive_page(parent, drive) {
job_path: drive.path,
component: DriveCard,
props: { drive },
actions: block.Size > 0 ? partitionable_block_actions(block) : [],
actions: partitionable_block_actions(block),
});

if (block.Size > 0) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/storaged/filesystem/filesystem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
import { StorageLink, StorageUsageBar, StorageSize } from "../storage-controls.jsx";
import { StorageCard, StorageDescription, new_card, useIsNarrow } from "../pages.jsx";

import { format_dialog } from "../block/format-dialog.jsx";
import { is_mounted, MountPoint, mount_point_text } from "./utils.jsx";
import { mounting_dialog } from "./mounting-dialog.jsx";
import { check_mismounted_fsys, MismountAlert } from "./mismounting.jsx";
Expand Down Expand Up @@ -106,7 +105,6 @@ export function make_filesystem_card(next, backing_block, content_block, fstab_c
primary: true,
action: () => mounting_dialog(client, content_block || backing_block, "mount"),
},
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
]
});
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/storaged/legacy-vdo/legacy-vdo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { StorageButton, StorageOnOff } from "../storage-controls.jsx";

import { StorageCard, new_page, new_card } from "../pages.jsx";
import { make_block_page } from "../block/create-pages.jsx";
import { block_actions } from "../block/actions.jsx";

import inotify_py from "inotify.py";
import vdo_monitor_py from "./vdo-monitor.py";
Expand Down Expand Up @@ -149,6 +150,7 @@ export function make_legacy_vdo_page(parent, vdo, backing_block, next_card) {
? { title: _("Stop"), action: stop }
: { title: _("Start"), action: () => vdo.start() }
),
...block_actions(block),
{ title: _("Delete"), action: delete_, danger: true }
],
});
Expand Down
2 changes: 2 additions & 0 deletions pkg/storaged/lvm2/block-logical-volume.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Flex, FlexItem } from "@patternfly/react-core/dist/esm/layouts/Flex/ind
import { StorageButton, StorageLink } from "../storage-controls.jsx";

import { check_unused_space, get_resize_info, grow_dialog, shrink_dialog } from "../block/resize.jsx";
import { block_actions } from "../block/actions.jsx";
import { StorageCard, StorageDescription, new_card, navigate_to_new_card_location, navigate_away_from_card } from "../pages.jsx";
import { block_name, fmt_size, get_active_usage, teardown_active_usage, reload_systemd } from "../utils.js";
import {
Expand Down Expand Up @@ -218,6 +219,7 @@ export function make_block_logical_volume_card(next, vgroup, lvol, block) {
},
lvm2_create_snapshot_action(lvol),
repair_action,
...block_actions(block),
{
title: _("Delete"),
action: () => lvol_delete(lvol, card),
Expand Down
2 changes: 0 additions & 2 deletions pkg/storaged/lvm2/physical-volume.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";

import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { format_dialog } from "../block/format-dialog.jsx";
import { std_lock_action } from "../crypto/actions.jsx";
import { StorageUsageBar } from "../storage-controls.jsx";

Expand All @@ -47,7 +46,6 @@ export function make_lvm2_physical_volume_card(next, backing_block, content_bloc
props: { backing_block, content_block },
actions: [
std_lock_action(backing_block, content_block),
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
]
});

Expand Down
2 changes: 0 additions & 2 deletions pkg/storaged/mdraid/mdraid-disk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";

import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { format_dialog } from "../block/format-dialog.jsx";
import { block_short_name, fmt_size, mdraid_name } from "../utils.js";
import { std_lock_action } from "../crypto/actions.jsx";

Expand All @@ -44,7 +43,6 @@ export function make_mdraid_disk_card(next, backing_block, content_block) {
props: { backing_block, content_block, mdraid },
actions: [
std_lock_action(backing_block, content_block),
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
]
});

Expand Down
20 changes: 9 additions & 11 deletions pkg/storaged/mdraid/mdraid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
init_active_usage_processes
} from "../dialog.jsx";

import { partitionable_block_actions } from "../partitions/actions.jsx";
import { partitionable_block_actions } from "../block/actions.jsx";

const _ = cockpit.gettext;

Expand Down Expand Up @@ -145,7 +145,7 @@ function start_stop_action(mdraid) {
// "Stop" is only in the card, to discourage stopping.

if (!running)
return { title: _("Start"), action: () => mdraid_start(mdraid), tag: "device" };
return { title: _("Start"), action: () => mdraid_start(mdraid) };
else
return null;
}
Expand Down Expand Up @@ -229,15 +229,13 @@ export function make_mdraid_page(parent, mdraid) {
excuse: add_excuse,
tag: "disks",
}),
].concat(
(block ? partitionable_block_actions(block, "device") : []).concat(
[
{
title: _("Delete"),
action: () => mdraid_delete(mdraid, block, mdraid_card),
danger: true,
},
])),
...partitionable_block_actions(block),
{
title: _("Delete"),
action: () => mdraid_delete(mdraid, block, mdraid_card),
danger: true,
},
],
});

if (!block) {
Expand Down
40 changes: 0 additions & 40 deletions pkg/storaged/partitions/actions.jsx

This file was deleted.

2 changes: 2 additions & 0 deletions pkg/storaged/partitions/partition.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
} from "../dialog.jsx";
import { block_name, fmt_size, get_active_usage, teardown_active_usage, reload_systemd } from "../utils.js";
import { check_unused_space, get_resize_info, free_space_after_part, grow_dialog, shrink_dialog } from "../block/resize.jsx";
import { block_actions } from "../block/actions.jsx";
import { StorageCard, StorageDescription, new_card, navigate_away_from_card } from "../pages.jsx";

const _ = cockpit.gettext;
Expand Down Expand Up @@ -100,6 +101,7 @@ export function make_partition_card(next, block) {
action: () => grow_dialog(client, block_part, info),
excuse: grow_excuse,
}),
...block_actions(block),
{
title: _("Delete"),
action: () => delete_partition(block, card),
Expand Down
2 changes: 0 additions & 2 deletions pkg/storaged/stratis/blockdev.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { CardBody } from "@patternfly/react-core/dist/esm/components/Card/index.
import { DescriptionList } from "@patternfly/react-core/dist/esm/components/DescriptionList/index.js";

import { StorageCard, StorageDescription, new_card, register_crossref } from "../pages.jsx";
import { format_dialog } from "../block/format-dialog.jsx";
import { fmt_size } from "../utils.js";
import { std_lock_action } from "../crypto/actions.jsx";

Expand All @@ -45,7 +44,6 @@ export function make_stratis_blockdev_card(next, backing_block, content_block) {
props: { backing_block, content_block, pool, stopped_pool },
actions: [
std_lock_action(backing_block, content_block),
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
]
});

Expand Down
2 changes: 0 additions & 2 deletions pkg/storaged/swap/swap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { DescriptionList } from "@patternfly/react-core/dist/esm/components/Desc
import { useEvent } from "hooks";

import { StorageCard, StorageDescription, new_card } from "../pages.jsx";
import { format_dialog } from "../block/format-dialog.jsx";
import {
fmt_size, decode_filename, encode_filename,
parse_options, unparse_options, extract_option,
Expand Down Expand Up @@ -97,7 +96,6 @@ export function make_swap_card(next, backing_block, content_block) {
(block_swap && !block_swap.Active
? { title: _("Start"), action: start }
: null),
{ title: _("Format"), action: () => format_dialog(client, backing_block.path), danger: true },
]
});
}
Expand Down

0 comments on commit efddee6

Please sign in to comment.