stash
This commit is contained in:
parent
d56784eb8d
commit
6ee5ae38b1
8 changed files with 246 additions and 153 deletions
|
|
@ -2,6 +2,10 @@
|
|||
<BaseLayout hide-search>
|
||||
<main class="content">
|
||||
<div class="container-fluid p-0">
|
||||
<div v-if="qualified" class="card">
|
||||
<div class="card-header">Domain</div>
|
||||
<div class="card-body">{{ qualified.domain }}</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">Decoded</div>
|
||||
<div class="card-body">
|
||||
|
|
@ -64,8 +68,11 @@
|
|||
<script>
|
||||
import {mapActions} from 'vuex';
|
||||
import BaseLayout from '@/components/BaseLayout.vue';
|
||||
import {decodeShortId, deserializeShortId, encodeShortId, serializeShortId} from '@/short-id';
|
||||
import {expandedRoute as buildExpandedRoute, NEEDS_IDMAP} from '@/router';
|
||||
import {
|
||||
decodeShortId, deserializeShortId, encodeShortId, serializeShortId,
|
||||
isDomainQualifiedShortId, decodeDomainQualifiedShortId
|
||||
} from '@/short-id';
|
||||
import {expandedRoute as buildExpandedRoute, NEEDS_IDMAP, domainQualifiedRoute} from '@/router';
|
||||
|
||||
const EXAMPLES = [
|
||||
{kind: 'item', owner_identity_id: 7, item_local_id: 42},
|
||||
|
|
@ -130,12 +137,17 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
error: null
|
||||
error: null,
|
||||
foreignRoute: undefined,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// '<domain>:~<token>' vs a bare '~<token>' - see docs/handles-and-shortids.md#domain-qualified-short-id.
|
||||
qualified() {
|
||||
return isDomainQualifiedShortId(this.short_id) ? decodeDomainQualifiedShortId(this.short_id) : null;
|
||||
},
|
||||
decoded() {
|
||||
return decodeShortId(this.short_id);
|
||||
return this.qualified ? this.qualified.ints : decodeShortId(this.short_id);
|
||||
},
|
||||
deserialized() {
|
||||
return deserializeShortId(this.decoded);
|
||||
|
|
@ -145,7 +157,7 @@ export default {
|
|||
return fields;
|
||||
},
|
||||
expandedRoute() {
|
||||
return buildExpandedRoute(this.deserialized);
|
||||
return this.qualified ? (this.foreignRoute || null) : buildExpandedRoute(this.deserialized);
|
||||
},
|
||||
examples() {
|
||||
return EXAMPLES.map(named => {
|
||||
|
|
@ -165,13 +177,21 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['fetchIdMap'])
|
||||
...mapActions(['fetchIdMap']),
|
||||
async resolveIfQualified() {
|
||||
if (this.qualified) {
|
||||
this.foreignRoute = await domainQualifiedRoute(this.qualified.domain, this.decoded) || null;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.resolveIfQualified();
|
||||
if (NEEDS_IDMAP.has(this.deserialized.kind) && !this.$store.state.idmapLoaded) {
|
||||
this.fetchIdMap().catch(e => {
|
||||
this.error = e.message;
|
||||
});
|
||||
this.fetchIdMap()
|
||||
.then(() => this.resolveIfQualified())
|
||||
.catch(e => {
|
||||
this.error = e.message;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue