feat: add generate data schema option in spotlight searcher (#4356)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
|||||||
|
|
||||||
import IconDownload from "~icons/lucide/download"
|
import IconDownload from "~icons/lucide/download"
|
||||||
import IconCopy from "~icons/lucide/copy"
|
import IconCopy from "~icons/lucide/copy"
|
||||||
|
import IconNetwork from "~icons/lucide/network"
|
||||||
import { Container } from "dioc"
|
import { Container } from "dioc"
|
||||||
|
|
||||||
type Doc = {
|
type Doc = {
|
||||||
@@ -40,6 +41,8 @@ export class ResponseSpotlightSearcherService extends StaticSpotlightSearcherSer
|
|||||||
"response.file.download"
|
"response.file.download"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private dataSchemaActionEnabled = isActionBound("response.schema.toggle")
|
||||||
|
|
||||||
private documents: Record<string, Doc> = reactive({
|
private documents: Record<string, Doc> = reactive({
|
||||||
copy_response: {
|
copy_response: {
|
||||||
text: this.t("spotlight.response.copy"),
|
text: this.t("spotlight.response.copy"),
|
||||||
@@ -55,6 +58,12 @@ export class ResponseSpotlightSearcherService extends StaticSpotlightSearcherSer
|
|||||||
() => !this.downloadResponseActionEnabled.value
|
() => !this.downloadResponseActionEnabled.value
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
generate_data_schema: {
|
||||||
|
text: this.t("response.generate_data_schema"),
|
||||||
|
alternates: ["generate", "data", "schema", "typescript", "response"],
|
||||||
|
icon: markRaw(IconNetwork),
|
||||||
|
excludeFromSearch: computed(() => !this.dataSchemaActionEnabled.value),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
|
// TODO: Constructors are no longer recommended as of dioc > 3, move to onServiceInit
|
||||||
@@ -87,5 +96,6 @@ export class ResponseSpotlightSearcherService extends StaticSpotlightSearcherSer
|
|||||||
public onDocSelected(id: string): void {
|
public onDocSelected(id: string): void {
|
||||||
if (id === "copy_response") invokeAction(`response.copy`)
|
if (id === "copy_response") invokeAction(`response.copy`)
|
||||||
if (id === "download_response") invokeAction(`response.file.download`)
|
if (id === "download_response") invokeAction(`response.file.download`)
|
||||||
|
if (id === "generate_data_schema") invokeAction(`response.schema.toggle`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user