-
Notifications
You must be signed in to change notification settings - Fork 1.2k
shell: Show some pages in fullscreen #21670
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
Draft
mvollmer
wants to merge
1
commit into
cockpit-project:main
Choose a base branch
from
mvollmer:shell-fullscreen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Cockpit playground</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link href="fullscreen.css" type="text/css" rel="stylesheet" /> | ||
<script src="../base1/cockpit.js"></script> | ||
<script src="fullscreen.js"></script> | ||
</head> | ||
<body class="pf-v5-m-tabular-nums"> | ||
<div id="app" /> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* This file is part of Cockpit. | ||
* | ||
* Copyright (C) 2016 Red Hat, Inc. | ||
* | ||
* Cockpit is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 2.1 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Cockpit is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with Cockpit; If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import cockpit from "cockpit"; | ||
import React from "react"; | ||
import { createRoot, Container } from 'react-dom/client'; | ||
import { usePageLocation } from "hooks"; | ||
|
||
import '../lib/patternfly/patternfly-5-cockpit.scss'; | ||
|
||
import { Page, PageSection, Bullseye, Button } from '@patternfly/react-core'; | ||
|
||
import 'cockpit-dark-theme'; // once per page | ||
|
||
const FullscreenDemo = () => { | ||
const { path } = usePageLocation(); | ||
|
||
function go_fullscreen() { | ||
cockpit.location.go("/fullscreen"); | ||
} | ||
|
||
function go_halfscreen() { | ||
cockpit.location.go("/"); | ||
} | ||
|
||
return ( | ||
<Page> | ||
<PageSection> | ||
<Bullseye> | ||
{ (path[0] != "fullscreen") | ||
? <Button onClick={go_fullscreen}>Go fullscreen</Button> | ||
: <Button onClick={go_halfscreen}>Go back</Button> | ||
} | ||
</Bullseye> | ||
</PageSection> | ||
</Page> | ||
); | ||
}; | ||
|
||
function init_app(rootElement: Container) { | ||
const root = createRoot(rootElement); | ||
root.render(<FullscreenDemo />); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", function() { | ||
cockpit.transport.wait(function() { | ||
init_app(document.getElementById('app')!); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -585,6 +585,7 @@ export class ShellState extends EventEmitter<ShellStateEvents> { | |
current_manifest: Manifest | null = null; | ||
|
||
current_frame: ShellFrame | null = null; | ||
current_fullscreen: boolean | null = null; | ||
|
||
update() { | ||
if (!this.ready || this.problem) { | ||
|
@@ -642,6 +643,23 @@ export class ShellState extends EventEmitter<ShellStateEvents> { | |
this.current_manifest_item = item; | ||
this.current_manifest = compiled.find_path_manifest(location.path); | ||
|
||
this.current_fullscreen = false; | ||
if (this.current_manifest.fullscreen) { | ||
let fs = this.current_manifest.fullscreen; | ||
const path_prefix = location.path.split("/", 1)[0]; | ||
if (Array.isArray(fs)) | ||
fs = { "": fs }; | ||
for (const path_suffix in fs) { | ||
if ((path_suffix == "" && path_prefix == location.path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This added line is not executed by any test. |
||
|| (path_prefix + "/" + path_suffix == location.path)) { | ||
for (const hash_prefix of fs[path_suffix]) { | ||
if (this.current_location.hash.startsWith(hash_prefix)) | ||
this.current_fullscreen = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
let frame = null; | ||
if (location.path && (machine.state == "connected" || machine.state == "connecting")) | ||
frame = this.#ensure_frame(machine, location.path, location.hash, item.label); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.