Fix styles in datasource select

This commit is contained in:
Andrew Kingston 2021-04-29 09:01:24 +01:00
parent f660c86ba9
commit 5e7ba5dfb3
1 changed files with 24 additions and 52 deletions

View File

@ -30,7 +30,7 @@
export let showAllQueries export let showAllQueries
$: text = value?.label ?? "Choose an option" $: text = value?.label ?? "Choose an option"
$: tables = $tablesStore.list.map((m) => ({ $: tables = $tablesStore.list.map(m => ({
label: m.name, label: m.name,
tableId: m._id, tableId: m._id,
type: "table", type: "table",
@ -46,9 +46,9 @@
}, []) }, [])
$: queries = $queriesStore.list $: queries = $queriesStore.list
.filter( .filter(
(query) => showAllQueries || query.queryVerb === "read" || query.readable query => showAllQueries || query.queryVerb === "read" || query.readable
) )
.map((query) => ({ .map(query => ({
label: query.name, label: query.name,
name: query.name, name: query.name,
tableId: query._id, tableId: query._id,
@ -61,15 +61,15 @@
$currentAsset, $currentAsset,
$store.selectedComponentId $store.selectedComponentId
) )
$: queryBindableProperties = bindableProperties.map((property) => ({ $: queryBindableProperties = bindableProperties.map(property => ({
...property, ...property,
category: property.type === "instance" ? "Component" : "Table", category: property.type === "instance" ? "Component" : "Table",
label: property.readableBinding, label: property.readableBinding,
path: property.readableBinding, path: property.readableBinding,
})) }))
$: links = bindableProperties $: links = bindableProperties
.filter((x) => x.fieldSchema?.type === "link") .filter(x => x.fieldSchema?.type === "link")
.map((property) => { .map(property => {
return { return {
providerId: property.providerId, providerId: property.providerId,
label: property.readableBinding, label: property.readableBinding,
@ -89,7 +89,7 @@
} }
function fetchQueryDefinition(query) { function fetchQueryDefinition(query) {
const source = $datasources.list.find((ds) => ds._id === query.datasourceId) const source = $datasources.list.find(ds => ds._id === query.datasourceId)
.source .source
return $integrations[source].query[query.queryVerb] return $integrations[source].query[query.queryVerb]
} }
@ -100,20 +100,18 @@
readonly readonly
value={text} value={text}
options={[text]} options={[text]}
on:click={dropdownRight.show} on:click={dropdownRight.show} />
/> {#if value?.type === 'query'}
{#if value?.type === "query"}
<i class="ri-settings-5-line" on:click={drawer.show} /> <i class="ri-settings-5-line" on:click={drawer.show} />
<Drawer title={"Query Parameters"} bind:this={drawer}> <Drawer title={'Query Parameters'} bind:this={drawer}>
<Button <Button
slot="buttons" slot="buttons"
cta cta
on:click={() => { on:click={() => {
notifications.success("Query parameters saved.") notifications.success('Query parameters saved.')
handleSelected(value) handleSelected(value)
drawer.hide() drawer.hide()
}} }}>
>
Save Save
</Button> </Button>
<DrawerContent slot="body"> <DrawerContent slot="body">
@ -121,20 +119,15 @@
{#if value.parameters.length > 0} {#if value.parameters.length > 0}
<ParameterBuilder <ParameterBuilder
bind:customParams={value.queryParams} bind:customParams={value.queryParams}
parameters={queries.find((query) => query._id === value._id) parameters={queries.find(query => query._id === value._id).parameters}
.parameters} bindings={queryBindableProperties} />
bindings={queryBindableProperties}
/>
{/if} {/if}
<IntegrationQueryEditor <IntegrationQueryEditor
height={200} height={200}
query={value} query={value}
schema={fetchQueryDefinition(value)} schema={fetchQueryDefinition(value)}
datasource={$datasources.list.find( datasource={$datasources.list.find(ds => ds._id === value.datasourceId)}
(ds) => ds._id === value.datasourceId editable={false} />
)}
editable={false}
/>
</Layout> </Layout>
</DrawerContent> </DrawerContent>
</Drawer> </Drawer>
@ -147,12 +140,7 @@
</div> </div>
<ul> <ul>
{#each tables as table} {#each tables as table}
<li <li on:click={() => handleSelected(table)}>{table.label}</li>
class:selected={value === table}
on:click={() => handleSelected(table)}
>
{table.label}
</li>
{/each} {/each}
</ul> </ul>
<Divider size="S" /> <Divider size="S" />
@ -161,12 +149,7 @@
</div> </div>
<ul> <ul>
{#each views as view} {#each views as view}
<li <li on:click={() => handleSelected(view)}>{view.label}</li>
class:selected={value === view}
on:click={() => handleSelected(view)}
>
{view.label}
</li>
{/each} {/each}
</ul> </ul>
<Divider size="S" /> <Divider size="S" />
@ -175,12 +158,7 @@
</div> </div>
<ul> <ul>
{#each links as link} {#each links as link}
<li <li on:click={() => handleSelected(link)}>{link.label}</li>
class:selected={value === link}
on:click={() => handleSelected(link)}
>
{link.label}
</li>
{/each} {/each}
</ul> </ul>
<Divider size="S" /> <Divider size="S" />
@ -191,8 +169,7 @@
{#each queries as query} {#each queries as query}
<li <li
class:selected={value === query} class:selected={value === query}
on:click={() => handleSelected(query)} on:click={() => handleSelected(query)}>
>
{query.label} {query.label}
</li> </li>
{/each} {/each}
@ -205,12 +182,7 @@
</div> </div>
<ul> <ul>
{#each otherSources as source} {#each otherSources as source}
<li <li on:click={() => handleSelected(source)}>{source.label}</li>
class:selected={value === source}
on:click={() => handleSelected(source)}
>
{source.label}
</li>
{/each} {/each}
</ul> </ul>
{/if} {/if}
@ -246,15 +218,15 @@
cursor: pointer; cursor: pointer;
margin: 0px; margin: 0px;
padding: var(--spacing-s) var(--spacing-m); padding: var(--spacing-s) var(--spacing-m);
font-size: var(--font-size-xs); font-size: var(--font-size-m);
} }
.selected { .selected {
background-color: var(--grey-4); color: var(--spectrum-global-color-blue-600);
} }
li:hover { li:hover {
background-color: var(--grey-4); background-color: var(--spectrum-global-color-gray-200);
} }
.drawer-contents { .drawer-contents {