Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3676 from torchiaf/fix/help-button-shortcut-3
Preferences, Help Shortcuts
- Loading branch information
Showing
12 changed files
with
100 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import { ipcRenderer } from 'electron'; | ||
import Vue from 'vue'; | ||
import Help from '@pkg/components/Help.vue'; | ||
export default Vue.extend({ | ||
name: 'preferences-help', | ||
components: { Help }, | ||
methods: { | ||
openUrl() { | ||
ipcRenderer.send('help/preferences/open-url'); | ||
}, | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<help @open:url="openUrl" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,49 @@ | ||
import { ipcRenderer } from '@pkg/utils/ipcRenderer'; | ||
import { parseDocsVersion } from '@pkg/utils/version'; | ||
|
||
const baseUrl = 'https://docs.rancherdesktop.io'; | ||
import { shell } from 'electron'; | ||
|
||
const paths: Record<string, string> = { | ||
Application: 'ui/preferences/application', | ||
'Application-behavior': 'ui/preferences/application#behavior', | ||
'Application-environment': 'ui/preferences/application#environment', | ||
'Virtual Machine': 'ui/preferences/virtual-machine', | ||
'Container Engine-general': 'ui/preferences/container-engine#general', | ||
'Container Engine-allowed-images': 'ui/preferences/container-engine#allowed-images', | ||
WSL: 'ui/preferences/wsl', | ||
Kubernetes: 'ui/preferences/kubernetes', | ||
}; | ||
import { TransientSettings } from '@pkg/config/transientSettings'; | ||
import { parseDocsVersion } from '@pkg/utils/version'; | ||
|
||
class HelpImpl { | ||
private version = 'next'; | ||
type Paths = Record<string, string>; | ||
|
||
constructor() { | ||
ipcRenderer.on('get-app-version', (_event, version) => { | ||
this.version = parseDocsVersion(version); | ||
}); | ||
class Url { | ||
private readonly baseUrl = 'https://docs.rancherdesktop.io'; | ||
private paths: Paths = {}; | ||
|
||
ipcRenderer.send('get-app-version'); | ||
constructor(paths: Paths) { | ||
this.paths = paths; | ||
} | ||
|
||
url(key: string | undefined): string { | ||
buildUrl(key: string | undefined, version: string): string { | ||
if (key) { | ||
return `${ baseUrl }/${ this.version }/${ paths[key] }`; | ||
const docsVersion = parseDocsVersion(version); | ||
|
||
return `${ this.baseUrl }/${ docsVersion }/${ this.paths[key] }`; | ||
} | ||
|
||
return ''; | ||
} | ||
} | ||
|
||
export const Help = new HelpImpl(); | ||
class PreferencesHelp { | ||
private readonly url = new Url({ | ||
Application: 'ui/preferences/application', | ||
'Application-behavior': 'ui/preferences/application#behavior', | ||
'Application-environment': 'ui/preferences/application#environment', | ||
'Virtual Machine': 'ui/preferences/virtual-machine', | ||
'Container Engine-general': 'ui/preferences/container-engine#general', | ||
'Container Engine-allowed-images': 'ui/preferences/container-engine#allowed-images', | ||
WSL: 'ui/preferences/wsl', | ||
Kubernetes: 'ui/preferences/kubernetes', | ||
}); | ||
|
||
openUrl(version: string): void { | ||
const { current, currentTabs } = TransientSettings.value.preferences.navItem; | ||
const tab = currentTabs[current] ? `-${ currentTabs[current] }` : ''; | ||
|
||
const url = this.url.buildUrl(`${ current }${ tab }`, version); | ||
|
||
shell.openExternal(url); | ||
} | ||
} | ||
|
||
export const Help = { preferences: new PreferencesHelp() }; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters