* fix: environment add bug in inspection * chore: add 127.0.0.1 in url inspection * chore: update browserextension inspection help url * fix: team env not showing bug in selector * chore: rework inspector systems to be reactive * chore: handling tab changes gracefully * refactor: move out url interceptor from the platform * chore: add view function in inspector service to get views into the list * fix: interceptors not kicking in on initial load * fix: don't show no internet connection error unless browser deems so * chore: fix tests --------- Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { Service } from "dioc"
|
|
import {
|
|
ContextMenu,
|
|
ContextMenuResult,
|
|
ContextMenuService,
|
|
ContextMenuState,
|
|
} from "../"
|
|
import { markRaw, ref } from "vue"
|
|
import { invokeAction } from "~/helpers/actions"
|
|
import IconPlusCircle from "~icons/lucide/plus-circle"
|
|
import { getI18n } from "~/modules/i18n"
|
|
|
|
/**
|
|
* This menu returns a single result that allows the user
|
|
* to add the selected text as an environment variable
|
|
* This menus is shown on all text selections
|
|
*/
|
|
export class EnvironmentMenuService extends Service implements ContextMenu {
|
|
public static readonly ID = "ENVIRONMENT_CONTEXT_MENU_SERVICE"
|
|
|
|
private t = getI18n()
|
|
|
|
public readonly menuID = "environment"
|
|
|
|
private readonly contextMenu = this.bind(ContextMenuService)
|
|
|
|
constructor() {
|
|
super()
|
|
|
|
this.contextMenu.registerMenu(this)
|
|
}
|
|
|
|
getMenuFor(text: Readonly<string>): ContextMenuState {
|
|
const results = ref<ContextMenuResult[]>([])
|
|
results.value = [
|
|
{
|
|
id: "environment",
|
|
text: {
|
|
type: "text",
|
|
text: this.t("context_menu.set_environment_variable"),
|
|
},
|
|
icon: markRaw(IconPlusCircle),
|
|
action: () => {
|
|
invokeAction("modals.environment.add", {
|
|
envName: "",
|
|
variableName: text,
|
|
})
|
|
},
|
|
},
|
|
]
|
|
const resultObj = <ContextMenuState>{
|
|
results: results.value,
|
|
}
|
|
return resultObj
|
|
}
|
|
}
|