Improve REST query naming in navigation
This commit is contained in:
parent
2e4cfb3312
commit
e34895989b
2 changed files with 36 additions and 2 deletions
|
@ -8,7 +8,11 @@
|
|||
import EditQueryPopover from "./popovers/EditQueryPopover.svelte"
|
||||
import NavItem from "components/common/NavItem.svelte"
|
||||
import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte"
|
||||
import { customQueryIconText, customQueryIconColor } from "helpers/data/utils"
|
||||
import {
|
||||
customQueryIconText,
|
||||
customQueryIconColor,
|
||||
customQueryText,
|
||||
} from "helpers/data/utils"
|
||||
import ICONS from "./icons"
|
||||
import { notifications } from "@budibase/bbui"
|
||||
|
||||
|
@ -137,7 +141,7 @@
|
|||
icon="SQLQuery"
|
||||
iconText={customQueryIconText(datasource, query)}
|
||||
iconColor={customQueryIconColor(datasource, query)}
|
||||
text={query.name}
|
||||
text={customQueryText(datasource, query)}
|
||||
opened={$queries.selected === query._id}
|
||||
selected={$queries.selected === query._id}
|
||||
on:click={() => onClickQuery(query)}
|
||||
|
|
|
@ -109,6 +109,36 @@ export function customQueryIconColor(datasource, query) {
|
|||
}
|
||||
}
|
||||
|
||||
export function customQueryText(datasource, query) {
|
||||
if (!query.name || datasource.source !== IntegrationTypes.REST) {
|
||||
return query.name
|
||||
}
|
||||
|
||||
// Remove protocol
|
||||
let name = query.name
|
||||
if (name.includes("://")) {
|
||||
name = name.split("://")[1]
|
||||
}
|
||||
|
||||
// If no path, return the full name
|
||||
if (!name.includes("/")) {
|
||||
return name
|
||||
}
|
||||
|
||||
// Remove trailing slash
|
||||
if (name.endsWith("/")) {
|
||||
name = name.slice(0, -1)
|
||||
}
|
||||
|
||||
// Only use path
|
||||
const split = name.split("/")
|
||||
if (split[1]) {
|
||||
return `/${split.slice(1).join("/")}`
|
||||
} else {
|
||||
return split[0]
|
||||
}
|
||||
}
|
||||
|
||||
export function flipHeaderState(headersActivity) {
|
||||
if (!headersActivity) {
|
||||
return {}
|
||||
|
|
Loading…
Reference in a new issue