Skip to content

Commit 6a67f42

Browse files
committed
data source disappear from site data during loading and when there is a loading error
1 parent a364692 commit 6a67f42

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/storage.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export default (editor: Editor) => {
2626
const newDataSources: IDataSource[] = (data.dataSources || [] as GraphQLOptions[])
2727
.map((ds: GraphQLOptions) => new GraphQL(ds))
2828

29-
await Promise.all(newDataSources.map((ds: IDataSource) => ds.connect()))
30-
3129
// Get all data sources
3230
const dataSources = getAllDataSources()
3331
// Keep only data sources from the config
@@ -37,10 +35,10 @@ export default (editor: Editor) => {
3735
resetDataSources(dataSources)
3836

3937
// Add the new data sources
40-
await Promise.all(newDataSources.map(ds => {
38+
newDataSources.forEach(ds => {
4139
addDataSource(ds)
42-
return ds.connect()
43-
}))
40+
})
41+
4442
refreshDataSources()
4543
})
4644
}

src/view/settings.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ class DataSourceCard extends LitElement {
548548

549549
private loadingIcon = html`<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="3"><animate attributeName="r" values="3;8;3" dur="1s" repeatCount="indefinite"/><animate attributeName="opacity" values="1;0.3;1" dur="1s" repeatCount="indefinite"/></circle></svg>`
550550
private connectedIcon = html`<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>`
551+
private errorIcon = html`<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/></svg>`
551552

552553
constructor() {
553554
super()
@@ -598,6 +599,9 @@ class DataSourceCard extends LitElement {
598599
.ds-card__status--loading {
599600
color: var(--ds-highlight);
600601
}
602+
.ds-card__status--error {
603+
color: var(--ds-highlight);
604+
}
601605
.ds-card__actions {
602606
display: flex;
603607
gap: 8px;
@@ -649,7 +653,11 @@ class DataSourceCard extends LitElement {
649653
<div class="ds-card__status ds-card__status--connected">
650654
${this.connectedIcon} Connected
651655
</div>
652-
` : ''}
656+
` : html`
657+
<div class="ds-card__status ds-card__status--error">
658+
${this.errorIcon} Not connected
659+
</div>
660+
`}
653661
</div>
654662
<div class="ds-card__actions">
655663
<button

0 commit comments

Comments
 (0)