reigncode-app 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +30 -0
- package/Dockerfile +21 -0
- package/README.md +51 -0
- package/bunfig.toml +3 -0
- package/create-effect-simplification-spec.md +515 -0
- package/e2e/AGENTS.md +226 -0
- package/e2e/actions.ts +1018 -0
- package/e2e/app/home.spec.ts +24 -0
- package/e2e/app/navigation.spec.ts +10 -0
- package/e2e/app/palette.spec.ts +20 -0
- package/e2e/app/server-default.spec.ts +58 -0
- package/e2e/app/session.spec.ts +16 -0
- package/e2e/app/titlebar-history.spec.ts +120 -0
- package/e2e/commands/input-focus.spec.ts +15 -0
- package/e2e/commands/panels.spec.ts +33 -0
- package/e2e/commands/tab-close.spec.ts +32 -0
- package/e2e/files/file-open.spec.ts +31 -0
- package/e2e/files/file-tree.spec.ts +56 -0
- package/e2e/files/file-viewer.spec.ts +156 -0
- package/e2e/fixtures.ts +154 -0
- package/e2e/models/model-picker.spec.ts +48 -0
- package/e2e/models/models-visibility.spec.ts +61 -0
- package/e2e/projects/project-edit.spec.ts +43 -0
- package/e2e/projects/projects-close.spec.ts +54 -0
- package/e2e/projects/projects-switch.spec.ts +116 -0
- package/e2e/projects/workspace-new-session.spec.ts +94 -0
- package/e2e/projects/workspaces.spec.ts +375 -0
- package/e2e/prompt/context.spec.ts +95 -0
- package/e2e/prompt/prompt-async.spec.ts +76 -0
- package/e2e/prompt/prompt-drop-file-uri.spec.ts +22 -0
- package/e2e/prompt/prompt-drop-file.spec.ts +30 -0
- package/e2e/prompt/prompt-history.spec.ts +184 -0
- package/e2e/prompt/prompt-mention.spec.ts +26 -0
- package/e2e/prompt/prompt-multiline.spec.ts +24 -0
- package/e2e/prompt/prompt-shell.spec.ts +62 -0
- package/e2e/prompt/prompt-slash-open.spec.ts +22 -0
- package/e2e/prompt/prompt-slash-share.spec.ts +64 -0
- package/e2e/prompt/prompt-slash-terminal.spec.ts +18 -0
- package/e2e/prompt/prompt.spec.ts +55 -0
- package/e2e/selectors.ts +75 -0
- package/e2e/session/session-child-navigation.spec.ts +37 -0
- package/e2e/session/session-composer-dock.spec.ts +530 -0
- package/e2e/session/session-model-persistence.spec.ts +359 -0
- package/e2e/session/session-review.spec.ts +426 -0
- package/e2e/session/session-undo-redo.spec.ts +233 -0
- package/e2e/session/session.spec.ts +174 -0
- package/e2e/settings/settings-keybinds.spec.ts +389 -0
- package/e2e/settings/settings-models.spec.ts +122 -0
- package/e2e/settings/settings-providers.spec.ts +136 -0
- package/e2e/settings/settings.spec.ts +519 -0
- package/e2e/sidebar/sidebar-popover-actions.spec.ts +118 -0
- package/e2e/sidebar/sidebar-session-links.spec.ts +30 -0
- package/e2e/sidebar/sidebar.spec.ts +40 -0
- package/e2e/status/status-popover.spec.ts +94 -0
- package/e2e/terminal/terminal-init.spec.ts +28 -0
- package/e2e/terminal/terminal-reconnect.spec.ts +46 -0
- package/e2e/terminal/terminal-tabs.spec.ts +168 -0
- package/e2e/terminal/terminal.spec.ts +18 -0
- package/e2e/thinking-level.spec.ts +25 -0
- package/e2e/tsconfig.json +9 -0
- package/e2e/utils.ts +63 -0
- package/happydom.ts +75 -0
- package/index.html +23 -0
- package/package.json +77 -0
- package/playwright.config.ts +45 -0
- package/public/_headers +17 -0
- package/public/oc-theme-preload.js +35 -0
- package/script/e2e-local.ts +180 -0
- package/src/addons/serialize.test.ts +319 -0
- package/src/addons/serialize.ts +634 -0
- package/src/app.tsx +308 -0
- package/src/components/debug-bar.tsx +443 -0
- package/src/components/dialog-connect-provider.tsx +617 -0
- package/src/components/dialog-custom-provider-form.ts +158 -0
- package/src/components/dialog-custom-provider.test.ts +80 -0
- package/src/components/dialog-custom-provider.tsx +329 -0
- package/src/components/dialog-edit-project.tsx +255 -0
- package/src/components/dialog-fork.tsx +108 -0
- package/src/components/dialog-manage-models.tsx +101 -0
- package/src/components/dialog-release-notes.tsx +144 -0
- package/src/components/dialog-select-directory.tsx +392 -0
- package/src/components/dialog-select-file.tsx +466 -0
- package/src/components/dialog-select-mcp.tsx +107 -0
- package/src/components/dialog-select-model-unpaid.tsx +137 -0
- package/src/components/dialog-select-model.tsx +220 -0
- package/src/components/dialog-select-provider.tsx +86 -0
- package/src/components/dialog-select-server.tsx +649 -0
- package/src/components/dialog-settings.tsx +73 -0
- package/src/components/file-tree.test.ts +78 -0
- package/src/components/file-tree.tsx +507 -0
- package/src/components/link.tsx +26 -0
- package/src/components/model-tooltip.tsx +91 -0
- package/src/components/prompt-input/attachments.test.ts +44 -0
- package/src/components/prompt-input/attachments.ts +201 -0
- package/src/components/prompt-input/build-request-parts.test.ts +312 -0
- package/src/components/prompt-input/build-request-parts.ts +175 -0
- package/src/components/prompt-input/context-items.tsx +88 -0
- package/src/components/prompt-input/drag-overlay.tsx +25 -0
- package/src/components/prompt-input/editor-dom.test.ts +99 -0
- package/src/components/prompt-input/editor-dom.ts +148 -0
- package/src/components/prompt-input/files.ts +66 -0
- package/src/components/prompt-input/history.test.ts +153 -0
- package/src/components/prompt-input/history.ts +256 -0
- package/src/components/prompt-input/image-attachments.tsx +58 -0
- package/src/components/prompt-input/paste.ts +24 -0
- package/src/components/prompt-input/placeholder.test.ts +48 -0
- package/src/components/prompt-input/placeholder.ts +15 -0
- package/src/components/prompt-input/slash-popover.tsx +141 -0
- package/src/components/prompt-input/submit.test.ts +346 -0
- package/src/components/prompt-input/submit.ts +579 -0
- package/src/components/prompt-input.tsx +1595 -0
- package/src/components/server/server-row.tsx +130 -0
- package/src/components/session/index.ts +5 -0
- package/src/components/session/session-context-breakdown.test.ts +61 -0
- package/src/components/session/session-context-breakdown.ts +132 -0
- package/src/components/session/session-context-format.ts +20 -0
- package/src/components/session/session-context-metrics.test.ts +101 -0
- package/src/components/session/session-context-metrics.ts +82 -0
- package/src/components/session/session-context-tab.tsx +339 -0
- package/src/components/session/session-header.tsx +486 -0
- package/src/components/session/session-new-view.tsx +91 -0
- package/src/components/session/session-sortable-tab.tsx +70 -0
- package/src/components/session/session-sortable-terminal-tab.tsx +193 -0
- package/src/components/session-context-usage.tsx +122 -0
- package/src/components/settings-general.tsx +585 -0
- package/src/components/settings-keybinds.tsx +453 -0
- package/src/components/settings-list.tsx +5 -0
- package/src/components/settings-models.tsx +137 -0
- package/src/components/settings-providers.tsx +251 -0
- package/src/components/status-popover.tsx +419 -0
- package/src/components/terminal.tsx +653 -0
- package/src/components/titlebar-history.test.ts +63 -0
- package/src/components/titlebar-history.ts +57 -0
- package/src/components/titlebar.tsx +312 -0
- package/src/constants/file-picker.ts +89 -0
- package/src/context/command-keybind.test.ts +69 -0
- package/src/context/command.test.ts +25 -0
- package/src/context/command.tsx +437 -0
- package/src/context/comments.test.ts +186 -0
- package/src/context/comments.tsx +243 -0
- package/src/context/file/content-cache.ts +88 -0
- package/src/context/file/path.test.ts +360 -0
- package/src/context/file/path.ts +151 -0
- package/src/context/file/tree-store.ts +170 -0
- package/src/context/file/types.ts +41 -0
- package/src/context/file/view-cache.ts +146 -0
- package/src/context/file/watcher.test.ts +149 -0
- package/src/context/file/watcher.ts +53 -0
- package/src/context/file-content-eviction-accounting.test.ts +65 -0
- package/src/context/file.tsx +280 -0
- package/src/context/global-sdk.tsx +232 -0
- package/src/context/global-sync/bootstrap.ts +206 -0
- package/src/context/global-sync/child-store.test.ts +38 -0
- package/src/context/global-sync/child-store.ts +281 -0
- package/src/context/global-sync/event-reducer.test.ts +552 -0
- package/src/context/global-sync/event-reducer.ts +359 -0
- package/src/context/global-sync/eviction.ts +28 -0
- package/src/context/global-sync/queue.ts +83 -0
- package/src/context/global-sync/session-cache.test.ts +102 -0
- package/src/context/global-sync/session-cache.ts +62 -0
- package/src/context/global-sync/session-load.ts +25 -0
- package/src/context/global-sync/session-prefetch.test.ts +96 -0
- package/src/context/global-sync/session-prefetch.ts +100 -0
- package/src/context/global-sync/session-trim.test.ts +59 -0
- package/src/context/global-sync/session-trim.ts +56 -0
- package/src/context/global-sync/types.ts +133 -0
- package/src/context/global-sync/utils.ts +25 -0
- package/src/context/global-sync.test.ts +122 -0
- package/src/context/global-sync.tsx +408 -0
- package/src/context/highlights.tsx +233 -0
- package/src/context/language.tsx +248 -0
- package/src/context/layout-scroll.test.ts +64 -0
- package/src/context/layout-scroll.ts +126 -0
- package/src/context/layout.test.ts +69 -0
- package/src/context/layout.tsx +937 -0
- package/src/context/local.tsx +422 -0
- package/src/context/model-variant.test.ts +86 -0
- package/src/context/model-variant.ts +52 -0
- package/src/context/models.tsx +163 -0
- package/src/context/notification.tsx +373 -0
- package/src/context/permission-auto-respond.test.ts +102 -0
- package/src/context/permission-auto-respond.ts +51 -0
- package/src/context/permission.tsx +277 -0
- package/src/context/platform.tsx +99 -0
- package/src/context/prompt.tsx +297 -0
- package/src/context/sdk.tsx +49 -0
- package/src/context/server.tsx +295 -0
- package/src/context/settings.tsx +241 -0
- package/src/context/sync-optimistic.test.ts +123 -0
- package/src/context/sync.tsx +618 -0
- package/src/context/terminal-title.ts +51 -0
- package/src/context/terminal.test.ts +82 -0
- package/src/context/terminal.tsx +437 -0
- package/src/entry.tsx +144 -0
- package/src/env.d.ts +18 -0
- package/src/hooks/use-providers.ts +44 -0
- package/src/i18n/ar.ts +855 -0
- package/src/i18n/br.ts +867 -0
- package/src/i18n/bs.ts +943 -0
- package/src/i18n/da.ts +937 -0
- package/src/i18n/de.ts +879 -0
- package/src/i18n/en.ts +948 -0
- package/src/i18n/es.ts +950 -0
- package/src/i18n/fr.ts +878 -0
- package/src/i18n/ja.ts +861 -0
- package/src/i18n/ko.ts +860 -0
- package/src/i18n/no.ts +944 -0
- package/src/i18n/parity.test.ts +32 -0
- package/src/i18n/pl.ts +865 -0
- package/src/i18n/ru.ts +946 -0
- package/src/i18n/th.ts +933 -0
- package/src/i18n/tr.ts +952 -0
- package/src/i18n/zh.ts +930 -0
- package/src/i18n/zht.ts +925 -0
- package/src/index.css +29 -0
- package/src/index.ts +6 -0
- package/src/pages/directory-layout.tsx +88 -0
- package/src/pages/error.tsx +327 -0
- package/src/pages/home.tsx +131 -0
- package/src/pages/layout/deep-links.ts +50 -0
- package/src/pages/layout/helpers.test.ts +211 -0
- package/src/pages/layout/helpers.ts +98 -0
- package/src/pages/layout/inline-editor.tsx +126 -0
- package/src/pages/layout/sidebar-items.tsx +437 -0
- package/src/pages/layout/sidebar-project.tsx +384 -0
- package/src/pages/layout/sidebar-shell.tsx +125 -0
- package/src/pages/layout/sidebar-workspace.tsx +504 -0
- package/src/pages/layout.tsx +2509 -0
- package/src/pages/session/composer/index.ts +2 -0
- package/src/pages/session/composer/session-composer-region.tsx +255 -0
- package/src/pages/session/composer/session-composer-state.test.ts +128 -0
- package/src/pages/session/composer/session-composer-state.ts +249 -0
- package/src/pages/session/composer/session-followup-dock.tsx +109 -0
- package/src/pages/session/composer/session-permission-dock.tsx +74 -0
- package/src/pages/session/composer/session-question-dock.tsx +449 -0
- package/src/pages/session/composer/session-request-tree.ts +52 -0
- package/src/pages/session/composer/session-revert-dock.tsx +99 -0
- package/src/pages/session/composer/session-todo-dock.tsx +330 -0
- package/src/pages/session/file-tab-scroll.test.ts +40 -0
- package/src/pages/session/file-tab-scroll.ts +67 -0
- package/src/pages/session/file-tabs.tsx +456 -0
- package/src/pages/session/handoff.ts +36 -0
- package/src/pages/session/helpers.test.ts +181 -0
- package/src/pages/session/helpers.ts +198 -0
- package/src/pages/session/message-gesture.test.ts +62 -0
- package/src/pages/session/message-gesture.ts +21 -0
- package/src/pages/session/message-id-from-hash.ts +6 -0
- package/src/pages/session/message-timeline.tsx +1013 -0
- package/src/pages/session/review-tab.tsx +170 -0
- package/src/pages/session/session-layout.ts +20 -0
- package/src/pages/session/session-model-helpers.test.ts +51 -0
- package/src/pages/session/session-model-helpers.ts +16 -0
- package/src/pages/session/session-side-panel.tsx +453 -0
- package/src/pages/session/terminal-label.ts +16 -0
- package/src/pages/session/terminal-panel.test.ts +25 -0
- package/src/pages/session/terminal-panel.tsx +326 -0
- package/src/pages/session/use-session-commands.tsx +495 -0
- package/src/pages/session/use-session-hash-scroll.test.ts +16 -0
- package/src/pages/session/use-session-hash-scroll.ts +197 -0
- package/src/pages/session.tsx +1841 -0
- package/src/sst-env.d.ts +12 -0
- package/src/testing/model-selection.ts +80 -0
- package/src/testing/prompt.ts +56 -0
- package/src/testing/session-composer.ts +84 -0
- package/src/testing/terminal.ts +118 -0
- package/src/theme-preload.test.ts +46 -0
- package/src/utils/agent.ts +23 -0
- package/src/utils/aim.ts +138 -0
- package/src/utils/base64.ts +10 -0
- package/src/utils/comment-note.ts +88 -0
- package/src/utils/id.ts +99 -0
- package/src/utils/notification-click.test.ts +27 -0
- package/src/utils/notification-click.ts +13 -0
- package/src/utils/persist.test.ts +115 -0
- package/src/utils/persist.ts +476 -0
- package/src/utils/prompt.test.ts +44 -0
- package/src/utils/prompt.ts +203 -0
- package/src/utils/runtime-adapters.test.ts +62 -0
- package/src/utils/runtime-adapters.ts +39 -0
- package/src/utils/same.ts +6 -0
- package/src/utils/scoped-cache.test.ts +69 -0
- package/src/utils/scoped-cache.ts +104 -0
- package/src/utils/server-errors.test.ts +131 -0
- package/src/utils/server-errors.ts +80 -0
- package/src/utils/server-health.test.ts +123 -0
- package/src/utils/server-health.ts +91 -0
- package/src/utils/server.ts +22 -0
- package/src/utils/solid-dnd.tsx +49 -0
- package/src/utils/sound.ts +117 -0
- package/src/utils/terminal-writer.test.ts +64 -0
- package/src/utils/terminal-writer.ts +65 -0
- package/src/utils/time.ts +22 -0
- package/src/utils/uuid.test.ts +78 -0
- package/src/utils/uuid.ts +12 -0
- package/src/utils/worktree.test.ts +46 -0
- package/src/utils/worktree.ts +73 -0
- package/sst-env.d.ts +10 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +15 -0
- package/vite.js +26 -0
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
import { Button } from "@reign-labs/ui/button"
|
|
2
|
+
import { useDialog } from "@reign-labs/ui/context/dialog"
|
|
3
|
+
import { Dialog } from "@reign-labs/ui/dialog"
|
|
4
|
+
import { DropdownMenu } from "@reign-labs/ui/dropdown-menu"
|
|
5
|
+
import { Icon } from "@reign-labs/ui/icon"
|
|
6
|
+
import { IconButton } from "@reign-labs/ui/icon-button"
|
|
7
|
+
import { List } from "@reign-labs/ui/list"
|
|
8
|
+
import { TextField } from "@reign-labs/ui/text-field"
|
|
9
|
+
import { useMutation } from "@tanstack/solid-query"
|
|
10
|
+
import { showToast } from "@reign-labs/ui/toast"
|
|
11
|
+
import { useNavigate } from "@solidjs/router"
|
|
12
|
+
import { createEffect, createMemo, createResource, onCleanup, Show } from "solid-js"
|
|
13
|
+
import { createStore, reconcile } from "solid-js/store"
|
|
14
|
+
import { ServerHealthIndicator, ServerRow } from "@/components/server/server-row"
|
|
15
|
+
import { useLanguage } from "@/context/language"
|
|
16
|
+
import { usePlatform } from "@/context/platform"
|
|
17
|
+
import { normalizeServerUrl, ServerConnection, useServer } from "@/context/server"
|
|
18
|
+
import { type ServerHealth, useCheckServerHealth } from "@/utils/server-health"
|
|
19
|
+
|
|
20
|
+
const DEFAULT_USERNAME = "opencode"
|
|
21
|
+
|
|
22
|
+
interface ServerFormProps {
|
|
23
|
+
value: string
|
|
24
|
+
name: string
|
|
25
|
+
username: string
|
|
26
|
+
password: string
|
|
27
|
+
placeholder: string
|
|
28
|
+
busy: boolean
|
|
29
|
+
error: string
|
|
30
|
+
status: boolean | undefined
|
|
31
|
+
onChange: (value: string) => void
|
|
32
|
+
onNameChange: (value: string) => void
|
|
33
|
+
onUsernameChange: (value: string) => void
|
|
34
|
+
onPasswordChange: (value: string) => void
|
|
35
|
+
onSubmit: () => void
|
|
36
|
+
onBack: () => void
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function showRequestError(language: ReturnType<typeof useLanguage>, err: unknown) {
|
|
40
|
+
showToast({
|
|
41
|
+
variant: "error",
|
|
42
|
+
title: language.t("common.requestFailed"),
|
|
43
|
+
description: err instanceof Error ? err.message : String(err),
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function useDefaultServer() {
|
|
48
|
+
const language = useLanguage()
|
|
49
|
+
const platform = usePlatform()
|
|
50
|
+
const [defaultKey, defaultUrlActions] = createResource(
|
|
51
|
+
async () => {
|
|
52
|
+
try {
|
|
53
|
+
const key = await platform.getDefaultServer?.()
|
|
54
|
+
if (!key) return null
|
|
55
|
+
return key
|
|
56
|
+
} catch (err) {
|
|
57
|
+
showRequestError(language, err)
|
|
58
|
+
return null
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{ initialValue: null },
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const canDefault = createMemo(() => !!platform.getDefaultServer && !!platform.setDefaultServer)
|
|
65
|
+
const setDefault = async (key: ServerConnection.Key | null) => {
|
|
66
|
+
try {
|
|
67
|
+
await platform.setDefaultServer?.(key)
|
|
68
|
+
defaultUrlActions.mutate(key)
|
|
69
|
+
} catch (err) {
|
|
70
|
+
showRequestError(language, err)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return { defaultKey, canDefault, setDefault }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function useServerPreview() {
|
|
78
|
+
const checkServerHealth = useCheckServerHealth()
|
|
79
|
+
|
|
80
|
+
const looksComplete = (value: string) => {
|
|
81
|
+
const normalized = normalizeServerUrl(value)
|
|
82
|
+
if (!normalized) return false
|
|
83
|
+
const host = normalized.replace(/^https?:\/\//, "").split("/")[0]
|
|
84
|
+
if (!host) return false
|
|
85
|
+
if (host.includes("localhost") || host.startsWith("127.0.0.1")) return true
|
|
86
|
+
return host.includes(".") || host.includes(":")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const previewStatus = async (
|
|
90
|
+
value: string,
|
|
91
|
+
username: string,
|
|
92
|
+
password: string,
|
|
93
|
+
setStatus: (value: boolean | undefined) => void,
|
|
94
|
+
) => {
|
|
95
|
+
setStatus(undefined)
|
|
96
|
+
if (!looksComplete(value)) return
|
|
97
|
+
const normalized = normalizeServerUrl(value)
|
|
98
|
+
if (!normalized) return
|
|
99
|
+
const http: ServerConnection.HttpBase = { url: normalized }
|
|
100
|
+
if (username) http.username = username
|
|
101
|
+
if (password) http.password = password
|
|
102
|
+
const result = await checkServerHealth(http)
|
|
103
|
+
setStatus(result.healthy)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return { previewStatus }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function ServerForm(props: ServerFormProps) {
|
|
110
|
+
const language = useLanguage()
|
|
111
|
+
const keyDown = (event: KeyboardEvent) => {
|
|
112
|
+
event.stopPropagation()
|
|
113
|
+
if (event.key === "Escape") {
|
|
114
|
+
event.preventDefault()
|
|
115
|
+
props.onBack()
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
if (event.key !== "Enter" || event.isComposing) return
|
|
119
|
+
event.preventDefault()
|
|
120
|
+
props.onSubmit()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div class="px-5">
|
|
125
|
+
<div class="bg-surface-base rounded-md p-5 flex flex-col gap-3">
|
|
126
|
+
<div class="flex-1 min-w-0 [&_[data-slot=input-wrapper]]:relative">
|
|
127
|
+
<TextField
|
|
128
|
+
type="text"
|
|
129
|
+
label={language.t("dialog.server.add.url")}
|
|
130
|
+
placeholder={props.placeholder}
|
|
131
|
+
value={props.value}
|
|
132
|
+
autofocus
|
|
133
|
+
validationState={props.error ? "invalid" : "valid"}
|
|
134
|
+
error={props.error}
|
|
135
|
+
disabled={props.busy}
|
|
136
|
+
onChange={props.onChange}
|
|
137
|
+
onKeyDown={keyDown}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
<TextField
|
|
141
|
+
type="text"
|
|
142
|
+
label={language.t("dialog.server.add.name")}
|
|
143
|
+
placeholder={language.t("dialog.server.add.namePlaceholder")}
|
|
144
|
+
value={props.name}
|
|
145
|
+
disabled={props.busy}
|
|
146
|
+
onChange={props.onNameChange}
|
|
147
|
+
onKeyDown={keyDown}
|
|
148
|
+
/>
|
|
149
|
+
<div class="grid grid-cols-2 gap-2 min-w-0">
|
|
150
|
+
<TextField
|
|
151
|
+
type="text"
|
|
152
|
+
label={language.t("dialog.server.add.username")}
|
|
153
|
+
placeholder={language.t("dialog.server.add.usernamePlaceholder")}
|
|
154
|
+
value={props.username}
|
|
155
|
+
disabled={props.busy}
|
|
156
|
+
onChange={props.onUsernameChange}
|
|
157
|
+
onKeyDown={keyDown}
|
|
158
|
+
/>
|
|
159
|
+
<TextField
|
|
160
|
+
type="password"
|
|
161
|
+
label={language.t("dialog.server.add.password")}
|
|
162
|
+
placeholder={language.t("dialog.server.add.passwordPlaceholder")}
|
|
163
|
+
value={props.password}
|
|
164
|
+
disabled={props.busy}
|
|
165
|
+
onChange={props.onPasswordChange}
|
|
166
|
+
onKeyDown={keyDown}
|
|
167
|
+
/>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function DialogSelectServer() {
|
|
175
|
+
const navigate = useNavigate()
|
|
176
|
+
const dialog = useDialog()
|
|
177
|
+
const server = useServer()
|
|
178
|
+
const platform = usePlatform()
|
|
179
|
+
const language = useLanguage()
|
|
180
|
+
const { defaultKey, canDefault, setDefault } = useDefaultServer()
|
|
181
|
+
const { previewStatus } = useServerPreview()
|
|
182
|
+
const checkServerHealth = useCheckServerHealth()
|
|
183
|
+
const [store, setStore] = createStore({
|
|
184
|
+
status: {} as Record<ServerConnection.Key, ServerHealth | undefined>,
|
|
185
|
+
addServer: {
|
|
186
|
+
url: "",
|
|
187
|
+
name: "",
|
|
188
|
+
username: DEFAULT_USERNAME,
|
|
189
|
+
password: "",
|
|
190
|
+
error: "",
|
|
191
|
+
showForm: false,
|
|
192
|
+
status: undefined as boolean | undefined,
|
|
193
|
+
},
|
|
194
|
+
editServer: {
|
|
195
|
+
id: undefined as string | undefined,
|
|
196
|
+
value: "",
|
|
197
|
+
name: "",
|
|
198
|
+
username: "",
|
|
199
|
+
password: "",
|
|
200
|
+
error: "",
|
|
201
|
+
status: undefined as boolean | undefined,
|
|
202
|
+
},
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
const resetAdd = () => {
|
|
206
|
+
setStore("addServer", {
|
|
207
|
+
url: "",
|
|
208
|
+
name: "",
|
|
209
|
+
username: DEFAULT_USERNAME,
|
|
210
|
+
password: "",
|
|
211
|
+
error: "",
|
|
212
|
+
showForm: false,
|
|
213
|
+
status: undefined,
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
const resetEdit = () => {
|
|
217
|
+
setStore("editServer", {
|
|
218
|
+
id: undefined,
|
|
219
|
+
value: "",
|
|
220
|
+
name: "",
|
|
221
|
+
username: "",
|
|
222
|
+
password: "",
|
|
223
|
+
error: "",
|
|
224
|
+
status: undefined,
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const addMutation = useMutation(() => ({
|
|
229
|
+
mutationFn: async (value: string) => {
|
|
230
|
+
const normalized = normalizeServerUrl(value)
|
|
231
|
+
if (!normalized) {
|
|
232
|
+
resetAdd()
|
|
233
|
+
return
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const conn: ServerConnection.Http = {
|
|
237
|
+
type: "http",
|
|
238
|
+
http: { url: normalized },
|
|
239
|
+
}
|
|
240
|
+
if (store.addServer.name.trim()) conn.displayName = store.addServer.name.trim()
|
|
241
|
+
if (store.addServer.password) conn.http.password = store.addServer.password
|
|
242
|
+
if (store.addServer.password && store.addServer.username) conn.http.username = store.addServer.username
|
|
243
|
+
const result = await checkServerHealth(conn.http)
|
|
244
|
+
if (!result.healthy) {
|
|
245
|
+
setStore("addServer", { error: language.t("dialog.server.add.error") })
|
|
246
|
+
return
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
resetAdd()
|
|
250
|
+
await select(conn, true)
|
|
251
|
+
},
|
|
252
|
+
}))
|
|
253
|
+
|
|
254
|
+
const editMutation = useMutation(() => ({
|
|
255
|
+
mutationFn: async (input: { original: ServerConnection.Any; value: string }) => {
|
|
256
|
+
if (input.original.type !== "http") return
|
|
257
|
+
const normalized = normalizeServerUrl(input.value)
|
|
258
|
+
if (!normalized) {
|
|
259
|
+
resetEdit()
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const name = store.editServer.name.trim() || undefined
|
|
264
|
+
const username = store.editServer.username || undefined
|
|
265
|
+
const password = store.editServer.password || undefined
|
|
266
|
+
const existingName = input.original.displayName
|
|
267
|
+
if (
|
|
268
|
+
normalized === input.original.http.url &&
|
|
269
|
+
name === existingName &&
|
|
270
|
+
username === input.original.http.username &&
|
|
271
|
+
password === input.original.http.password
|
|
272
|
+
) {
|
|
273
|
+
resetEdit()
|
|
274
|
+
return
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const conn: ServerConnection.Http = {
|
|
278
|
+
type: "http",
|
|
279
|
+
displayName: name,
|
|
280
|
+
http: { url: normalized, username, password },
|
|
281
|
+
}
|
|
282
|
+
const result = await checkServerHealth(conn.http)
|
|
283
|
+
if (!result.healthy) {
|
|
284
|
+
setStore("editServer", { error: language.t("dialog.server.add.error") })
|
|
285
|
+
return
|
|
286
|
+
}
|
|
287
|
+
if (normalized === input.original.http.url) {
|
|
288
|
+
server.add(conn)
|
|
289
|
+
} else {
|
|
290
|
+
replaceServer(input.original, conn)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
resetEdit()
|
|
294
|
+
},
|
|
295
|
+
}))
|
|
296
|
+
|
|
297
|
+
const replaceServer = (original: ServerConnection.Http, next: ServerConnection.Http) => {
|
|
298
|
+
const active = server.key
|
|
299
|
+
const newConn = server.add(next)
|
|
300
|
+
if (!newConn) return
|
|
301
|
+
const nextActive = active === ServerConnection.key(original) ? ServerConnection.key(newConn) : active
|
|
302
|
+
if (nextActive) server.setActive(nextActive)
|
|
303
|
+
server.remove(ServerConnection.key(original))
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const items = createMemo(() => {
|
|
307
|
+
const current = server.current
|
|
308
|
+
const list = server.list
|
|
309
|
+
if (!current) return list
|
|
310
|
+
if (!list.includes(current)) return [current, ...list]
|
|
311
|
+
return [current, ...list.filter((x) => x !== current)]
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
const current = createMemo(() => items().find((x) => ServerConnection.key(x) === server.key) ?? items()[0])
|
|
315
|
+
|
|
316
|
+
const sortedItems = createMemo(() => {
|
|
317
|
+
const list = items()
|
|
318
|
+
if (!list.length) return list
|
|
319
|
+
const active = current()
|
|
320
|
+
const order = new Map(list.map((url, index) => [url, index] as const))
|
|
321
|
+
const rank = (value?: ServerHealth) => {
|
|
322
|
+
if (value?.healthy === true) return 0
|
|
323
|
+
if (value?.healthy === false) return 2
|
|
324
|
+
return 1
|
|
325
|
+
}
|
|
326
|
+
return list.slice().sort((a, b) => {
|
|
327
|
+
if (a === active) return -1
|
|
328
|
+
if (b === active) return 1
|
|
329
|
+
const diff = rank(store.status[ServerConnection.key(a)]) - rank(store.status[ServerConnection.key(b)])
|
|
330
|
+
if (diff !== 0) return diff
|
|
331
|
+
return (order.get(a) ?? 0) - (order.get(b) ?? 0)
|
|
332
|
+
})
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
async function refreshHealth() {
|
|
336
|
+
const results: Record<ServerConnection.Key, ServerHealth> = {}
|
|
337
|
+
await Promise.all(
|
|
338
|
+
items().map(async (conn) => {
|
|
339
|
+
results[ServerConnection.key(conn)] = await checkServerHealth(conn.http)
|
|
340
|
+
}),
|
|
341
|
+
)
|
|
342
|
+
setStore("status", reconcile(results))
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
createEffect(() => {
|
|
346
|
+
items()
|
|
347
|
+
refreshHealth()
|
|
348
|
+
const interval = setInterval(refreshHealth, 10_000)
|
|
349
|
+
onCleanup(() => clearInterval(interval))
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
async function select(conn: ServerConnection.Any, persist?: boolean) {
|
|
353
|
+
if (!persist && store.status[ServerConnection.key(conn)]?.healthy === false) return
|
|
354
|
+
dialog.close()
|
|
355
|
+
if (persist && conn.type === "http") {
|
|
356
|
+
server.add(conn)
|
|
357
|
+
navigate("/")
|
|
358
|
+
return
|
|
359
|
+
}
|
|
360
|
+
navigate("/")
|
|
361
|
+
queueMicrotask(() => server.setActive(ServerConnection.key(conn)))
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const handleAddChange = (value: string) => {
|
|
365
|
+
if (addMutation.isPending) return
|
|
366
|
+
setStore("addServer", { url: value, error: "" })
|
|
367
|
+
void previewStatus(value, store.addServer.username, store.addServer.password, (next) =>
|
|
368
|
+
setStore("addServer", { status: next }),
|
|
369
|
+
)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const handleAddNameChange = (value: string) => {
|
|
373
|
+
if (addMutation.isPending) return
|
|
374
|
+
setStore("addServer", { name: value, error: "" })
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const handleAddUsernameChange = (value: string) => {
|
|
378
|
+
if (addMutation.isPending) return
|
|
379
|
+
setStore("addServer", { username: value, error: "" })
|
|
380
|
+
void previewStatus(store.addServer.url, value, store.addServer.password, (next) =>
|
|
381
|
+
setStore("addServer", { status: next }),
|
|
382
|
+
)
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const handleAddPasswordChange = (value: string) => {
|
|
386
|
+
if (addMutation.isPending) return
|
|
387
|
+
setStore("addServer", { password: value, error: "" })
|
|
388
|
+
void previewStatus(store.addServer.url, store.addServer.username, value, (next) =>
|
|
389
|
+
setStore("addServer", { status: next }),
|
|
390
|
+
)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const handleEditChange = (value: string) => {
|
|
394
|
+
if (editMutation.isPending) return
|
|
395
|
+
setStore("editServer", { value, error: "" })
|
|
396
|
+
void previewStatus(value, store.editServer.username, store.editServer.password, (next) =>
|
|
397
|
+
setStore("editServer", { status: next }),
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const handleEditNameChange = (value: string) => {
|
|
402
|
+
if (editMutation.isPending) return
|
|
403
|
+
setStore("editServer", { name: value, error: "" })
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const handleEditUsernameChange = (value: string) => {
|
|
407
|
+
if (editMutation.isPending) return
|
|
408
|
+
setStore("editServer", { username: value, error: "" })
|
|
409
|
+
void previewStatus(store.editServer.value, value, store.editServer.password, (next) =>
|
|
410
|
+
setStore("editServer", { status: next }),
|
|
411
|
+
)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const handleEditPasswordChange = (value: string) => {
|
|
415
|
+
if (editMutation.isPending) return
|
|
416
|
+
setStore("editServer", { password: value, error: "" })
|
|
417
|
+
void previewStatus(store.editServer.value, store.editServer.username, value, (next) =>
|
|
418
|
+
setStore("editServer", { status: next }),
|
|
419
|
+
)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const mode = createMemo<"list" | "add" | "edit">(() => {
|
|
423
|
+
if (store.editServer.id) return "edit"
|
|
424
|
+
if (store.addServer.showForm) return "add"
|
|
425
|
+
return "list"
|
|
426
|
+
})
|
|
427
|
+
|
|
428
|
+
const editing = createMemo(() => {
|
|
429
|
+
if (!store.editServer.id) return
|
|
430
|
+
return items().find((x) => x.type === "http" && x.http.url === store.editServer.id)
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
const resetForm = () => {
|
|
434
|
+
resetAdd()
|
|
435
|
+
resetEdit()
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const startAdd = () => {
|
|
439
|
+
resetEdit()
|
|
440
|
+
setStore("addServer", {
|
|
441
|
+
showForm: true,
|
|
442
|
+
url: "",
|
|
443
|
+
name: "",
|
|
444
|
+
username: DEFAULT_USERNAME,
|
|
445
|
+
password: "",
|
|
446
|
+
error: "",
|
|
447
|
+
status: undefined,
|
|
448
|
+
})
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const startEdit = (conn: ServerConnection.Http) => {
|
|
452
|
+
resetAdd()
|
|
453
|
+
setStore("editServer", {
|
|
454
|
+
id: conn.http.url,
|
|
455
|
+
value: conn.http.url,
|
|
456
|
+
name: conn.displayName ?? "",
|
|
457
|
+
username: conn.http.username ?? "",
|
|
458
|
+
password: conn.http.password ?? "",
|
|
459
|
+
error: "",
|
|
460
|
+
status: store.status[ServerConnection.key(conn)]?.healthy,
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const submitForm = () => {
|
|
465
|
+
if (mode() === "add") {
|
|
466
|
+
if (addMutation.isPending) return
|
|
467
|
+
setStore("addServer", { error: "" })
|
|
468
|
+
addMutation.mutate(store.addServer.url)
|
|
469
|
+
return
|
|
470
|
+
}
|
|
471
|
+
const original = editing()
|
|
472
|
+
if (!original) return
|
|
473
|
+
if (editMutation.isPending) return
|
|
474
|
+
setStore("editServer", { error: "" })
|
|
475
|
+
editMutation.mutate({ original, value: store.editServer.value })
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const isFormMode = createMemo(() => mode() !== "list")
|
|
479
|
+
const isAddMode = createMemo(() => mode() === "add")
|
|
480
|
+
const formBusy = createMemo(() => (isAddMode() ? addMutation.isPending : editMutation.isPending))
|
|
481
|
+
|
|
482
|
+
const formTitle = createMemo(() => {
|
|
483
|
+
if (!isFormMode()) return language.t("dialog.server.title")
|
|
484
|
+
return (
|
|
485
|
+
<div class="flex items-center gap-2 -ml-2">
|
|
486
|
+
<IconButton icon="arrow-left" variant="ghost" onClick={resetForm} aria-label={language.t("common.goBack")} />
|
|
487
|
+
<span>{isAddMode() ? language.t("dialog.server.add.title") : language.t("dialog.server.edit.title")}</span>
|
|
488
|
+
</div>
|
|
489
|
+
)
|
|
490
|
+
})
|
|
491
|
+
|
|
492
|
+
createEffect(() => {
|
|
493
|
+
if (!store.editServer.id) return
|
|
494
|
+
if (editing()) return
|
|
495
|
+
resetEdit()
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
async function handleRemove(url: ServerConnection.Key) {
|
|
499
|
+
server.remove(url)
|
|
500
|
+
if ((await platform.getDefaultServer?.()) === url) {
|
|
501
|
+
platform.setDefaultServer?.(null)
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return (
|
|
506
|
+
<Dialog title={formTitle()}>
|
|
507
|
+
<div class="flex flex-col gap-2">
|
|
508
|
+
<Show
|
|
509
|
+
when={!isFormMode()}
|
|
510
|
+
fallback={
|
|
511
|
+
<ServerForm
|
|
512
|
+
value={isAddMode() ? store.addServer.url : store.editServer.value}
|
|
513
|
+
name={isAddMode() ? store.addServer.name : store.editServer.name}
|
|
514
|
+
username={isAddMode() ? store.addServer.username : store.editServer.username}
|
|
515
|
+
password={isAddMode() ? store.addServer.password : store.editServer.password}
|
|
516
|
+
placeholder={language.t("dialog.server.add.placeholder")}
|
|
517
|
+
busy={formBusy()}
|
|
518
|
+
error={isAddMode() ? store.addServer.error : store.editServer.error}
|
|
519
|
+
status={isAddMode() ? store.addServer.status : store.editServer.status}
|
|
520
|
+
onChange={isAddMode() ? handleAddChange : handleEditChange}
|
|
521
|
+
onNameChange={isAddMode() ? handleAddNameChange : handleEditNameChange}
|
|
522
|
+
onUsernameChange={isAddMode() ? handleAddUsernameChange : handleEditUsernameChange}
|
|
523
|
+
onPasswordChange={isAddMode() ? handleAddPasswordChange : handleEditPasswordChange}
|
|
524
|
+
onSubmit={submitForm}
|
|
525
|
+
onBack={resetForm}
|
|
526
|
+
/>
|
|
527
|
+
}
|
|
528
|
+
>
|
|
529
|
+
<List
|
|
530
|
+
search={{
|
|
531
|
+
placeholder: language.t("dialog.server.search.placeholder"),
|
|
532
|
+
autofocus: false,
|
|
533
|
+
}}
|
|
534
|
+
noInitialSelection
|
|
535
|
+
emptyMessage={language.t("dialog.server.empty")}
|
|
536
|
+
items={sortedItems}
|
|
537
|
+
key={(x) => x.http.url}
|
|
538
|
+
onSelect={(x) => {
|
|
539
|
+
if (x) select(x)
|
|
540
|
+
}}
|
|
541
|
+
divider={true}
|
|
542
|
+
class="px-5 [&_[data-slot=list-search-wrapper]]:w-full [&_[data-slot=list-scroll]]h-[300px] [&_[data-slot=list-scroll]]:overflow-y-auto [&_[data-slot=list-items]]:bg-surface-base [&_[data-slot=list-items]]:rounded-md [&_[data-slot=list-item]]:min-h-14 [&_[data-slot=list-item]]:p-3 [&_[data-slot=list-item]]:!bg-transparent"
|
|
543
|
+
>
|
|
544
|
+
{(i) => {
|
|
545
|
+
const key = ServerConnection.key(i)
|
|
546
|
+
return (
|
|
547
|
+
<div class="flex items-center gap-3 min-w-0 flex-1 w-full group/item">
|
|
548
|
+
<div class="flex flex-col h-full items-start w-5">
|
|
549
|
+
<ServerHealthIndicator health={store.status[key]} />
|
|
550
|
+
</div>
|
|
551
|
+
<ServerRow
|
|
552
|
+
conn={i}
|
|
553
|
+
dimmed={store.status[key]?.healthy === false}
|
|
554
|
+
status={store.status[key]}
|
|
555
|
+
class="flex items-center gap-3 min-w-0 flex-1"
|
|
556
|
+
badge={
|
|
557
|
+
<Show when={defaultKey() === ServerConnection.key(i)}>
|
|
558
|
+
<span class="text-text-base bg-surface-base text-14-regular px-1.5 rounded-xs">
|
|
559
|
+
{language.t("dialog.server.status.default")}
|
|
560
|
+
</span>
|
|
561
|
+
</Show>
|
|
562
|
+
}
|
|
563
|
+
showCredentials
|
|
564
|
+
/>
|
|
565
|
+
<div class="flex items-center justify-center gap-4 pl-4">
|
|
566
|
+
<Show when={ServerConnection.key(current()) === key}>
|
|
567
|
+
<Icon name="check" class="h-6" />
|
|
568
|
+
</Show>
|
|
569
|
+
|
|
570
|
+
<Show when={i.type === "http"}>
|
|
571
|
+
<DropdownMenu>
|
|
572
|
+
<DropdownMenu.Trigger
|
|
573
|
+
as={IconButton}
|
|
574
|
+
icon="dot-grid"
|
|
575
|
+
variant="ghost"
|
|
576
|
+
class="shrink-0 size-8 hover:bg-surface-base-hover data-[expanded]:bg-surface-base-active"
|
|
577
|
+
onClick={(e: MouseEvent) => e.stopPropagation()}
|
|
578
|
+
onPointerDown={(e: PointerEvent) => e.stopPropagation()}
|
|
579
|
+
/>
|
|
580
|
+
<DropdownMenu.Portal>
|
|
581
|
+
<DropdownMenu.Content class="mt-1">
|
|
582
|
+
<DropdownMenu.Item
|
|
583
|
+
onSelect={() => {
|
|
584
|
+
if (i.type !== "http") return
|
|
585
|
+
startEdit(i)
|
|
586
|
+
}}
|
|
587
|
+
>
|
|
588
|
+
<DropdownMenu.ItemLabel>{language.t("dialog.server.menu.edit")}</DropdownMenu.ItemLabel>
|
|
589
|
+
</DropdownMenu.Item>
|
|
590
|
+
<Show when={canDefault() && defaultKey() !== key}>
|
|
591
|
+
<DropdownMenu.Item onSelect={() => setDefault(key)}>
|
|
592
|
+
<DropdownMenu.ItemLabel>
|
|
593
|
+
{language.t("dialog.server.menu.default")}
|
|
594
|
+
</DropdownMenu.ItemLabel>
|
|
595
|
+
</DropdownMenu.Item>
|
|
596
|
+
</Show>
|
|
597
|
+
<Show when={canDefault() && defaultKey() === key}>
|
|
598
|
+
<DropdownMenu.Item onSelect={() => setDefault(null)}>
|
|
599
|
+
<DropdownMenu.ItemLabel>
|
|
600
|
+
{language.t("dialog.server.menu.defaultRemove")}
|
|
601
|
+
</DropdownMenu.ItemLabel>
|
|
602
|
+
</DropdownMenu.Item>
|
|
603
|
+
</Show>
|
|
604
|
+
<DropdownMenu.Separator />
|
|
605
|
+
<DropdownMenu.Item
|
|
606
|
+
onSelect={() => handleRemove(ServerConnection.key(i))}
|
|
607
|
+
class="text-text-on-critical-base hover:bg-surface-critical-weak"
|
|
608
|
+
>
|
|
609
|
+
<DropdownMenu.ItemLabel>{language.t("dialog.server.menu.delete")}</DropdownMenu.ItemLabel>
|
|
610
|
+
</DropdownMenu.Item>
|
|
611
|
+
</DropdownMenu.Content>
|
|
612
|
+
</DropdownMenu.Portal>
|
|
613
|
+
</DropdownMenu>
|
|
614
|
+
</Show>
|
|
615
|
+
</div>
|
|
616
|
+
</div>
|
|
617
|
+
)
|
|
618
|
+
}}
|
|
619
|
+
</List>
|
|
620
|
+
</Show>
|
|
621
|
+
|
|
622
|
+
<div class="px-5 pb-5">
|
|
623
|
+
<Show
|
|
624
|
+
when={isFormMode()}
|
|
625
|
+
fallback={
|
|
626
|
+
<Button
|
|
627
|
+
variant="secondary"
|
|
628
|
+
icon="plus-small"
|
|
629
|
+
size="large"
|
|
630
|
+
onClick={startAdd}
|
|
631
|
+
class="py-1.5 pl-1.5 pr-3 flex items-center gap-1.5"
|
|
632
|
+
>
|
|
633
|
+
{language.t("dialog.server.add.button")}
|
|
634
|
+
</Button>
|
|
635
|
+
}
|
|
636
|
+
>
|
|
637
|
+
<Button variant="primary" size="large" onClick={submitForm} disabled={formBusy()} class="px-3 py-1.5">
|
|
638
|
+
{formBusy()
|
|
639
|
+
? language.t("dialog.server.add.checking")
|
|
640
|
+
: isAddMode()
|
|
641
|
+
? language.t("dialog.server.add.button")
|
|
642
|
+
: language.t("common.save")}
|
|
643
|
+
</Button>
|
|
644
|
+
</Show>
|
|
645
|
+
</div>
|
|
646
|
+
</div>
|
|
647
|
+
</Dialog>
|
|
648
|
+
)
|
|
649
|
+
}
|