Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: add autofocus prop to MarkdownEditor component (#17286)

boojacka72e117d149f
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
index f6a60df982..b903430134 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
@@ -103,7 +103,7 @@ import {
HeadingIcon,
} from "lucide-vue-next";
import { NButton, NTooltip } from "naive-ui";
-import { nextTick, ref, reactive, watch, toRef } from "vue";
+import { nextTick, ref, reactive, watch, toRef, onMounted } from "vue";
import type { Component } from "vue";
import { useI18n } from "vue-i18n";
import type { ComposedIssue, ComposedProject } from "@/types";
@@ -136,7 +136,9 @@ const props = defineProps<{
project?: ComposedProject;
issueList: ComposedIssue[];
placeholder?: string;
+ autofocus?: boolean;
}>();
+
const emit = defineEmits<{
(event: "change", value: string): void;
(event: "submit"): void;
@@ -195,6 +197,14 @@ watch(
}
);
+onMounted(() => {
+ if (props.autofocus && !state.showPreview) {
+ nextTick(() => {
+ contentTextArea.value?.focus();
+ });
+ }
+});
+
const keyboardHandler = (e: KeyboardEvent) => {
if (!contentTextArea.value) {
return;
diff --git a/frontend/src/components/Plan/components/Configuration/Configuration.vue b/frontend/src/components/Plan/components/Configuration/Configuration.vue
index d76aeb83b9..4cf5cb34a7 100644
--- a/frontend/src/components/Plan/components/Configuration/Configuration.vue
+++ b/frontend/src/components/Plan/components/Configuration/Configuration.vue
@@ -1,6 +1,6 @@
<template>
<div v-if="shouldShow" class="flex flex-col gap-2">
- <p class="text-base font-medium">
+ <p class="text-base">
{{ $t("plan.options.self") }}
</p>
<div class="w-auto">
diff --git a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
index 678ca9e2ca..5b7d4c9776 100644
--- a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
@@ -1,11 +1,11 @@
<template>
<div class="flex-1">
- <div v-if="!state.isExpanded" class="py-1 truncate">
+ <div v-if="!state.isExpanded" class="py-1 truncate pr-4">
<span class="text-sm text-control mr-2"
>{{ $t("common.description") }}:</span
>
<span
- class="text-sm cursor-pointer hover:opacity-80"
+ class="text-sm cursor-text hover:opacity-80"
:class="state.description ? 'text-gray-700' : 'italic text-gray-400'"
@click="toggleExpanded"
>
@@ -18,8 +18,8 @@
$t("common.description")
}}</span>
<NButton
- size="small"
- quaternary
+ size="tiny"
+ type="default"
@click="toggleExpanded"
:disabled="state.isUpdating"
>
@@ -29,6 +29,7 @@
<MarkdownEditor
:content="state.description"
mode="editor"
+ :autofocus="true"
:project="project"
:placeholder="$t('plan.description.placeholder')"
:issue-list="[]"
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/DescriptionSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/DescriptionSection.vue
index 0d6e06ffa6..7a53eaeccb 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/DescriptionSection.vue
@@ -9,18 +9,15 @@
size="small"
@click="startEditing"
>
- <template #icon>
- <EditIcon class="w-4 h-4" />
- </template>
{{ $t("common.edit") }}
</NButton>
<div v-if="isEditing" class="flex items-center gap-2">
- <NButton size="small" @click="cancelEditing">
- {{ $t("common.cancel") }}
- </NButton>
- <NButton size="small" type="primary" @click="saveChanges">
+ <NButton size="small" @click="saveChanges">
{{ $t("common.save") }}
</NButton>
+ <NButton size="small" quaternary @click="cancelEditing">
+ {{ $t("common.cancel") }}
+ </NButton>
</div>
</div>
<div v-if="!isEditing">
@@ -39,6 +36,7 @@
<MarkdownEditor
:content="editingDescription"
mode="editor"
+ autofocus
:project="project"
:placeholder="$t('issue.add-some-description')"
:issue-list="[]"
@@ -50,7 +48,6 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
-import { EditIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
index 9cb66fab3a..1d08e9976e 100644
--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
@@ -2,7 +2,7 @@
<div v-if="shouldShow" class="pt-3 flex flex-col gap-y-1 overflow-hidden">
<div class="flex items-center justify-between gap-2">
<div class="flex items-center gap-2">
- <h3 class="text-base font-medium">{{ $t("plan.checks.self") }}</h3>
+ <h3 class="text-base">{{ $t("plan.checks.self") }}</h3>
<NTooltip v-if="checksOfSelectedSpec.length > 0 && affectedRows > 0">
<template #trigger>
@@ -10,7 +10,7 @@
<span class="text-sm text-control-light mr-1">{{
$t("task.check-type.affected-rows.self")
}}</span>
- <span class="text-sm font-medium">
+ <span class="text-sm">
{{ affectedRows }}
</span>
</NTag>
diff --git a/frontend/src/components/Plan/components/RolloutView/StageCard.vue b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
index f18e3ad4b7..1c52fab23f 100644
--- a/frontend/src/components/Plan/components/RolloutView/StageCard.vue
+++ b/frontend/src/components/Plan/components/RolloutView/StageCard.vue
@@ -22,7 +22,6 @@
class="text-base font-medium text-gray-900 whitespace-nowrap truncate"
>
<EnvironmentV1Name
- text-class="w-24"
:environment="environment"
:link="false"
:null-environment-placeholder="'Null'"
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
index 05ba9a85ce..aea810d489 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue
@@ -29,7 +29,7 @@
</NTooltip>
<NButton
v-if="canModifySpecs && plan.specs.length > 1"
- quaternary
+ text
size="tiny"
:title="$t('common.delete')"
@click.stop="handleDeleteSpec(spec)"
@@ -49,9 +49,6 @@
size="small"
@click="showAddSpecDrawer = true"
>
- <template #icon>
- <PlusIcon class="w-4 h-4" />
- </template>
{{ $t("plan.add-spec") }}
</NButton>
</div>
@@ -67,7 +64,7 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
-import { PlusIcon, XIcon } from "lucide-vue-next";
+import { XIcon } from "lucide-vue-next";
import { NTabs, NTab, NButton, useDialog, NTooltip } from "naive-ui";
import { ref, computed, nextTick } from "vue";
import { useI18n } from "vue-i18n";
diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
index e495e0550b..f4c79028b9 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
@@ -2,7 +2,7 @@
<div class="flex flex-col gap-y-2 pt-2">
<div class="flex items-center justify-between gap-2">
<div class="flex items-center gap-1">
- <h3 class="text-base font-medium">{{ $t("plan.targets.title") }}</h3>
+ <h3 class="text-base">{{ $t("plan.targets.title") }}</h3>
<span class="text-control-light" v-if="targets.length > 1"
>({{ targets.length }})</span
>
@@ -13,9 +13,6 @@
size="small"
@click="showTargetsSelector = true"
>
- <template #icon>
- <EditIcon class="w-4 h-4" />
- </template>
{{ $t("common.edit") }}
</NButton>
</div>
@@ -99,7 +96,7 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
-import { EditIcon, ExternalLinkIcon } from "lucide-vue-next";
+import { ExternalLinkIcon } from "lucide-vue-next";
import { NButton, NTag } from "naive-ui";
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
index 7fdc380731..bbb806920c 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
@@ -2,9 +2,9 @@
<div class="flex flex-col gap-y-2">
<div class="flex items-center justify-between">
<div class="flex items-center gap-x-4">
- <div class="flex items-center gap-x-1 text-sm font-medium">
+ <div class="flex items-center gap-x-1 text-sm">
<span
- class="text-base font-medium"
+ class="text-base"
:class="isEmpty(state.statement) ? 'text-red-600' : ''"
>
{{ statementTitle }}