Adding http verbs instead of icons for REST requests.
This commit is contained in:
parent
ad1007ffdc
commit
4cd28fa7c4
|
@ -9,6 +9,7 @@
|
||||||
export let size = "M"
|
export let size = "M"
|
||||||
export let hoverable = false
|
export let hoverable = false
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let color
|
||||||
|
|
||||||
$: rotation = getRotation(direction)
|
$: rotation = getRotation(direction)
|
||||||
|
|
||||||
|
@ -25,7 +26,9 @@
|
||||||
focusable="false"
|
focusable="false"
|
||||||
aria-hidden={hidden}
|
aria-hidden={hidden}
|
||||||
aria-label={name}
|
aria-label={name}
|
||||||
style={`transform: rotate(${rotation}deg)`}
|
style={`transform: rotate(${rotation}deg); ${
|
||||||
|
color ? `color: ${color};` : ""
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<use xlink:href="#spectrum-icon-18-{name}" />
|
<use xlink:href="#spectrum-icon-18-{name}" />
|
||||||
</svg>
|
</svg>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
import EditQueryPopover from "./popovers/EditQueryPopover.svelte"
|
import EditQueryPopover from "./popovers/EditQueryPopover.svelte"
|
||||||
import NavItem from "components/common/NavItem.svelte"
|
import NavItem from "components/common/NavItem.svelte"
|
||||||
import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte"
|
import TableNavigator from "components/backend/TableNavigator/TableNavigator.svelte"
|
||||||
|
import { customQueryIconText, customQueryIconColor } from "helpers/data/utils"
|
||||||
import ICONS from "./icons"
|
import ICONS from "./icons"
|
||||||
|
|
||||||
let openDataSources = []
|
let openDataSources = []
|
||||||
|
@ -129,6 +130,8 @@
|
||||||
<NavItem
|
<NavItem
|
||||||
indentLevel={1}
|
indentLevel={1}
|
||||||
icon="SQLQuery"
|
icon="SQLQuery"
|
||||||
|
iconText={customQueryIconText(datasource, query)}
|
||||||
|
iconColor={customQueryIconColor(datasource, query)}
|
||||||
text={query.name}
|
text={query.name}
|
||||||
opened={$queries.selected === query._id}
|
opened={$queries.selected === query._id}
|
||||||
selected={$queries.selected === query._id}
|
selected={$queries.selected === query._id}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
export let selected = false
|
export let selected = false
|
||||||
export let opened = false
|
export let opened = false
|
||||||
export let draggable = false
|
export let draggable = false
|
||||||
|
export let iconText
|
||||||
|
export let iconColor
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -42,9 +44,13 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<slot name="icon" />
|
<slot name="icon" />
|
||||||
{#if icon}
|
{#if iconText}
|
||||||
|
<div class="iconText" style={iconColor ? `color: ${iconColor};` : ""}>
|
||||||
|
{iconText}
|
||||||
|
</div>
|
||||||
|
{:else if icon}
|
||||||
<div class="icon">
|
<div class="icon">
|
||||||
<Icon size="S" name={icon} />
|
<Icon color={iconColor} size="S" name={icon} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="text">{text}</div>
|
<div class="text">{text}</div>
|
||||||
|
@ -123,4 +129,9 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.iconText {
|
||||||
|
margin-top: 1px;
|
||||||
|
font-size: var(--spectrum-global-dimension-font-size-50);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { IntegrationTypes } from "constants/backend"
|
||||||
|
|
||||||
export function schemaToFields(schema) {
|
export function schemaToFields(schema) {
|
||||||
const response = {}
|
const response = {}
|
||||||
if (schema && typeof schema === "object") {
|
if (schema && typeof schema === "object") {
|
||||||
|
@ -69,3 +71,40 @@ export function queryParametersToKeyValue(array) {
|
||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function customQueryIconText(datasource, query) {
|
||||||
|
if (datasource.source !== IntegrationTypes.REST) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch (query.queryVerb) {
|
||||||
|
case "create":
|
||||||
|
return "POST"
|
||||||
|
case "update":
|
||||||
|
return "PUT"
|
||||||
|
case "read":
|
||||||
|
return "GET"
|
||||||
|
case "delete":
|
||||||
|
return "DELETE"
|
||||||
|
case "patch":
|
||||||
|
return "PATCH"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function customQueryIconColor(datasource, query) {
|
||||||
|
if (datasource.source !== IntegrationTypes.REST) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch (query.queryVerb) {
|
||||||
|
case "create":
|
||||||
|
return "#DCC339"
|
||||||
|
case "update":
|
||||||
|
return "#5197EC"
|
||||||
|
case "read":
|
||||||
|
return "#59B294"
|
||||||
|
case "delete":
|
||||||
|
return "#E16B71"
|
||||||
|
case "patch":
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
import JSONPreview from "components/integration/JSONPreview.svelte"
|
import JSONPreview from "components/integration/JSONPreview.svelte"
|
||||||
import AccessLevelSelect from "components/integration/AccessLevelSelect.svelte"
|
import AccessLevelSelect from "components/integration/AccessLevelSelect.svelte"
|
||||||
import Placeholder from "assets/bb-spaceship.svg"
|
import Placeholder from "assets/bb-spaceship.svg"
|
||||||
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
|
||||||
let query, datasource
|
let query, datasource
|
||||||
let breakQs = {},
|
let breakQs = {},
|
||||||
|
@ -61,7 +62,7 @@
|
||||||
response?.info?.code >= 200 && response?.info?.code <= 206
|
response?.info?.code >= 200 && response?.info?.code <= 206
|
||||||
|
|
||||||
function getSelectedQuery() {
|
function getSelectedQuery() {
|
||||||
return (
|
return cloneDeep(
|
||||||
$queries.list.find(q => q._id === $queries.selected) || {
|
$queries.list.find(q => q._id === $queries.selected) || {
|
||||||
datasourceId: $params.selectedDatasource,
|
datasourceId: $params.selectedDatasource,
|
||||||
parameters: [],
|
parameters: [],
|
||||||
|
|
Loading…
Reference in New Issue