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

Add user menu with About modal #35

Merged
merged 4 commits into from
Mar 13, 2023
Merged
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,720 changes: 2,018 additions & 702 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
"productName": "Nextcloud Talk",
"version": "0.1.0",
"description": "Official Desktop client for Nextcloud Talk",
"bugs": "https://github.com/nextcloud-gmbh/talk-desktop/issues",
"license": "AGPL-3.0",
"author": {
"name": "Grigorii Shartsev",
"email": "[email protected]"
},
"main": "./.webpack/main",
"repository": {
"type" : "git",
"url" : "https://github.com/nextcloud-gmbh/talk-desktop"
},
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
Expand All @@ -21,17 +31,12 @@
"generate-icons": "node ./img/generate-icons.js",
"lint": "eslint --ext .js,.vue src/ --fix"
},
"keywords": [],
"author": {
"name": "Grigorii Shartsev",
"email": "[email protected]"
},
"license": "agpl",
"dependencies": {
"@nextcloud/l10n": "^2.1.0",
"@nextcloud/vue": "^7.1.0-beta.1",
"@nextcloud/vue": "^7.8.0",
"core-js": "^3.26.1",
"electron-squirrel-startup": "^1.0.0",
"floating-vue": "^1.0.0-beta.19",
"vue": "^2.7.14",
"vue-material-design-icons": "^5.2.0"
},
Expand Down
3 changes: 1 addition & 2 deletions src/accounts/renderer/WindowAccounts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import { getCapabilities, getCurrentUserData } from '../../shared/ocs.service.js'
import { appData } from '../../app/AppData.js'
import { MIN_REQUIRED_NEXTCLOUD_VERSION, MIN_REQUIRED_TALK_VERSION } from '../../constants.js'
import packageJson from '../../../package.json'

export default {
name: 'WindowAccounts',
Expand All @@ -92,7 +91,7 @@ export default {

setup() {
return {
version: packageJson.version,
version: window.TALK_DESKTOP.packageInfo.version,
}
},

Expand Down
6 changes: 3 additions & 3 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const { version } = require('../package.json');
const packageJson = require('../package.json')

const BASE_TITLE = 'Nextcloud Talk'
const USER_AGENT = `Mozilla/5.0 (Desktop) Nextcloud-Talk v${version}`
const BASE_TITLE = packageJson.productName
const USER_AGENT = `Mozilla/5.0 (Desktop) Nextcloud-Talk v${packageJson.version}`
const DEV_SERVER_ORIGIN = 'http://localhost:3000'
const MIN_REQUIRED_NEXTCLOUD_VERSION = 26
const MIN_REQUIRED_TALK_VERSION = 16
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ const {
enableWebRequestInterceptor,
disableWebRequestInterceptor,
} = require('./app/webRequestInterceptor.js')
const { getOs } = require('./shared/os.utils.js')

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
// if (require('electron-squirrel-startup')) {
// app.quit();
// }

ipcMain.handle('app:getOs', () => getOs())
ipcMain.handle('app:enableWebRequestInterceptor', (event, ...args) => enableWebRequestInterceptor(...args))
ipcMain.handle('app:disableWebRequestInterceptor', (event, ...args) => disableWebRequestInterceptor(...args))

Expand Down
59 changes: 50 additions & 9 deletions src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,68 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const {
contextBridge,
ipcRenderer,
} = require('electron')

const packageJson = require('../package.json')
const packageInfo = {
productName: packageJson.productName,
version: packageJson.version,
description: packageJson.description,
bugs: packageJson.bugs,
license: packageJson.license,
author: packageJson.author,
repository: packageJson.repository.url,
}

/**
* @typedef TALK_DESKTOP
* @property {Function} openLoginWebView
* @property {Function} login
* @property {Function} logout
* @property {typeof import('./app/webRequestInterceptor').enableWebRequestInterceptor} enableWebRequestInterceptor
* @property {typeof import('./app/webRequestInterceptor').disableWebRequestInterceptor} disableWebRequestInterceptor
* @global
*/

/** @type {TALK_DESKTOP} */
const TALK_DESKTOP = {
/**
* Subset of package.json meta-data
*
* @type {typeof packageInfo} packageInfo
*/
packageInfo,
/**
* Get OS version and versions as flags
*
* @return {Promise<import('./shared/os.utils.js').OsVersion>}
*/
getOs: () => ipcRenderer.invoke('app:getOs'),
/**
* Enable web request intercepting
*
* @type {typeof import('./app/webRequestInterceptor').enableWebRequestInterceptor}
*/
enableWebRequestInterceptor: (...args) => ipcRenderer.invoke('app:enableWebRequestInterceptor', ...args),
/**
* Disable web request intercepting
*
* @type {typeof import('./app/webRequestInterceptor').disableWebRequestInterceptor}
*/
disableWebRequestInterceptor: (...args) => ipcRenderer.invoke('app:disableWebRequestInterceptor', ...args),
/**
* Open a web-view modal window with Nextcloud Server login page
*
* @param {string} server - Server URL
* @return {Promise<import('./accounts/login.service.js').Credentials|Error>}
*/
openLoginWebView: (server) => ipcRenderer.invoke('accounts:openLoginWebView', server),
/**
* Open main window after logging in
*
* @return {Promise<void>}
*/
login: () => ipcRenderer.invoke('accounts:login'),
/**
* Logout and open accounts window
*
* @return {Promise<void>}
*/
logout: () => ipcRenderer.invoke('accounts:logout'),
}

Expand Down
91 changes: 91 additions & 0 deletions src/shared/os.utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* @copyright Copyright (c) 2023 Grigorii Shartsev <[email protected]>
*
* @author Grigorii Shartsev <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const os = require('os')

/**
* Returns a string representing OS version
*
* @return {string} os version
* @example "Linux 5.15.0-53-generic (#59-Ubuntu SMP Mon Oct 17 18:53:30 UTC 2022)"
* @example "Darwin 22.3.0 (Darwin Kernel Version 22.3.0: Thu Jan 5 20:48:54 PST 2023; root:xnu-8792.81.2~2/RELEASE_ARM64_T6000)"
* @example "Windows_NT 10.0.22621 (Windows 10 Pro)"
*/
function getOsVersion() {
return `${os.type()} ${os.release()} (${os.version()})`
}

/**
* Is it Linux?
*
* @return {boolean}
*/
function isLinux() {
return os.type() === 'Linux'
}

/**
* Is it Mac?
*
* @return {boolean}
*/
function isMac() {
return os.type() === 'Darwin'
}

/**
* Is it Windows?
*
* @return {boolean}
*/
function isWindows() {
return os.type() === 'Windows_NT'
}

/**
* @typedef OsVersion
* @property {boolean} isLinux - Is Linux?
* @property {boolean} isMac - Is Mac?
* @property {boolean} isWindows - Is Windows?
* @property {string} version - Full string representation of OS version
*/

/**
* Get current OS version and versions as flags
*
* @return {OsVersion}
*/
function getOs() {
return {
isLinux: isLinux(),
isMac: isMac(),
isWindows: isWindows(),
version: getOsVersion(),
}
}

module.exports = {
getOsVersion,
isLinux,
isMac,
isWindows,
getOs,
}
Loading