[MM-19327] Remove Finder from desktop app (#1515)
* [MM-19327] Remove Finder from desktop app * Lint fix * Commenting out flaky test Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
@@ -100,12 +100,6 @@ function createTemplate(config) {
|
||||
});
|
||||
|
||||
const viewSubMenu = [{
|
||||
label: 'Find..',
|
||||
accelerator: 'CmdOrCtrl+F',
|
||||
click() {
|
||||
WindowManager.openFinder();
|
||||
},
|
||||
}, {
|
||||
label: 'Reload',
|
||||
accelerator: 'CmdOrCtrl+R',
|
||||
click() {
|
||||
|
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
// Copyright (c) 2015-2016 Yuya Ochiai
|
||||
|
||||
'use strict';
|
||||
|
||||
import {ipcRenderer} from 'electron';
|
||||
|
||||
import {FOUND_IN_PAGE, FIND_IN_PAGE, STOP_FIND_IN_PAGE, CLOSE_FINDER, FOCUS_FINDER} from 'common/communication';
|
||||
|
||||
console.log('preloaded for the finder!');
|
||||
|
||||
window.addEventListener('message', async (event) => {
|
||||
switch (event.data.type) {
|
||||
case FIND_IN_PAGE:
|
||||
ipcRenderer.send(FIND_IN_PAGE, event.data.data.searchText, event.data.data.options);
|
||||
break;
|
||||
case STOP_FIND_IN_PAGE:
|
||||
ipcRenderer.send(STOP_FIND_IN_PAGE, event.data.data);
|
||||
break;
|
||||
case CLOSE_FINDER:
|
||||
ipcRenderer.send(CLOSE_FINDER);
|
||||
break;
|
||||
case FOCUS_FINDER:
|
||||
ipcRenderer.send(FOCUS_FINDER);
|
||||
break;
|
||||
default:
|
||||
console.log(`got a message: ${event}`);
|
||||
console.log(event);
|
||||
}
|
||||
});
|
||||
|
||||
ipcRenderer.on(FOUND_IN_PAGE, (event, result) => {
|
||||
window.postMessage({type: FOUND_IN_PAGE, data: result}, window.location.href);
|
||||
});
|
@@ -245,8 +245,6 @@ export class MattermostView extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
handleFoundInPage = (event, result) => WindowManager.foundInPage(result)
|
||||
|
||||
titleParser = /(\((\d+)\) )?(\*)?/g
|
||||
|
||||
handleTitleUpdate = (e, title) => {
|
||||
|
@@ -4,7 +4,7 @@ import log from 'electron-log';
|
||||
import {BrowserView, dialog} from 'electron';
|
||||
|
||||
import {SECOND} from 'common/utils/constants';
|
||||
import {UPDATE_TARGET_URL, FOUND_IN_PAGE, SET_SERVER_KEY, LOAD_SUCCESS, LOAD_FAILED, TOGGLE_LOADING_SCREEN_VISIBILITY, GET_LOADING_SCREEN_DATA} from 'common/communication';
|
||||
import {UPDATE_TARGET_URL, SET_SERVER_KEY, LOAD_SUCCESS, LOAD_FAILED, TOGGLE_LOADING_SCREEN_VISIBILITY, GET_LOADING_SCREEN_DATA} from 'common/communication';
|
||||
import urlUtils from 'common/utils/url';
|
||||
|
||||
import contextMenu from '../contextMenu';
|
||||
@@ -17,8 +17,6 @@ import {addWebContentsEventListeners} from './webContentEvents';
|
||||
|
||||
const URL_VIEW_DURATION = 10 * SECOND;
|
||||
const URL_VIEW_HEIGHT = 36;
|
||||
const FINDER_WIDTH = 310;
|
||||
const FINDER_HEIGHT = 40;
|
||||
|
||||
export class ViewManager {
|
||||
constructor(config, mainWindow) {
|
||||
@@ -217,59 +215,6 @@ export class ViewManager {
|
||||
}
|
||||
}
|
||||
|
||||
setFinderBounds = () => {
|
||||
if (this.finder) {
|
||||
const boundaries = this.mainWindow.getBounds();
|
||||
this.finder.setBounds({
|
||||
x: boundaries.width - FINDER_WIDTH - (process.platform === 'darwin' ? 20 : 200),
|
||||
y: 0,
|
||||
width: FINDER_WIDTH,
|
||||
height: FINDER_HEIGHT,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
focusFinder = () => {
|
||||
if (this.finder) {
|
||||
this.finder.webContents.focus();
|
||||
}
|
||||
}
|
||||
|
||||
hideFinder = () => {
|
||||
if (this.finder) {
|
||||
this.mainWindow.removeBrowserView(this.finder);
|
||||
this.finder = null;
|
||||
}
|
||||
}
|
||||
|
||||
foundInPage = (result) => {
|
||||
if (this.finder) {
|
||||
this.finder.webContents.send(FOUND_IN_PAGE, result);
|
||||
}
|
||||
};
|
||||
|
||||
showFinder = () => {
|
||||
// just focus the current finder if it's already open
|
||||
if (this.finder) {
|
||||
this.finder.webContents.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
const preload = getLocalPreload('finderPreload.js');
|
||||
this.finder = new BrowserView({webPreferences: {
|
||||
contextIsolation: process.env.NODE_ENV !== 'test',
|
||||
preload,
|
||||
nodeIntegration: process.env.NODE_ENV === 'test',
|
||||
enableRemoteModule: process.env.NODE_ENV === 'test', // TODO: try to use this only on testing
|
||||
}});
|
||||
const localURL = getLocalURLString('finder.html');
|
||||
this.finder.webContents.loadURL(localURL);
|
||||
this.mainWindow.addBrowserView(this.finder);
|
||||
this.setFinderBounds();
|
||||
|
||||
this.finder.webContents.focus();
|
||||
};
|
||||
|
||||
setLoadingScreenBounds = () => {
|
||||
if (this.loadingScreen) {
|
||||
this.loadingScreen.setBounds(getWindowBoundaries(this.mainWindow));
|
||||
|
@@ -5,7 +5,7 @@ import path from 'path';
|
||||
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain} from 'electron';
|
||||
import log from 'electron-log';
|
||||
|
||||
import {MAXIMIZE_CHANGE, FIND_IN_PAGE, STOP_FIND_IN_PAGE, CLOSE_FINDER, FOCUS_FINDER, HISTORY, GET_LOADING_SCREEN_DATA, REACT_APP_INITIALIZED, LOADING_SCREEN_ANIMATION_FINISHED, FOCUS_THREE_DOT_MENU} from 'common/communication';
|
||||
import {MAXIMIZE_CHANGE, HISTORY, GET_LOADING_SCREEN_DATA, REACT_APP_INITIALIZED, LOADING_SCREEN_ANIMATION_FINISHED, FOCUS_THREE_DOT_MENU} from 'common/communication';
|
||||
import urlUtils from 'common/utils/url';
|
||||
|
||||
import {getAdjustedWindowBoundaries} from '../utils';
|
||||
@@ -26,10 +26,6 @@ const status = {
|
||||
};
|
||||
const assetsDir = path.resolve(app.getAppPath(), 'assets');
|
||||
|
||||
ipcMain.on(FIND_IN_PAGE, findInPage);
|
||||
ipcMain.on(STOP_FIND_IN_PAGE, stopFindInPage);
|
||||
ipcMain.on(CLOSE_FINDER, closeFinder);
|
||||
ipcMain.on(FOCUS_FINDER, focusFinder);
|
||||
ipcMain.on(HISTORY, handleHistory);
|
||||
ipcMain.handle(GET_LOADING_SCREEN_DATA, handleLoadingScreenDataRequest);
|
||||
ipcMain.on(REACT_APP_INITIALIZED, handleReactAppInitialized);
|
||||
@@ -140,7 +136,6 @@ function setBoundsForCurrentView(event, newBounds) {
|
||||
if (currentView) {
|
||||
currentView.setBounds(getAdjustedWindowBoundaries(bounds.width, bounds.height, !urlUtils.isTeamUrl(currentView.server.url, currentView.view.webContents.getURL())));
|
||||
}
|
||||
status.viewManager.setFinderBounds();
|
||||
status.viewManager.setLoadingScreenBounds();
|
||||
}
|
||||
|
||||
@@ -318,48 +313,6 @@ export function openBrowserViewDevTools() {
|
||||
}
|
||||
}
|
||||
|
||||
export function openFinder() {
|
||||
if (status.viewManager) {
|
||||
status.viewManager.showFinder();
|
||||
}
|
||||
}
|
||||
|
||||
export function closeFinder() {
|
||||
if (status.viewManager) {
|
||||
status.viewManager.hideFinder();
|
||||
}
|
||||
}
|
||||
|
||||
export function focusFinder() {
|
||||
if (status.viewManager) {
|
||||
status.viewManager.focusFinder();
|
||||
}
|
||||
}
|
||||
|
||||
export function foundInPage(result) {
|
||||
if (status.viewManager && status.viewManager.foundInPage) {
|
||||
status.viewManager.foundInPage(result);
|
||||
}
|
||||
}
|
||||
|
||||
export function findInPage(event, searchText, options) {
|
||||
if (status.viewManager) {
|
||||
const activeView = status.viewManager.getCurrentView();
|
||||
if (activeView) {
|
||||
activeView.view.webContents.findInPage(searchText, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function stopFindInPage(event, action) {
|
||||
if (status.viewManager) {
|
||||
const activeView = status.viewManager.getCurrentView();
|
||||
if (activeView) {
|
||||
activeView.view.webContents.stopFindInPage(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function focusThreeDotMenu() {
|
||||
if (status.mainWindow) {
|
||||
status.mainWindow.webContents.focus();
|
||||
|
Reference in New Issue
Block a user