Show fetch errors

This commit is contained in:
Vincent Fiduccia 2021-08-11 17:26:35 -07:00
parent ca9575215b
commit 62b60e4415
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
2 changed files with 130 additions and 123 deletions

View File

@ -1,5 +1,6 @@
<script>
import Loading from '@/components/Loading';
import Banner from '@/components/Banner';
import ResourceTable from '@/components/ResourceTable';
import ResourceTabs from '@/components/form/ResourceTabs';
import SortableTable from '@/components/SortableTable';
@ -16,6 +17,7 @@ import AsyncButton from '@/components/AsyncButton.vue';
export default {
components: {
Loading,
Banner,
ResourceTable,
ResourceTabs,
SortableTable,
@ -354,137 +356,140 @@ export default {
<template>
<Loading v-if="$fetchState.pending" />
<ResourceTabs v-else v-model="value" :default-tab="defaultTab">
<Tab v-if="showMachines" name="machine-pools" :label-key="value.isCustom ? 'cluster.tabs.machines' : 'cluster.tabs.machinePools'" :weight="3">
<ResourceTable
:rows="machines"
:schema="machineSchema"
:headers="machineHeaders"
default-sort-by="name"
:groupable="false"
:group-by="value.isCustom ? null : 'poolId'"
group-ref="pool"
:group-sort="['pool.nameDisplay']"
>
<template #main-row:isFake="{fullColspan}">
<tr class="main-row">
<td :colspan="fullColspan" class="no-entries">
{{ t('node.list.noNodes') }}
</td>
</tr>
</template>
<div v-else>
<Banner v-if="$fetchState.error" color="error" :label="$fetchState.error" />
<ResourceTabs v-model="value" :default-tab="defaultTab">
<Tab v-if="showMachines" name="machine-pools" :label-key="value.isCustom ? 'cluster.tabs.machines' : 'cluster.tabs.machinePools'" :weight="3">
<ResourceTable
:rows="machines"
:schema="machineSchema"
:headers="machineHeaders"
default-sort-by="name"
:groupable="false"
:group-by="value.isCustom ? null : 'poolId'"
group-ref="pool"
:group-sort="['pool.nameDisplay']"
>
<template #main-row:isFake="{fullColspan}">
<tr class="main-row">
<td :colspan="fullColspan" class="no-entries">
{{ t('node.list.noNodes') }}
</td>
</tr>
</template>
<template #group-by="{group}">
<div class="pool-row" :class="{'has-description':group.ref && group.ref.template}">
<div v-trim-whitespace class="group-tab">
<div v-if="group && group.ref" v-html="group.ref.groupByPoolShortLabel" />
<div v-else v-html="t('resourceTable.groupLabel.notInANodePool')">
<template #group-by="{group}">
<div class="pool-row" :class="{'has-description':group.ref && group.ref.template}">
<div v-trim-whitespace class="group-tab">
<div v-if="group && group.ref" v-html="group.ref.groupByPoolShortLabel" />
<div v-else v-html="t('resourceTable.groupLabel.notInANodePool')">
</div>
<div v-if="group.ref && group.ref.template" class="description text-muted text-small">
{{ group.ref.providerDisplay }} &ndash; {{ group.ref.providerLocation }} / {{ group.ref.providerSize }} ({{ group.ref.providerName }})
</div>
</div>
<div v-if="group.ref && group.ref.template" class="description text-muted text-small">
{{ group.ref.providerDisplay }} &ndash; {{ group.ref.providerLocation }} / {{ group.ref.providerSize }} ({{ group.ref.providerName }})
<div v-if="group.ref" class="right mr-45">
<template v-if="value.hasLink('update')">
<button v-tooltip="t('node.list.scaleDown')" :disabled="group.ref.spec.replicas < 2" type="button" class="btn btn-sm role-secondary" @click="group.ref.scalePool(-1)">
<i class="icon icon-sm icon-minus" />
</button>
<button v-tooltip="t('node.list.scaleUp')" type="button" class="btn btn-sm role-secondary ml-10" @click="group.ref.scalePool(1)">
<i class="icon icon-sm icon-plus" />
</button>
</template>
</div>
</div>
<div v-if="group.ref" class="right mr-45">
<template v-if="value.hasLink('update')">
<button v-tooltip="t('node.list.scaleDown')" :disabled="group.ref.spec.replicas < 2" type="button" class="btn btn-sm role-secondary" @click="group.ref.scalePool(-1)">
<i class="icon icon-sm icon-minus" />
</button>
<button v-tooltip="t('node.list.scaleUp')" type="button" class="btn btn-sm role-secondary ml-10" @click="group.ref.scalePool(1)">
<i class="icon icon-sm icon-plus" />
</button>
</template>
</div>
</div>
</template>
</ResourceTable>
</Tab>
<Tab v-else-if="showNodes" name="node-pools" :label-key="value.isCustom ? 'cluster.tabs.machines' : 'cluster.tabs.machinePools'" :weight="3">
<ResourceTable
:schema="mgmtNodeSchema"
:headers="mgmtNodeSchemaHeaders"
:rows="nodes"
:groupable="false"
:group-by="value.isCustom ? null : 'spec.nodePoolName'"
group-ref="pool"
:group-sort="['pool.nameDisplay']"
>
<template #main-row:isFake="{fullColspan}">
<tr class="main-row">
<td :colspan="fullColspan" class="no-entries">
{{ t('node.list.noNodes') }}
</td>
</tr>
</template>
</template>
</ResourceTable>
</Tab>
<Tab v-else-if="showNodes" name="node-pools" :label-key="value.isCustom ? 'cluster.tabs.machines' : 'cluster.tabs.machinePools'" :weight="3">
<ResourceTable
:schema="mgmtNodeSchema"
:headers="mgmtNodeSchemaHeaders"
:rows="nodes"
:groupable="false"
:group-by="value.isCustom ? null : 'spec.nodePoolName'"
group-ref="pool"
:group-sort="['pool.nameDisplay']"
>
<template #main-row:isFake="{fullColspan}">
<tr class="main-row">
<td :colspan="fullColspan" class="no-entries">
{{ t('node.list.noNodes') }}
</td>
</tr>
</template>
<template #group-by="{group}">
<div class="pool-row" :class="{'has-description':group.ref && group.ref.nodeTemplate}">
<div v-trim-whitespace class="group-tab">
<div v-if="group.ref" v-html="t('resourceTable.groupLabel.nodePool', { name: group.ref.spec.hostnamePrefix, count: group.rows.length}, true)">
<template #group-by="{group}">
<div class="pool-row" :class="{'has-description':group.ref && group.ref.nodeTemplate}">
<div v-trim-whitespace class="group-tab">
<div v-if="group.ref" v-html="t('resourceTable.groupLabel.nodePool', { name: group.ref.spec.hostnamePrefix, count: group.rows.length}, true)">
</div>
<div v-else v-html="t('resourceTable.groupLabel.notInANodePool')">
</div>
<div v-if="group.ref && group.ref.nodeTemplate" class="description text-muted text-small">
{{ group.ref.providerDisplay }} &ndash; {{ group.ref.providerLocation }} / {{ group.ref.providerSize }} ({{ group.ref.providerName }})
</div>
</div>
<div v-else v-html="t('resourceTable.groupLabel.notInANodePool')">
</div>
<div v-if="group.ref && group.ref.nodeTemplate" class="description text-muted text-small">
{{ group.ref.providerDisplay }} &ndash; {{ group.ref.providerLocation }} / {{ group.ref.providerSize }} ({{ group.ref.providerName }})
<div v-if="group.ref" class="right">
<template v-if="group.ref.hasLink('update')">
<button v-tooltip="t('node.list.scaleDown')" :disabled="group.ref.spec.quantity < 2" type="button" class="btn btn-sm role-secondary" @click="group.ref.scalePool(-1)">
<i class="icon icon-sm icon-minus" />
</button>
<button v-tooltip="t('node.list.scaleUp')" type="button" class="btn btn-sm role-secondary ml-10" @click="group.ref.scalePool(1)">
<i class="icon icon-sm icon-plus" />
</button>
</template>
<button type="button" class="project-action btn btn-sm role-multi-action actions mr-5 ml-15" :class="{invisible: !showPoolActionButton(group.ref)}" @click="showPoolAction($event, group.ref)">
<i class="icon icon-actions" />
</button>
</div>
</div>
<div v-if="group.ref" class="right">
<template v-if="group.ref.hasLink('update')">
<button v-tooltip="t('node.list.scaleDown')" :disabled="group.ref.spec.quantity < 2" type="button" class="btn btn-sm role-secondary" @click="group.ref.scalePool(-1)">
<i class="icon icon-sm icon-minus" />
</button>
<button v-tooltip="t('node.list.scaleUp')" type="button" class="btn btn-sm role-secondary ml-10" @click="group.ref.scalePool(1)">
<i class="icon icon-sm icon-plus" />
</button>
</template>
</template>
</ResourceTable>
</Tab>
<button type="button" class="project-action btn btn-sm role-multi-action actions mr-5 ml-15" :class="{invisible: !showPoolActionButton(group.ref)}" @click="showPoolAction($event, group.ref)">
<i class="icon icon-actions" />
</button>
</div>
</div>
<Tab v-if="showRegistration" name="registration" label="Registration" :weight="2">
<CustomCommand v-if="value.isCustom" :cluster-token="clusterToken" :cluster="value" />
<template v-else>
<h4 v-html="t('cluster.import.commandInstructions', null, true)" />
<CopyCode class="m-10 p-10">
{{ clusterToken.command }}
</CopyCode>
<h4 class="mt-10" v-html="t('cluster.import.commandInstructionsInsecure', null, true)" />
<CopyCode class="m-10 p-10">
{{ clusterToken.insecureCommand }}
</CopyCode>
<h4 class="mt-10" v-html="t('cluster.import.clusterRoleBindingInstructions', null, true)" />
<CopyCode class="m-10 p-10">
{{ t('cluster.import.clusterRoleBindingCommand', null, true) }}
</CopyCode>
</template>
</ResourceTable>
</Tab>
</Tab>
<Tab v-if="showRegistration" name="registration" label="Registration" :weight="2">
<CustomCommand v-if="value.isCustom" :cluster-token="clusterToken" :cluster="value" />
<template v-else>
<h4 v-html="t('cluster.import.commandInstructions', null, true)" />
<CopyCode class="m-10 p-10">
{{ clusterToken.command }}
</CopyCode>
<h4 class="mt-10" v-html="t('cluster.import.commandInstructionsInsecure', null, true)" />
<CopyCode class="m-10 p-10">
{{ clusterToken.insecureCommand }}
</CopyCode>
<h4 class="mt-10" v-html="t('cluster.import.clusterRoleBindingInstructions', null, true)" />
<CopyCode class="m-10 p-10">
{{ t('cluster.import.clusterRoleBindingCommand', null, true) }}
</CopyCode>
</template>
</Tab>
<Tab v-if="showSnapshots" name="snapshots" label="Snapshots" :weight="1">
<SortableTable
:headers="value.isRke1 ? rke1SnapshotHeaders : rke2SnapshotHeaders"
default-sort-by="age"
:table-actions="value.isRke1"
:rows="value.isRke1 ? rke1Snapshots : rke2Snapshots"
:search="false"
>
<template #header-right>
<AsyncButton
mode="snapshot"
class="btn role-primary"
:disabled="!isClusterReady"
@click="takeSnapshot"
/>
</template>
</SortableTable>
</Tab>
</ResourceTabs>
<Tab v-if="showSnapshots" name="snapshots" label="Snapshots" :weight="1">
<SortableTable
:headers="value.isRke1 ? rke1SnapshotHeaders : rke2SnapshotHeaders"
default-sort-by="age"
:table-actions="value.isRke1"
:rows="value.isRke1 ? rke1Snapshots : rke2Snapshots"
:search="false"
>
<template #header-right>
<AsyncButton
mode="snapshot"
class="btn role-primary"
:disabled="!isClusterReady"
@click="takeSnapshot"
/>
</template>
</SortableTable>
</Tab>
</ResourceTabs>
</div>
</template>
<style lang='scss' scoped>

View File

@ -4,7 +4,6 @@ import ResourceTable from '@/components/ResourceTable';
import Masthead from '@/components/ResourceList/Masthead';
import { NORMAN, SECRET } from '@/config/types';
import { AGE_NORMAN, DESCRIPTION, NAME_UNLINKED } from '@/config/table-headers';
import { CLOUD_CREDENTIAL, _FLAGGED } from '@/config/query-params';
export default {
components: {
@ -12,7 +11,11 @@ export default {
},
async fetch() {
this.allSecrets = await this.$store.dispatch('management/findAll', { type: SECRET });
if ( this.$store.getters['management/schemaFor'](SECRET) ) {
// Having secrets allows showing the public poirtion of more types but not all users can see them.
await this.$store.dispatch('management/findAll', { type: SECRET });
}
this.allCredentials = await this.$store.dispatch('rancher/findAll', { type: NORMAN.CLOUD_CREDENTIAL });
},
@ -52,7 +55,6 @@ export default {
product: this.$store.getters['currentProduct'].name,
resource: this.resource
},
query: { [CLOUD_CREDENTIAL]: _FLAGGED }
};
},
},