feat(connection): add editable connection notes
This commit is contained in:
35 files changed
+126
-2
No files matched your search
@@ -213,6 +213,7 @@ function initialConfigTab(): ConfigTab {
|
||||
|
||||
const defaultForm = (): ConnectionForm => ({
|
||||
name: "",
|
||||
note: "",
|
||||
db_type: "mysql",
|
||||
driver_profile: "mysql",
|
||||
driver_label: "MySQL",
|
||||
@@ -444,6 +445,23 @@ function sshLayersForConfig(config: LegacyConnectionConfig): SshTunnelConfig[] {
|
||||
}
|
||||
|
||||
const form = ref(defaultForm());
|
||||
const noteTextareaRef = ref<HTMLTextAreaElement | null>(null);
|
||||
|
||||
function resizeNoteTextarea() {
|
||||
const textarea = noteTextareaRef.value;
|
||||
if (!textarea) return;
|
||||
|
||||
const style = window.getComputedStyle(textarea);
|
||||
const lineHeight = Number.parseFloat(style.lineHeight) || 20;
|
||||
const paddingHeight = (Number.parseFloat(style.paddingTop) || 0) + (Number.parseFloat(style.paddingBottom) || 0);
|
||||
const borderHeight = (Number.parseFloat(style.borderTopWidth) || 0) + (Number.parseFloat(style.borderBottomWidth) || 0);
|
||||
const maxContentHeight = lineHeight * 3 + paddingHeight;
|
||||
|
||||
textarea.style.height = "auto";
|
||||
textarea.style.height = `${Math.min(textarea.scrollHeight, maxContentHeight) + borderHeight}px`;
|
||||
textarea.style.overflowY = textarea.scrollHeight > maxContentHeight ? "auto" : "hidden";
|
||||
}
|
||||
|
||||
const showJdbcDependencyDriverManagerAction = computed(() => form.value.db_type === "jdbc" && isJdbcMissingRuntimeDependencyError(connectionErrorDetail.value));
|
||||
|
||||
function externalConfigRecord(value: unknown): Record<string, unknown> {
|
||||
@@ -517,6 +535,9 @@ const dbPickerView = ref<DbPickerView>(loadConnectionPickerView());
|
||||
const dbSearchQuery = ref("");
|
||||
const selectedDbCategory = ref<DbCategoryKey>("sql");
|
||||
const configTab = ref<ConfigTab>("connection");
|
||||
watch([() => form.value.note, configTab, dialogStep, open], () => {
|
||||
void nextTick(resizeNoteTextarea);
|
||||
});
|
||||
const MQ_KAFKA_SECURITY_PROTOCOL_AUTO = "__auto";
|
||||
const mqAdminUrl = ref("http://127.0.0.1:8080");
|
||||
const mqSystemKind = ref<MqSystemKind>("pulsar");
|
||||
@@ -1922,6 +1943,7 @@ watch(
|
||||
const profileConfig = driverProfiles[profile];
|
||||
form.value = {
|
||||
name: config.name,
|
||||
note: config.note || "",
|
||||
db_type: oceanbasePatch?.db_type || profileConfig?.type || config.db_type,
|
||||
driver_profile: oceanbasePatch?.driver_profile || profile,
|
||||
driver_label: config.driver_label || oceanbasePatch?.driver_label || driverProfiles[profile]?.label || config.db_type,
|
||||
@@ -3035,6 +3057,7 @@ function generateConnectionName(): string {
|
||||
function connectionConfigForSubmit(id: string, generatedName = ""): ConnectionConfig {
|
||||
const config = { ...formValueForSubmit(), id } as LegacyConnectionConfig;
|
||||
config.database_info = undefined;
|
||||
config.note = config.note?.trim() || undefined;
|
||||
if (selectedType.value === "oceanbase" && (config.driver_profile === "oceanbase" || config.driver_profile === "oceanbase-oracle")) {
|
||||
Object.assign(config, oceanbaseModeConnectionPatch(oceanbaseSubMode.value));
|
||||
}
|
||||
@@ -4744,7 +4767,7 @@ function openExternalUrl(url: string) {
|
||||
</div>
|
||||
|
||||
<TabsContent value="connection" class="m-0 min-h-0 flex-1 overflow-hidden">
|
||||
<div class="connection-form-body grid h-full min-h-0 gap-4 overflow-y-auto pt-4 pr-2">
|
||||
<div class="connection-form-body grid h-full min-h-0 gap-4 overflow-y-auto pt-4 pr-2 pb-2">
|
||||
<div v-if="!isJdbcConnection && form.db_type !== 'nacos'" class="grid grid-cols-4 items-center gap-4">
|
||||
<Label :class="connectionLabelClass">{{ t("connection.connectionUrlOptional") }}</Label>
|
||||
<div class="col-span-3 flex items-center gap-1">
|
||||
@@ -6148,6 +6171,18 @@ function openExternalUrl(url: string) {
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-4 items-start gap-4">
|
||||
<Label :class="connectionLabelTopClass">{{ t("connection.note") }}</Label>
|
||||
<textarea
|
||||
ref="noteTextareaRef"
|
||||
v-model="form.note"
|
||||
rows="1"
|
||||
class="col-span-3 min-h-8 w-full min-w-0 resize-none overflow-y-hidden rounded-md border border-input bg-transparent px-2.5 py-1 text-base leading-5 transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 dark:bg-input/30 md:text-sm"
|
||||
:placeholder="t('connection.notePlaceholder')"
|
||||
@input="resizeNoteTextarea"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
|
||||
Reference in new issue
Block a user