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

Various fix/enhancement about Profiles #8726

Merged
merged 41 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4dedbbc
feat[core): Eugeny/tabby#7057 order recent profile
Clem-Fern Jul 20, 2023
d57757c
fix(core): Eugeny/tabby#8709 sort freeInputPattern by weight
Clem-Fern Jul 20, 2023
272b9ee
wip ref(core): update profileDefaults in view of Eugeny/tabby#3999
Clem-Fern Jul 22, 2023
ee4487a
Revert "wip ref(core): update profileDefaults in view of Eugeny/tabby…
Clem-Fern Jul 22, 2023
8a85fca
wip ref(core/profiles.service): add methods to interract with Provide…
Clem-Fern Jul 22, 2023
c1e03ed
wip ref(core/profiles.service): move out group managment from settings
Clem-Fern Jul 22, 2023
5763919
wip ref(core/profiles.service): add methods to manage ProfileGroup co…
Clem-Fern Jul 22, 2023
f0e2482
wip fix(core): group migration c1e03ed5321f2a0add06a7051008e6deffdb038c
Clem-Fern Jul 22, 2023
5ba6bfb
wip fix(core): getProfileGroups bad builtin profile filtering c1e03ed…
Clem-Fern Jul 22, 2023
4d14694
wip fix(core): getConfigProxyForProfile skipUserDefaults param never …
Clem-Fern Jul 22, 2023
21df033
lint
Clem-Fern Jul 22, 2023
1903ec5
wip ref(settings): move out group managment from settings
Clem-Fern Jul 23, 2023
8e9156e
wip ref(core): ProfileGroup avoid direct config interraction outside …
Clem-Fern Jul 23, 2023
ef040ee
wip fix(core): Cannot access 'ProfilesService' before initialization …
Clem-Fern Jul 23, 2023
48d4b8e
wip ref(core): Profile avoid direct config interraction outside of pr…
Clem-Fern Jul 23, 2023
b751e10
wip fix(core): deleteProfile & deleteGroupProfile 8e9156e2504edb90522…
Clem-Fern Jul 23, 2023
a0804cc
wip fix(settings): newProfile unresolve group name
Clem-Fern Jul 23, 2023
1c06a51
wip ref(core): Profile & ProfileGroup add creation methods in Profile…
Clem-Fern Jul 23, 2023
44c449b
wip ref(core): move group collapsed status into profileSettingsTab
Clem-Fern Aug 4, 2023
30936b7
wip fix(core): writeProfile avoid deleting profile fields one by one
Clem-Fern Aug 4, 2023
951c69b
wip ref(core): resolveProfileGroupName return groupId if no name found
Clem-Fern Aug 4, 2023
935c981
wip ref(core): getProfileGroups create non editable group for built-i…
Clem-Fern Aug 5, 2023
0ef24dd
wip ref(settings): profilesSettingsTab profile template no launchable
Clem-Fern Aug 5, 2023
695c5ba
feat(core/settings): Eugeny/tabby#3999 Allow groups to specify settin…
Clem-Fern Aug 11, 2023
c108476
ref(settings): editProfileModal component remove unused ConfigService
Clem-Fern Aug 12, 2023
f369b14
feat(settings): Eugeny/tabby#7265 add a button to reset global & grou…
Clem-Fern Aug 12, 2023
8adb9a6
Merge branch 'Eugeny:master' into profiles-rework
Clem-Fern Aug 13, 2023
21e38c8
ref(core/settings/serial/ssh/telnet): create ConnectableProfile & Con…
Clem-Fern Aug 14, 2023
7be6fca
Merge branch 'Eugeny:master' into profiles-rework
Clem-Fern Aug 14, 2023
ef6b8a4
feat(core/settings/serial/ssh/telnet): add clearServiceMessagesOnConn…
Clem-Fern Aug 14, 2023
5eeaef9
ref(settings/ssh): migrate and remove deprecated clearServiceMessages…
Clem-Fern Aug 14, 2023
d275238
Merge branch 'master' into profiles-rework
Clem-Fern Aug 14, 2023
d212825
fix: avoid error Uncaught (in promise) on modal dismiss
Clem-Fern Aug 15, 2023
a9c63b5
fix(selector): avoid error Uncaught (in promise) on modal dismiss (fi…
Clem-Fern Aug 15, 2023
7687972
ref ef6b8a4eaa1ce4cf0311649d009d1a8a3e66a71c
Clem-Fern Aug 18, 2023
49f9a10
ref: a9c63b53059c842e31b52d1226aec78c6372fcc3 bad promise rejection h…
Clem-Fern Aug 25, 2023
06859de
ref(core): profiles.services config saving should be the caller's res…
Clem-Fern Aug 25, 2023
5e5c808
ref(core): profiles.services optionnal options object argument
Clem-Fern Aug 25, 2023
0128013
ref(core): profiles.services deleteBulkProfiles filter with predicate…
Clem-Fern Aug 25, 2023
96eee51
cleanup saving
Eugeny Aug 25, 2023
eddb50b
fixed delete predicate
Eugeny Aug 25, 2023
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 changes: 1 addition & 1 deletion tabby-core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export { BootstrapData, PluginInfo, BOOTSTRAP_DATA } from './mainProcess'
export { HostWindowService } from './hostWindow'
export { HostAppService, Platform } from './hostApp'
export { FileProvider } from './fileProvider'
export { ProfileProvider, Profile, PartialProfile, ProfileSettingsComponent } from './profileProvider'
export { ProfileProvider, ConnectableProfileProvider, QuickConnectProfileProvider, Profile, ConnectableProfile, PartialProfile, ProfileSettingsComponent, ProfileGroup, PartialProfileGroup } from './profileProvider'
export { PromptModalComponent } from '../components/promptModal.component'
export * from './commands'

Expand Down
36 changes: 28 additions & 8 deletions tabby-core/src/api/profileProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export interface Profile {
isTemplate: boolean
}

export interface ConnectableProfile extends Profile {
clearServiceMessagesOnConnect: boolean
}

export type PartialProfile<T extends Profile> = Omit<Omit<Omit<{
[K in keyof T]?: T[K]
}, 'options'>, 'type'>, 'name'> & {
Expand All @@ -31,6 +35,21 @@ export type PartialProfile<T extends Profile> = Omit<Omit<Omit<{
}
}

export interface ProfileGroup {
id: string
name: string
profiles: PartialProfile<Profile>[]
defaults: any
editable: boolean
}

export type PartialProfileGroup<T extends ProfileGroup> = Omit<Omit<{
Eugeny marked this conversation as resolved.
Show resolved Hide resolved
[K in keyof T]?: T[K]
}, 'id'>, 'name'> & {
id: string
name: string
}

export interface ProfileSettingsComponent<P extends Profile> {
profile: P
save?: () => void
Expand All @@ -39,7 +58,6 @@ export interface ProfileSettingsComponent<P extends Profile> {
export abstract class ProfileProvider<P extends Profile> {
id: string
name: string
supportsQuickConnect = false
settingsComponent?: new (...args: any[]) => ProfileSettingsComponent<P>
configDefaults = {}

Expand All @@ -53,13 +71,15 @@ export abstract class ProfileProvider<P extends Profile> {

abstract getDescription (profile: PartialProfile<P>): string

quickConnect (query: string): PartialProfile<P>|null {
return null
}
deleteProfile (profile: P): void { }
}

intoQuickConnectString (profile: P): string|null {
return null
}
export abstract class ConnectableProfileProvider<P extends ConnectableProfile> extends ProfileProvider<P> {}

export abstract class QuickConnectProfileProvider<P extends ConnectableProfile> extends ConnectableProfileProvider<P> {

abstract quickConnect (query: string): PartialProfile<P>|null

abstract intoQuickConnectString (profile: P): string|null

deleteProfile (profile: P): void { }
}
2 changes: 1 addition & 1 deletion tabby-core/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class CoreCommandProvider extends CommandProvider {
}

async activate () {
const profile = await this.profilesService.showProfileSelector()
const profile = await this.profilesService.showProfileSelector().catch(() => null)
if (profile) {
this.profilesService.launchProfile(profile)
}
Expand Down
2 changes: 1 addition & 1 deletion tabby-core/src/components/selectorModal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class SelectorModalComponent<T> {
{ sort: true },
).search(f)

this.options.filter(x => x.freeInputPattern).forEach(freeOption => {
this.options.filter(x => x.freeInputPattern).sort(firstBy<SelectorOption<T>, number>(x => x.weight ?? 0)).forEach(freeOption => {
if (!this.filteredOptions.includes(freeOption)) {
this.filteredOptions.push(freeOption)
}
Expand Down
1 change: 1 addition & 0 deletions tabby-core/src/configDefaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ hotkeys:
profile-selectors:
__nonStructural: true
profiles: []
groups: []
profileDefaults:
__nonStructural: true
ssh:
Expand Down
6 changes: 1 addition & 5 deletions tabby-core/src/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core'
import { TranslateService } from '@ngx-translate/core'
import { ProfilesService } from './services/profiles.service'
import { HotkeyDescription, HotkeyProvider } from './api/hotkeyProvider'
import { PartialProfile, Profile } from './api'

/** @hidden */
@Injectable()
Expand Down Expand Up @@ -268,7 +267,7 @@ export class AppHotkeyProvider extends HotkeyProvider {
return [
...this.hotkeys,
...profiles.map(profile => ({
id: `profile.${AppHotkeyProvider.getProfileHotkeyName(profile)}`,
id: `profile.${ProfilesService.getProfileHotkeyName(profile)}`,
name: this.translate.instant('New tab: {profile}', { profile: profile.name }),
})),
...this.profilesService.getProviders().map(provider => ({
Expand All @@ -278,7 +277,4 @@ export class AppHotkeyProvider extends HotkeyProvider {
]
}

static getProfileHotkeyName (profile: PartialProfile<Profile>): string {
return (profile.id ?? profile.name).replace(/\./g, '-')
}
}
10 changes: 5 additions & 5 deletions tabby-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { FastHtmlBindDirective } from './directives/fastHtmlBind.directive'
import { DropZoneDirective } from './directives/dropZone.directive'
import { CdkAutoDropGroup } from './directives/cdkAutoDropGroup.directive'

import { Theme, CLIHandler, TabContextMenuItemProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider, PlatformService, FileProvider, ProfilesService, ProfileProvider, SelectorOption, Profile, SelectorService, CommandProvider } from './api'
import { Theme, CLIHandler, TabContextMenuItemProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider, PlatformService, FileProvider, ProfilesService, ProfileProvider, QuickConnectProfileProvider, SelectorOption, Profile, SelectorService, CommandProvider } from './api'

import { AppService } from './services/app.service'
import { ConfigService } from './services/config.service'
Expand Down Expand Up @@ -177,7 +177,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
if (hotkey.startsWith('profile.')) {
const id = hotkey.substring(hotkey.indexOf('.') + 1)
const profiles = await profilesService.getProfiles()
const profile = profiles.find(x => AppHotkeyProvider.getProfileHotkeyName(x) === id)
const profile = profiles.find(x => ProfilesService.getProfileHotkeyName(x) === id)
if (profile) {
profilesService.openNewTabForProfile(profile)
}
Expand All @@ -191,7 +191,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
this.showSelector(provider)
}
if (hotkey === 'command-selector') {
commands.showSelector()
commands.showSelector().catch(() => {return})
}

if (hotkey === 'profile-selector') {
Expand All @@ -214,7 +214,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
callback: () => this.profilesService.openNewTabForProfile(p),
}))

if (provider.supportsQuickConnect) {
if (provider instanceof QuickConnectProfileProvider) {
options.push({
name: this.translate.instant('Quick connect'),
freeInputPattern: this.translate.instant('Connect to "%s"...'),
Expand All @@ -229,7 +229,7 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
})
}

await this.selector.show(this.translate.instant('Select profile'), options)
await this.selector.show(this.translate.instant('Select profile'), options).catch(() => {return})
}

static forRoot (): ModuleWithProviders<AppModule> {
Expand Down
4 changes: 2 additions & 2 deletions tabby-core/src/services/commands.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ export class CommandService {
context.tab = tab.getFocusedTab() ?? undefined
}
const commands = await this.getCommands(context)
await this.selector.show(
return this.selector.show(
this.translate.instant('Commands'),
commands.map(c => ({
name: c.label,
callback: c.run,
description: c.sublabel,
icon: c.icon,
})),
)
).then(() => {return})
}
}
40 changes: 40 additions & 0 deletions tabby-core/src/services/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { PlatformService } from '../api/platform'
import { HostAppService } from '../api/hostApp'
import { Vault, VaultService } from './vault.service'
import { serializeFunction } from '../utils'
import { PartialProfileGroup, ProfileGroup } from '../api/profileProvider'
const deepmerge = require('deepmerge')

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
Expand Down Expand Up @@ -364,6 +365,45 @@ export class ConfigService {
}
config.version = 4
}
if (config.version < 5) {
const groups: PartialProfileGroup<ProfileGroup>[] = []
for (const p of config.profiles ?? []) {
if (!(p.group ?? '').trim()) {
continue
}

let group = groups.find(x => x.name === p.group)
if (!group) {
group = {
id: `${uuidv4()}`,
name: `${p.group}`,
}
groups.push(group)
}
p.group = group.id
}

const profileGroupCollapsed = JSON.parse(window.localStorage.profileGroupCollapsed ?? '{}')
for (const g of groups) {
if (profileGroupCollapsed[g.name]) {
const collapsed = profileGroupCollapsed[g.name]
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete profileGroupCollapsed[g.name]
profileGroupCollapsed[g.id] = collapsed
}
}
window.localStorage.profileGroupCollapsed = JSON.stringify(profileGroupCollapsed)

config.groups = groups
config.version = 5
}
if (config.version < 6) {
if (config.ssh.clearServiceMessagesOnConnect === false) {
config.profileDefaults.ssh.clearServiceMessagesOnConnect = false
delete config.ssh?.clearServiceMessagesOnConnect
}
config.version = 6
}
}

private async maybeDecryptConfig (store) {
Expand Down
5 changes: 3 additions & 2 deletions tabby-core/src/services/fileProviders.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export class FileProvidersService {
) { }

async selectAndStoreFile (description: string): Promise<string> {
const p = await this.selectProvider()
return p.selectAndStoreFile(description)
return this.selectProvider().then(p => {
Clem-Fern marked this conversation as resolved.
Show resolved Hide resolved
return p.selectAndStoreFile(description)
})
}

async retrieveFile (key: string): Promise<Buffer> {
Expand Down
Loading