Skip to content

Add fullscreen mode as a more efficient operation way to view projects #34081

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

Open
wants to merge 6 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
2 changes: 2 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3844,6 +3844,8 @@ deleted.display_name = Deleted Project
type-1.display_name = Individual Project
type-2.display_name = Repository Project
type-3.display_name = Organization Project
enter_fullscreen = Fullscreen
exit_fullscreen = Exit Fullscreen

[git.filemode]
changed_filemode = %[1]s → %[2]s
Expand Down
4 changes: 2 additions & 2 deletions templates/org/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
{{template "user/overview/header" .}}
</div>
{{end}}
<div class="ui container fluid padded">
{{template "projects/view" .}}
<div class="ui container fluid padded org-projects-view">
{{template "projects/view" dict "." . "FullscreenElementsSelector" ".org-projects-view"}}
Copy link
Contributor

Choose a reason for hiding this comment

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

The old layout is not right, the new change makes things worse.

projects/view already has its own "ui container" and it could have a unified CSS class name.

</div>
</div>
{{template "base/footer" .}}
8 changes: 8 additions & 0 deletions templates/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
</div>
{{if $canWriteProject}}
<div class="ui compact mini menu">
<a class="item screen-full" data-fullscreen-elements-selector="{{.FullscreenElementsSelector}}">
{{svg "octicon-screen-full"}}
{{ctx.Locale.Tr "projects.enter_fullscreen"}}
</a>
<a class="item screen-normal tw-hidden">
{{svg "octicon-screen-normal"}}
{{ctx.Locale.Tr "projects.exit_fullscreen"}}
</a>
<a class="item" href="{{.Link}}/edit?redirect=project">
{{svg "octicon-pencil"}}
{{ctx.Locale.Tr "repo.issues.label_edit"}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<a class="ui small primary button" href="{{.RepoLink}}/issues/new/choose?project={{.Project.ID}}">{{ctx.Locale.Tr "repo.issues.new"}}</a>
</div>
</div>
<div class="ui container fluid padded">
{{template "projects/view" .}}
<div class="ui container fluid padded repo-projects-view">
{{template "projects/view" dict "." . "FullscreenElementsSelector" ".repo-projects-view"}}
</div>
</div>

Expand Down
20 changes: 20 additions & 0 deletions web_src/css/features/projects.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,23 @@
.card-ghost * {
opacity: 0;
}

.fullscreen.org-projects-view .ui.container,
.fullscreen.repo-projects-view .ui.container {
position: fixed;
z-index: 1000;
top: 0;
left: 0;
right: 0;
margin: 0 !important;
padding: .25rem;
width: 100%;
max-width: 100%;
background-color: var(--color-body);
}

.fullscreen #project-board {
position: absolute;
top: 75px;
left: 0;
}
17 changes: 2 additions & 15 deletions web_src/js/components/RepoActionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {formatDatetime} from '../utils/time.ts';
import {renderAnsi} from '../render/ansi.ts';
import {POST, DELETE} from '../modules/fetch.ts';
import type {IntervalId} from '../types.ts';
import {toggleFullScreen} from '../utils.ts';

