Skip to content

Commit 983b389

Browse files
committed
consoles: Allow control over scaling and resizing behavior
1 parent 3fef26c commit 983b389

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

src/components/vm/consoles/consoles.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const ConsoleCard = ({ state, vm, config, onAddErrorNotification, isExpan
136136
state={state.vncState}
137137
vm={vm}
138138
vnc={vnc}
139-
/>
139+
isExpanded={isExpanded} />
140140
);
141141
} else if (inactive_vnc) {
142142
body = (

src/components/vm/consoles/vnc.jsx

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ import { HelperText, HelperTextItem } from "@patternfly/react-core/dist/esm/comp
2929
import { TextInput } from "@patternfly/react-core/dist/esm/components/TextInput";
3030
import { InputGroup } from "@patternfly/react-core/dist/esm/components/InputGroup";
3131
import { EyeIcon, EyeSlashIcon, PendingIcon, HelpIcon } from "@patternfly/react-icons";
32+
import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core/dist/esm/components/ToggleGroup';
3233

3334
import {
3435
EmptyState, EmptyStateHeader, EmptyStateIcon, EmptyStateBody, EmptyStateFooter, EmptyStateActions
3536
} from "@patternfly/react-core/dist/esm/components/EmptyState";
3637
import { Split, SplitItem } from "@patternfly/react-core/dist/esm/layouts/Split/index.js";
3738

3839
import { KebabDropdown } from 'cockpit-components-dropdown.jsx';
39-
import { DropdownItem } from "@patternfly/react-core/dist/esm/components/Dropdown";
40+
import { DropdownItem, DropdownGroup } from "@patternfly/react-core/dist/esm/components/Dropdown";
4041

4142
import { Modal, ModalVariant } from "@patternfly/react-core/dist/esm/components/Modal";
4243
import { ModalError } from 'cockpit-components-inline-notification.jsx';
@@ -72,10 +73,13 @@ const Enum = {
7273

7374
export const useVncState = () => {
7475
const [connected, setConnected] = useState(true);
76+
const [sizeMode, setSizeMode] = useState(null);
7577

7678
return {
7779
connected,
78-
setConnected
80+
setConnected,
81+
sizeMode,
82+
setSizeMode,
7983
};
8084
};
8185

@@ -198,7 +202,7 @@ const VncEditModal = ({ vm, inactive_vnc }) => {
198202
);
199203
};
200204

201-
export const VncActiveActions = ({ state, vm, vnc, onAddErrorNotification }) => {
205+
export const VncActiveActions = ({ state, vm, vnc, isExpanded, onAddErrorNotification }) => {
202206
const renderDropdownItem = keyName => {
203207
return (
204208
<DropdownItem
@@ -242,11 +246,33 @@ export const VncActiveActions = ({ state, vm, vnc, onAddErrorNotification }) =>
242246
];
243247

244248
return (
245-
<KebabDropdown
246-
toggleButtonId="vnc-actions"
247-
position='right'
248-
dropdownItems={dropdownItems}
249-
/>
249+
<Split>
250+
<SplitItem>
251+
<KebabDropdown
252+
toggleButtonId="vnc-actions"
253+
position='right'
254+
dropdownItems={dropdownItems}
255+
/>
256+
</SplitItem>
257+
{ isExpanded &&
258+
<SplitItem>
259+
<ToggleGroup>
260+
<ToggleGroupItem
261+
text={_("No scaling or resizing")}
262+
isSelected={!state.sizeMode}
263+
onChange={() => state.setSizeMode(null)} />
264+
<ToggleGroupItem
265+
text={_("Local scaling")}
266+
isSelected={state.sizeMode == "local"}
267+
onChange={() => state.setSizeMode("local")} />
268+
<ToggleGroupItem
269+
text={_("Remote resizing")}
270+
isSelected={state.sizeMode == "remote"}
271+
onChange={() => state.setSizeMode("remote")} />
272+
</ToggleGroup>
273+
</SplitItem>
274+
}
275+
</Split>
250276
);
251277
};
252278

@@ -398,8 +424,8 @@ export class VncActive extends React.Component {
398424
onSecurityFailure={this.onSecurityFailure}
399425
textConnecting={_("Connecting")}
400426
consoleContainerId={isExpanded ? "vnc-display-container-expanded" : "vnc-display-container-minimized"}
401-
resizeSession
402-
scaleViewport
427+
scaleViewport={!isExpanded || state.sizeMode == "local"}
428+
resizeSession={!!isExpanded && state.sizeMode == "remote"}
403429
/>
404430
: <div className="pf-v5-c-console__vnc">
405431
<EmptyState>

0 commit comments

Comments
 (0)