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

[WIP] preferences: Add X button to preference pages. #1160

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions app/common/typed-ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export interface RendererMessage {
"update-realm-icon": (serverURL: string, iconURL: string) => void;
"update-realm-name": (serveRURL: string, realmName: string) => void;
"webview-reload": () => void;
"exit-settings": () => void;
zoomActualSize: () => void;
zoomIn: () => void;
zoomOut: () => void;
Expand Down
11 changes: 11 additions & 0 deletions app/renderer/css/preference.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ td:nth-child(odd) {
text-rendering: optimizeLegibility;
}

.exit-sign {
float: right;
position: relative;
top: 1px;
margin-left: 3px;
font-size: 2rem;
line-height: 1;
font-weight: 600;
cursor: pointer;
}

#content {
display: flex;
height: 100%;
Expand Down
16 changes: 16 additions & 0 deletions app/renderer/js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,22 @@ class ServerManagerView {
});
}

ipcRenderer.on("exit-settings", () => {
let lastActiveServerTabIndex = -1;

for (const tab of this.tabs) {
if (tab.props.role === "server") {
lastActiveServerTabIndex = tab.props.tabIndex;
}
}

console.log(typeof this.tabs[lastActiveServerTabIndex]);
if (lastActiveServerTabIndex >= 0) {
console.log("Tab to be focussed");
this.tabs[lastActiveServerTabIndex].webview.focus();
}
});

ipcRenderer.on(
"permission-request",
(
Expand Down
7 changes: 7 additions & 0 deletions app/renderer/js/pages/preference/base-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,10 @@ export function generateSelectHTML(
export function reloadApp(): void {
ipcRenderer.send("forward-message", "reload-viewer");
}

export function exitSettings(): void {
const exitButton = document.querySelector(".exit-sign")!;
exitButton.addEventListener("click", async () => {
ipcRenderer.send("forward-message", "exit-settings");
});
}
5 changes: 4 additions & 1 deletion app/renderer/js/pages/preference/connected-org-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as t from "../../../../common/translation-util";
import {ipcRenderer} from "../../typed-ipc-renderer";
import * as DomainUtil from "../../utils/domain-util";

import {reloadApp} from "./base-section";
import {exitSettings, reloadApp} from "./base-section";
import {initFindAccounts} from "./find-accounts";
import {initServerInfoForm} from "./server-info-form";

Expand All @@ -17,6 +17,7 @@ export function initConnectedOrgSection(props: ConnectedOrgSectionProps): void {
const servers = DomainUtil.getDomains();
props.$root.innerHTML = html`
<div class="settings-pane" id="server-settings-pane">
<span class="exit-sign">×</span>
<div class="page-title">${t.__("Connected organizations")}</div>
<div class="title" id="existing-servers">
${t.__("All the connected orgnizations will appear here.")}
Expand All @@ -32,6 +33,8 @@ export function initConnectedOrgSection(props: ConnectedOrgSectionProps): void {
</div>
`.html;

exitSettings();

const $serverInfoContainer = document.querySelector(
"#server-info-container",
)!;
Expand Down
8 changes: 7 additions & 1 deletion app/renderer/js/pages/preference/general-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import * as t from "../../../../common/translation-util";
import supportedLocales from "../../../../translations/supported-locales.json";
import {ipcRenderer} from "../../typed-ipc-renderer";

import {generateSelectHTML, generateSettingOption} from "./base-section";
import {
exitSettings,
generateSelectHTML,
generateSettingOption,
} from "./base-section";

const {app, dialog, session} = remote;
const currentBrowserWindow = remote.getCurrentWindow();
Expand All @@ -26,6 +30,7 @@ interface GeneralSectionProps {
export function initGeneralSection(props: GeneralSectionProps): void {
props.$root.innerHTML = html`
<div class="settings-pane">
<span class="exit-sign">×</span>
<div class="title">${t.__("Appearance")}</div>
<div id="appearance-option-settings" class="settings-card">
<div class="setting-row" id="tray-option">
Expand Down Expand Up @@ -211,6 +216,7 @@ export function initGeneralSection(props: GeneralSectionProps): void {
</div>
`.html;

exitSettings();
updateTrayOption();
updateBadgeOption();
updateSilentOption();
Expand Down
5 changes: 4 additions & 1 deletion app/renderer/js/pages/preference/network-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {html} from "../../../../common/html";
import * as t from "../../../../common/translation-util";
import {ipcRenderer} from "../../typed-ipc-renderer";

import {generateSettingOption} from "./base-section";
import {exitSettings, generateSettingOption} from "./base-section";

interface NetworkSectionProps {
$root: Element;
Expand All @@ -12,6 +12,7 @@ interface NetworkSectionProps {
export function initNetworkSection(props: NetworkSectionProps): void {
props.$root.innerHTML = html`
<div class="settings-pane">
<span class="exit-sign">×</span>
<div class="title">${t.__("Proxy")}</div>
<div id="appearance-option-settings" class="settings-card">
<div class="setting-row" id="use-system-settings">
Expand Down Expand Up @@ -55,6 +56,8 @@ export function initNetworkSection(props: NetworkSectionProps): void {
</div>
`.html;

exitSettings();

const $proxyPAC: HTMLInputElement = document.querySelector(
"#proxy-pac-option .setting-input-value",
)!;
Expand Down
5 changes: 5 additions & 0 deletions app/renderer/js/pages/preference/shortcuts-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {html} from "../../../../common/html";
import * as t from "../../../../common/translation-util";
import * as LinkUtil from "../../utils/link-util";

import {exitSettings} from "./base-section";

interface ShortcutsSectionProps {
$root: Element;
}
Expand All @@ -12,6 +14,7 @@ export function initShortcutsSection(props: ShortcutsSectionProps): void {

props.$root.innerHTML = html`
<div class="settings-pane">
<span class="exit-sign">×</span>
<div class="settings-card tip">
<p>
<b><i class="material-icons md-14">settings</i>${t.__("Tip")}: </b
Expand Down Expand Up @@ -222,6 +225,8 @@ export function initShortcutsSection(props: ShortcutsSectionProps): void {
</div>
`.html;

exitSettings();

const link = "https://zulip.com/help/keyboard-shortcuts";
const externalCreateNewOrgElement =
document.querySelector("#open-hotkeys-link")!;
Expand Down