Skip to content

Commit 6f2c89a

Browse files
Improve federation support (#102)
* Fix typos causing code to fail * Apply same logic to fed:missing as to fed:backends * Hide notice if missing backend is irrelevant * Prevent FedMissingNotice in non-federation context I returned `true` too eagerly :D When it's not a federation context, of course supportedBy is undefined, so affectedByMissing became true. The Notice didn't render anyway because of further checks in the component itself, but it was added to the DOM and that should be avoided too. * Hide notice if `missing` is empty array * Unify fed notice layouts and improve their texts (see #100, #101) * Apply suggestions from code review (cleanup and style) Co-authored-by: Matthias Mohr <webmaster@mamo-net.de> * Change texts of federation notices (see #100, #101, #102) --------- Co-authored-by: Matthias Mohr <webmaster@mamo-net.de>
1 parent a0b94b6 commit 6f2c89a

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

components/Collection.vue

+21-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<Description :description="stac.description"></Description>
2323
<DeprecationNotice v-if="stac.deprecated" entity="collection" />
2424
<FederationNotice v-if="supportedBy" :backends="supportedBy" :federation="federation" entity="collection" />
25-
<FederationMissing v-if="stac['federation:missing']" :missing="stac['federation:missing']" :federation="federation" />
25+
<FederationMissingNotice v-if="affectedByMissing" :missing="missing" :federation="federation" />
2626
</section>
2727

2828
<section class="license">
@@ -178,8 +178,8 @@ export default {
178178
},
179179
computed: {
180180
supportedBy() {
181-
if (Utils.isObject(this.stac.summary) && Array.isArray(this.stac.summary['federation:backends'])) {
182-
return this.stac.summary['federation:backends'];
181+
if (Utils.isObject(this.stac.summaries) && Array.isArray(this.stac.summaries['federation:backends'])) {
182+
return this.stac.summaries['federation:backends'];
183183
}
184184
else if (Array.isArray(this.stac['federation:backends'])) {
185185
return this.stac['federation:backends'];
@@ -188,6 +188,24 @@ export default {
188188
return undefined;
189189
}
190190
},
191+
missing() {
192+
if (Utils.isObject(this.stac.summaries) && Array.isArray(this.stac.summaries['federation:missing'])) {
193+
return this.stac.summaries['federation:missing'];
194+
}
195+
else if (Array.isArray(this.stac['federation:missing'])) {
196+
return this.stac['federation:missing'];
197+
}
198+
else {
199+
return undefined;
200+
}
201+
},
202+
affectedByMissing() {
203+
if (this.missing && !Array.isArray(this.supportedBy)) { // in case missing is set but supportedBy is unexpectedly not an array...
204+
return true; // default to display the notice (don't hold back information when we can't be sure)
205+
} else { // otherwise: check if any of the missing backends is actually in the list of backends that are relevant here
206+
return Array.isArray(this.missing) && this.missing.some(backend => this.supportedBy.includes(backend));
207+
}
208+
},
191209
showMap() {
192210
return this.boundingBoxes.length > 0 && !this.worldwide;
193211
},

components/Collections.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
2323
<template #content-start="scope">
2424
<slot name="content-start" v-bind="scope"></slot>
25-
<FederationMissingNotice v-if="missing" :missing="missing" :federation="federation" />
25+
<FederationMissingNotice v-if="Array.isArray(missing) && missing.length > 0" :missing="missing" :federation="federation" />
2626
</template>
2727
<template #after-search-box="scope"><slot name="after-search-box" v-bind="scope"></slot></template>
2828
<template #summary="scope"><slot name="summary" v-bind="scope" /></template>

components/FederationMissingNotice.vue

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
<AsyncButton v-if="retry" confirm class="retry" :fn="retry">Retry</AsyncButton>
44
<strong class="header">Incomplete</strong>
55
<p>
6-
The following list is incomplete as at least one of the services in the federation is currently not available.
7-
The data for the following services is missing: {{ services.join(', ') }}
6+
This data is incomplete as the following service{{services.length > 1 ? 's' : ''}} in the federation {{services.length > 1 ? 'are' : 'is'}} currently unavailable:
87
</p>
8+
<ul>
9+
<li v-for="service in services">
10+
<div class="fed-header">
11+
<strong class="fed-title">{{ service }}</strong>
12+
<ul class="badges small inline">
13+
<li class="badge red">offline</li>
14+
</ul>
15+
</div>
16+
</li>
17+
</ul>
918
</section>
1019
</template>
1120

components/FileFormats.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
:collapsed="collapsed"
1717
@detailsToggled="detailsToggled">
1818
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
19-
<template v-if="missing" #content-start><FederationMissingNotice :missing="missing" :federation="federation" /></template>
19+
<template v-if="Array.isArray(missing) && missing.length > 0" #content-start><FederationMissingNotice :missing="missing" :federation="federation" /></template>
2020
<template #summary="slot">
2121
<slot name="summary" v-bind="slot">
2222
<strong class="inline">{{ slot.item.name }}</strong>

components/Processes.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@detailsToggled="detailsToggled"
1919
allowCopy>
2020
<template #heading="scope"><slot name="heading" v-bind="scope" /></template>
21-
<template #content-start v-if="missing"><FederationMissingNotice :missing="missing" :federation="federation" /></template>
21+
<template #content-start v-if="Array.isArray(missing) && missing.length > 0"><FederationMissingNotice :missing="missing" :federation="federation" /></template>
2222
<template #summary="scope"><slot name="summary" v-bind="scope" /></template>
2323
<template #details="slot">
2424
<Process :process="slot.item" :provideDownload="provideDownload" :processUrl="processUrl" :showGraph="showGraph" :federation="federation">

components/internal/FederationNotice.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<section v-if="unsupported.length > 0" class="vue-component message-block federation federation-backends">
33
<strong class="header">Federation</strong>
4-
<p>This {{ entity }} is only available through the following services in the federation:</p>
4+
<p>This {{ entity }} is only available through the following service{{ services.length > 1 ? 's' : '' }} in the federation:</p>
55
<ul>
66
<li v-for="service in services" :key="service.url">
77
<div class="fed-header">

0 commit comments

Comments
 (0)