chore: make home server internal feature
This commit is contained in:
@@ -23,11 +23,9 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
|
||||
private readonly LOGS_BUFFER_SIZE = 1000
|
||||
|
||||
constructor(
|
||||
private homeServer: HomeServerInterface,
|
||||
private webContents: WebContents,
|
||||
private filesManager: FilesManagerInterface,
|
||||
) {}
|
||||
private homeServer?: HomeServerInterface
|
||||
|
||||
constructor(private webContents: WebContents, private filesManager: FilesManagerInterface) {}
|
||||
|
||||
async getHomeServerUrl(): Promise<string | undefined> {
|
||||
const homeServerConfiguration = await this.getHomeServerConfigurationObject()
|
||||
@@ -39,7 +37,7 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
}
|
||||
|
||||
async isHomeServerRunning(): Promise<boolean> {
|
||||
return this.homeServer.isRunning()
|
||||
return this.homeServer?.isRunning() ?? false
|
||||
}
|
||||
|
||||
async getHomeServerLastErrorMessage(): Promise<string | undefined> {
|
||||
@@ -47,6 +45,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
}
|
||||
|
||||
async activatePremiumFeatures(username: string): Promise<string | undefined> {
|
||||
if (!this.homeServer) {
|
||||
return
|
||||
}
|
||||
|
||||
const result = await this.homeServer.activatePremiumFeatures(username)
|
||||
|
||||
if (result.isFailed()) {
|
||||
@@ -111,6 +113,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
}
|
||||
|
||||
async stopHomeServer(): Promise<string | undefined> {
|
||||
if (!this.homeServer) {
|
||||
return
|
||||
}
|
||||
|
||||
const result = await this.homeServer.stop()
|
||||
if (result.isFailed()) {
|
||||
return result.getError()
|
||||
@@ -120,6 +126,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
}
|
||||
|
||||
async startHomeServer(): Promise<string | undefined> {
|
||||
if (!this.homeServer) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
this.lastErrorMessage = undefined
|
||||
this.logs = []
|
||||
|
||||
@@ -25,7 +25,6 @@ import { handleTestMessage, send } from './Utils/Testing'
|
||||
import { isTesting, lowercaseDriveLetter } from './Utils/Utils'
|
||||
import { initializeZoomManager } from './ZoomManager'
|
||||
import { HomeServerManager } from './HomeServer/HomeServerManager'
|
||||
import { HomeServer } from '@standardnotes/home-server'
|
||||
import { FilesManager } from './File/FilesManager'
|
||||
import { DirectoryManager } from './Directory/DirectoryManager'
|
||||
|
||||
@@ -206,11 +205,11 @@ async function createWindowServices(window: Electron.BrowserWindow, appState: Ap
|
||||
const trayManager = createTrayManager(window, appState.store)
|
||||
const spellcheckerManager = createSpellcheckerManager(appState.store, window.webContents, appLocale)
|
||||
const mediaManager = new MediaManager()
|
||||
const homeServer = new HomeServer()
|
||||
|
||||
const filesManager = new FilesManager()
|
||||
const directoryManager = new DirectoryManager(filesManager)
|
||||
|
||||
const homeServerManager = new HomeServerManager(homeServer, window.webContents, filesManager)
|
||||
const homeServerManager = new HomeServerManager(window.webContents, filesManager)
|
||||
|
||||
if (isTesting()) {
|
||||
handleTestMessage(MessageType.SpellCheckerManager, () => spellcheckerManager)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export enum InternalFeature {
|
||||
Vaults = 'vaults',
|
||||
HomeServer = 'home-server',
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
||||
|
||||
### Features
|
||||
|
||||
* New one-click Home Server, now in Labs. Launch your own self-hosted server instance with just 1 click from the Preferences window. ([#2341](https://github.com/standardnotes/app/issues/2341)) ([96f4264](https://github.com/standardnotes/app/commit/96f42643a98586052bfb5262ca797fd029c1e925))
|
||||
**Note:** Version bump only for package @standardnotes/web
|
||||
|
||||
## [3.163.3](https://github.com/standardnotes/app/compare/@standardnotes/web@3.163.2...@standardnotes/web@3.163.3) (2023-07-02)
|
||||
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"version": "3.164.0",
|
||||
"title": "[3.164.0](https://github.com/standardnotes/app/compare/@standardnotes/web@3.163.3...@standardnotes/web@3.164.0) (2023-07-03)",
|
||||
"date": null,
|
||||
"body": "### Features\n\n* New one-click Home Server, now in Labs. Launch your own self-hosted server instance with just 1 click from the Preferences window. ([#2341](https://github.com/standardnotes/app/issues/2341)) ([96f4264](https://github.com/standardnotes/app/commit/96f42643a98586052bfb5262ca797fd029c1e925))",
|
||||
"parsed": {
|
||||
"_": [
|
||||
"New one-click Home Server, now in Labs. Launch your own self-hosted server instance with just 1 click from the Preferences window. (#2341) (96f4264)"
|
||||
],
|
||||
"Features": [
|
||||
"New one-click Home Server, now in Labs. Launch your own self-hosted server instance with just 1 click from the Preferences window. (#2341) (96f4264)"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.163.3",
|
||||
"title": "[3.163.3](https://github.com/standardnotes/app/compare/@standardnotes/web@3.163.2...@standardnotes/web@3.163.3) (2023-07-02)",
|
||||
|
||||
@@ -5,7 +5,7 @@ import { PackageProvider } from './Panes/General/Advanced/Packages/Provider/Pack
|
||||
import { securityPrefsHasBubble } from './Panes/Security/securityPrefsHasBubble'
|
||||
import { PreferenceId } from '@standardnotes/ui-services'
|
||||
import { isDesktopApplication } from '@/Utils'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import { featureTrunkHomeServerEnabled, featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
|
||||
interface PreferencesMenuItem {
|
||||
readonly id: PreferenceId
|
||||
@@ -47,9 +47,7 @@ const READY_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
|
||||
{ id: 'help-feedback', label: 'Help & feedback', icon: 'help', order: 11 },
|
||||
]
|
||||
|
||||
const DESKTOP_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
|
||||
{ id: 'home-server', label: 'Home Server', icon: 'server', order: 5 },
|
||||
]
|
||||
const DESKTOP_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = []
|
||||
|
||||
export class PreferencesMenu {
|
||||
private _selectedPane: PreferenceId = 'account'
|
||||
@@ -62,6 +60,10 @@ export class PreferencesMenu {
|
||||
READY_PREFERENCES_MENU_ITEMS.splice(3, 0, { id: 'vaults', label: 'Vaults', icon: 'safe-square', order: 5 })
|
||||
}
|
||||
|
||||
if (featureTrunkHomeServerEnabled()) {
|
||||
DESKTOP_PREFERENCES_MENU_ITEMS.push({ id: 'home-server', label: 'Home Server', icon: 'server', order: 5 })
|
||||
}
|
||||
|
||||
let menuItems = this._enableUnfinishedFeatures ? PREFERENCES_MENU_ITEMS : READY_PREFERENCES_MENU_ITEMS
|
||||
|
||||
if (isDesktopApplication()) {
|
||||
|
||||
@@ -11,3 +11,7 @@ export function featureTrunkEnabled(trunk: FeatureTrunkName): boolean {
|
||||
export function featureTrunkVaultsEnabled(): boolean {
|
||||
return InternalFeatureService.get().isFeatureEnabled(InternalFeature.Vaults)
|
||||
}
|
||||
|
||||
export function featureTrunkHomeServerEnabled(): boolean {
|
||||
return InternalFeatureService.get().isFeatureEnabled(InternalFeature.HomeServer)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user