// see "models/actions/status.go", if it needs to be used somewhere else, move it to a shared file like "types/actions.ts"
type RunStatus = 'unknown' | 'waiting' | 'running' | 'success' | 'failure' | 'cancelled' | 'skipped' | 'blocked';
Expand Down Expand Up @@ -416,21 +417,7 @@ export default defineComponent({

toggleFullScreen() {
this.isFullScreen = !this.isFullScreen;
const fullScreenEl = document.querySelector('.action-view-right');
const outerEl = document.querySelector('.full.height');
const actionBodyEl = document.querySelector('.action-view-body');
const headerEl = document.querySelector('#navbar');
const contentEl = document.querySelector('.page-content');
const footerEl = document.querySelector('.page-footer');
toggleElem(headerEl, !this.isFullScreen);
toggleElem(contentEl, !this.isFullScreen);
toggleElem(footerEl, !this.isFullScreen);
// move .action-view-right to new parent
if (this.isFullScreen) {
outerEl.append(fullScreenEl);
} else {
actionBodyEl.append(fullScreenEl);
}
toggleFullScreen('.action-view-right', this.isFullScreen, '.action-view-body');
},
async hashChangeListener() {
const selectedLogStep = window.location.hash;
Expand Down
22 changes: 21 additions & 1 deletion web_src/js/features/repo-projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import {contrastColor} from '../utils/color.ts';
import {createSortable} from '../modules/sortable.ts';
import {POST, request} from '../modules/fetch.ts';
import {fomanticQuery} from '../modules/fomantic/base.ts';
import {queryElemChildren, queryElems} from '../utils/dom.ts';
import {queryElemChildren, queryElems, toggleElem} from '../utils/dom.ts';
import type {SortableEvent} from 'sortablejs';
import {toggleFullScreen} from '../utils.ts';

function updateIssueCount(card: HTMLElement): void {
const parent = card.parentElement;
Expand Down Expand Up @@ -139,7 +140,26 @@ function initRepoProjectColumnEdit(writableProjectBoard: Element): void {
});
}

function initRepoProjectToggleFullScreen(): void {
const enterFullscreenBtn = document.querySelector('.screen-full');
const exitFullscreenBtn = document.querySelector('.screen-normal');
if (!enterFullscreenBtn || !exitFullscreenBtn) return;

const fullscreenElementsSelector = enterFullscreenBtn.getAttribute('data-fullscreen-elements-selector');

const toggleFullscreenState = (isFullScreen: boolean) => {
toggleFullScreen(fullscreenElementsSelector, isFullScreen);
toggleElem(enterFullscreenBtn);
toggleElem(exitFullscreenBtn);
};

enterFullscreenBtn.addEventListener('click', () => toggleFullscreenState(true));
exitFullscreenBtn.addEventListener('click', () => toggleFullscreenState(false));
}

export function initRepoProject(): void {
initRepoProjectToggleFullScreen();

const writableProjectBoard = document.querySelector('#project-board[data-project-borad-writable="true"]');
if (!writableProjectBoard) return;

Expand Down
22 changes: 22 additions & 0 deletions web_src/js/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {decode, encode} from 'uint8-to-base64';
import type {IssuePageInfo, IssuePathInfo, RepoOwnerPathInfo} from './types.ts';
import {toggleClass, toggleElem} from './utils/dom.ts';

// transform /path/to/file.ext to /path/to
export function dirname(path: string): string {
Expand Down Expand Up @@ -179,3 +180,24 @@ export function isImageFile({name, type}: {name?: string, type?: string}): boole
export function isVideoFile({name, type}: {name?: string, type?: string}): boolean {
return /\.(mpe?g|mp4|mkv|webm)$/i.test(name || '') || type?.startsWith('video/');
}

export function toggleFullScreen(fullscreenElementsSelector: string, isFullScreen: boolean, sourceParentSelector?: string): void {
// hide other elements
const headerEl = document.querySelector('#navbar');
const contentEl = document.querySelector('.page-content');
const footerEl = document.querySelector('.page-footer');
toggleElem(headerEl, !isFullScreen);
toggleElem(contentEl, !isFullScreen);
toggleElem(footerEl, !isFullScreen);

const sourceParentEl = sourceParentSelector ? document.querySelector(sourceParentSelector) : contentEl;

const fullScreenEls = document.querySelectorAll(fullscreenElementsSelector);
const outerEl = document.querySelector('.full.height');
toggleClass(fullscreenElementsSelector, 'fullscreen', isFullScreen);
if (isFullScreen) {
for (const e of fullScreenEls) outerEl.append(e);
} else {
for (const e of fullScreenEls) sourceParentEl.append(e);
}
}