feat: New one-click Home Server, now in Labs. Launch your own self-hosted server instance with just 1 click from the Preferences window. (#2345)
* fix(desktop): add home server coming-soon message on windows platform * fix(desktop): typos and remove feature block * fix(desktop): instantiate home server only upon starting
This commit is contained in:
@@ -4,12 +4,13 @@ import {
|
||||
HomeServerManagerInterface,
|
||||
HomeServerEnvironmentConfiguration,
|
||||
} from '@web/Application/Device/DesktopSnjsExports'
|
||||
import { HomeServerInterface } from '@standardnotes/home-server'
|
||||
import { HomeServer, HomeServerInterface } from '@standardnotes/home-server'
|
||||
|
||||
import { WebContents } from 'electron'
|
||||
import { MessageToWebApp } from '../../Shared/IpcMessages'
|
||||
import { FilesManagerInterface } from '../File/FilesManagerInterface'
|
||||
import { HomeServerConfigurationFile } from './HomeServerConfigurationFile'
|
||||
import { isWindows } from '../Types/Platforms'
|
||||
|
||||
const os = require('os')
|
||||
|
||||
@@ -126,6 +127,8 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
}
|
||||
|
||||
async startHomeServer(): Promise<string | undefined> {
|
||||
this.doNotInstantiateHomeServerOnWindowsUntilItIsSupported()
|
||||
|
||||
if (!this.homeServer) {
|
||||
return
|
||||
}
|
||||
@@ -261,4 +264,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
|
||||
|
||||
return configuration
|
||||
}
|
||||
|
||||
private doNotInstantiateHomeServerOnWindowsUntilItIsSupported(): void {
|
||||
if (!isWindows() && !this.homeServer) {
|
||||
this.homeServer = new HomeServer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export enum InternalFeature {
|
||||
Vaults = 'vaults',
|
||||
HomeServer = 'home-server',
|
||||
}
|
||||
|
||||
@@ -1,10 +1,38 @@
|
||||
import { Subtitle, Text, Title } from '@/Components/Preferences/PreferencesComponents/Content'
|
||||
import { isWindowsPlatform } from '@standardnotes/ui-services'
|
||||
|
||||
import { useApplication } from '@/Components/ApplicationProvider'
|
||||
import { Pill, Subtitle, Text, Title } from '@/Components/Preferences/PreferencesComponents/Content'
|
||||
|
||||
import PreferencesPane from '../../PreferencesComponents/PreferencesPane'
|
||||
import PreferencesGroup from '../../PreferencesComponents/PreferencesGroup'
|
||||
import PreferencesSegment from '../../PreferencesComponents/PreferencesSegment'
|
||||
import HomeServerSettings from './HomeServerSettings'
|
||||
|
||||
const HomeServer = () => {
|
||||
const application = useApplication()
|
||||
|
||||
if (isWindowsPlatform(application.platform)) {
|
||||
return (
|
||||
<PreferencesPane>
|
||||
<PreferencesGroup>
|
||||
<PreferencesSegment>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-start">
|
||||
<Title>Home Server</Title>
|
||||
<Pill style={'success'}>Labs</Pill>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="mr-10 flex flex-col">
|
||||
<Subtitle>Windows support for home server is coming soon.</Subtitle>
|
||||
</div>
|
||||
</div>
|
||||
</PreferencesSegment>
|
||||
</PreferencesGroup>
|
||||
</PreferencesPane>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<PreferencesPane>
|
||||
<PreferencesGroup>
|
||||
|
||||
@@ -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 { featureTrunkHomeServerEnabled, featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
|
||||
interface PreferencesMenuItem {
|
||||
readonly id: PreferenceId
|
||||
@@ -47,7 +47,9 @@ const READY_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
|
||||
{ id: 'help-feedback', label: 'Help & feedback', icon: 'help', order: 11 },
|
||||
]
|
||||
|
||||
const DESKTOP_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = []
|
||||
const DESKTOP_PREFERENCES_MENU_ITEMS: PreferencesMenuItem[] = [
|
||||
{ id: 'home-server', label: 'Home Server', icon: 'server', order: 5 },
|
||||
]
|
||||
|
||||
export class PreferencesMenu {
|
||||
private _selectedPane: PreferenceId = 'account'
|
||||
@@ -60,10 +62,6 @@ 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()) {
|
||||
@@ -72,8 +70,6 @@ export class PreferencesMenu {
|
||||
|
||||
this._menu = menuItems.sort((a, b) => a.order - b.order)
|
||||
|
||||
this._menu = this._enableUnfinishedFeatures ? PREFERENCES_MENU_ITEMS : READY_PREFERENCES_MENU_ITEMS
|
||||
|
||||
this.loadLatestVersions()
|
||||
|
||||
makeAutoObservable<
|
||||
|
||||
@@ -11,7 +11,3 @@ 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