-
{vm.name}
+ {vm.title ? vm.title + " (" + vm.name + ")" : vm.name}
+ { vm.description && {vm.description}
}
);
diff --git a/src/components/vm/vmRenameDialog.jsx b/src/components/vm/vmRenameDialog.jsx
index b9ab48619..0bff2231a 100644
--- a/src/components/vm/vmRenameDialog.jsx
+++ b/src/components/vm/vmRenameDialog.jsx
@@ -23,47 +23,57 @@ import { Button } from "@patternfly/react-core/dist/esm/components/Button";
import { Form, FormGroup } from "@patternfly/react-core/dist/esm/components/Form";
import { Modal } from "@patternfly/react-core/dist/esm/components/Modal";
import { TextInput } from "@patternfly/react-core/dist/esm/components/TextInput";
+import { TextArea } from "@patternfly/react-core/dist/esm/components/TextArea";
import { FormHelper } from 'cockpit-components-form-helper.jsx';
import { ModalError } from 'cockpit-components-inline-notification.jsx';
import { useDialogs } from 'dialogs.jsx';
import { isObjectEmpty } from '../../helpers.js';
-import { domainRename } from '../../libvirtApi/domain.js';
+import { domainRename, domainSetMetadata } from '../../libvirtApi/domain.js';
const _ = cockpit.gettext;
-export const RenameDialog = ({ vmName, vmId, connectionName }) => {
+export const RenameDialog = ({ vm }) => {
const Dialogs = useDialogs();
- const [newName, setNewName] = useState(vmName);
+ const [name, setName] = useState(vm.name);
+ const [fullName, setFullName] = useState(vm.title || "");
+ const [description, setDescription] = useState(vm.description || "");
const [error, dialogErrorSet] = useState({});
const [submitted, setSubmitted] = useState(false);
- function onRename() {
+ async function onRename() {
setSubmitted(true);
- if (!newName)
+ if (!name)
return;
- return domainRename({ connectionName, id: vmId, newName })
- .then(() => {
- Dialogs.close();
- // If we are on the VMs details page change the URL to reflect the new name after the rename operation succeeded
- if (cockpit.location.path.length > 0)
- cockpit.location.go(["vm"], { ...cockpit.location.options, name: newName, connection: connectionName });
- }, exc => {
- dialogErrorSet({ dialogError: cockpit.format(_("Failed to rename VM $0"), vmName), dialogErrorDetail: exc.message });
- });
+ try {
+ await domainSetMetadata(vm, { title: fullName, description });
+ if (name != vm.name)
+ await domainRename({ connectionName: vm.connectionName, id: vm.id, newName: name });
+ Dialogs.close();
+
+ // If we are on the VMs details page change the URL to
+ // reflect the new name after the rename operation
+ // succeeded
+ if (name != vm.name && cockpit.location.path.length > 0)
+ cockpit.location.go(["vm"], { ...cockpit.location.options, name, connection: vm.connectionName });
+ } catch (exc) {
+ dialogErrorSet({
+ dialogError: cockpit.format(_("Failed to rename VM $0"), vm.name),
+ dialogErrorDetail: exc.message
+ });
+ }
}
return (