Skip to content
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

Dont show system session for user #1917

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const App = () => {
const [loadingResources, setLoadingResources] = useState(true);
const [error, setError] = useState('');
const [systemSocketInactive, setSystemSocketInactive] = useState(false);
const [systemSocketAvailable, setSystemSocketAvailable] = useState(false);
const [virtualizationEnabled, setVirtualizationEnabled] = useState(true);
const [emptyStateIgnored, setEmptyStateIgnored] = useState(() => {
const ignored = localStorage.getItem('virtualization-disabled-ignored');
Expand All @@ -89,6 +90,8 @@ export const App = () => {
.filter(promise => promise.status === 'rejected')
.map(promise => promise.reason.message);
setError(errorMsgs.join(', '));
if (connectionName == "system")
setSystemSocketAvailable(true);
} catch (ex) {
// access denied is expected for unprivileged session
if (connectionName !== 'system' || superuser.allowed || ex.name !== 'org.freedesktop.DBus.Error.AccessDenied')
Expand Down Expand Up @@ -150,7 +153,7 @@ export const App = () => {
</Page>
);
} else return (
<AppActive error={error} />
<AppActive error={error} systemSocketAvailable={systemSocketAvailable} />
);
};

Expand Down Expand Up @@ -260,6 +263,7 @@ class AppActive extends React.Component {
unattendedSupported,
unattendedUserLogin,
virtInstallAvailable,
systemSocketAvailable: this.props.systemSocketAvailable,
};
const createVmAction = <CreateVmAction {...properties} mode='create' />;
const importDiskAction = <CreateVmAction {...properties} mode='import' />;
Expand Down
9 changes: 6 additions & 3 deletions src/components/create-vm-dialog/createVmDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ class CreateVmModal extends React.Component {
validate: false,
vmName: '',
suggestedVmName: '',
connectionName: LIBVIRT_SYSTEM_CONNECTION,
connectionName: this.props.systemSocketAvailable ? LIBVIRT_SYSTEM_CONNECTION : LIBVIRT_SESSION_CONNECTION,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

sourceType: defaultSourceType,
source: '',
os: undefined,
Expand Down Expand Up @@ -1334,12 +1334,13 @@ class CreateVmModal extends React.Component {

const detailsTab = (
<>
{this.props.systemSocketAvailable &&
<MachinesConnectionSelector
id='connection'
connectionName={this.state.connectionName}
onValueChanged={this.onValueChanged}
loggedUser={loggedUser}
showInfoHelper />
showInfoHelper />}
<SourceRow
connectionName={this.state.connectionName}
networks={networks.filter(network => network.connectionName == this.state.connectionName)}
Expand Down Expand Up @@ -1516,7 +1517,9 @@ export class CreateVmAction extends React.Component {
downloadOSSupported={this.props.downloadOSSupported}
unattendedSupported={this.props.unattendedSupported}
unattendedUserLogin={this.props.unattendedUserLogin}
loggedUser={this.props.systemInfo.loggedUser} />);
loggedUser={this.props.systemInfo.loggedUser}
systemSocketAvailable={this.props.systemSocketAvailable}
/>);
};

let testdata;
Expand Down
2 changes: 1 addition & 1 deletion test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ vnc_password= "{vnc_passwd}"
else:
b.wait_val("#memory-size", self.expected_memory_size)

if (self.connection):
if self.connection:
b.set_checked(f"#connectionName-{self.connection}", True)

if self.is_unattended or self.sourceType == "cloud":
Expand Down
12 changes: 10 additions & 2 deletions test/check-machines-lifecycle
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,16 @@ class TestMachinesLifecycle(machineslib.VirtualMachinesCase):
b.wait_in_text(".pf-v5-c-popover__body", message)
m.execute("virt-xml subVmTest1 --remove-device --watchdog 1 --update")

checkConnectionDescription("#import-existing-vm", "Ideal for server VMs")
checkConnectionDescription("#create-new-vm", "Good choice for desktop virtualization")
if superuser:
checkConnectionDescription("#import-existing-vm", "Ideal for server VMs")
checkConnectionDescription("#create-new-vm", "Good choice for desktop virtualization")
else:
b.click("#create-new-vm")
b.wait_visible("#create-vm-dialog")
b.wait_not_present("#connection")
b.click('#create-vm-dialog button:contains("Cancel")')
b.wait_not_present("#create-vm-dialog")

checkNeedsShutdownLabel("Watchdog")

b.wait_in_text("#vm-subVmTest1-system-state", "Running")
Expand Down