mirror of https://github.com/rancher/dashboard.git
106 lines
2.2 KiB
Vue
106 lines
2.2 KiB
Vue
<script>
|
|
import ResourceTable from '@/components/ResourceTable';
|
|
import { EDIT_YAML, _FLAGGED } from '@/config/query-params';
|
|
|
|
export default {
|
|
components: { ResourceTable },
|
|
|
|
data() {
|
|
let listComponent;
|
|
|
|
if ( this.hasListComponent ) {
|
|
listComponent = this.$store.getters['type-map/importList'](this.resource);
|
|
}
|
|
|
|
return {
|
|
listComponent,
|
|
EDIT_YAML,
|
|
FLAGGED: _FLAGGED
|
|
};
|
|
},
|
|
|
|
computed: {
|
|
schema() {
|
|
return this.$store.getters['cluster/schemaFor'](this.resource);
|
|
},
|
|
|
|
headers() {
|
|
return this.$store.getters['type-map/headersFor'](this.schema);
|
|
},
|
|
|
|
hasEditComponent() {
|
|
return this.$store.getters['type-map/hasCustomEdit'](this.resource);
|
|
},
|
|
|
|
hasListComponent() {
|
|
return this.$store.getters['type-map/hasCustomList'](this.resource);
|
|
},
|
|
|
|
typeDisplay() {
|
|
return this.$store.getters['type-map/pluralLabelFor'](this.schema);
|
|
},
|
|
},
|
|
|
|
async asyncData({ params, store }) {
|
|
const resource = params.resource;
|
|
|
|
const rows = await store.dispatch('cluster/findAll', { type: resource });
|
|
|
|
await store.dispatch('type-map/addRecent', resource);
|
|
|
|
return {
|
|
resource,
|
|
rows
|
|
};
|
|
},
|
|
}; </script>
|
|
|
|
<template>
|
|
<div>
|
|
<header>
|
|
<h1>
|
|
{{ typeDisplay }}
|
|
</h1>
|
|
<div class="actions">
|
|
<nuxt-link :to="{path: 'create', params: {'as-yaml': null}}" append tag="button" type="button" class="btn bg-primary">
|
|
Import
|
|
</nuxt-link>
|
|
<nuxt-link
|
|
v-if="hasEditComponent"
|
|
to="create"
|
|
append
|
|
tag="button"
|
|
type="button"
|
|
class="btn bg-primary"
|
|
>
|
|
Create
|
|
</nuxt-link>
|
|
</div>
|
|
</header>
|
|
<div v-if="hasListComponent">
|
|
<component
|
|
:is="listComponent"
|
|
:schema="schema"
|
|
:rows="rows"
|
|
:headers="headers"
|
|
/>
|
|
</div>
|
|
<ResourceTable v-else :schema="schema" :rows="rows" :headers="headers" />
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.header {
|
|
position: relative;
|
|
}
|
|
H2 {
|
|
position: relative;
|
|
margin: 0 0 20px 0;
|
|
}
|
|
.right-action {
|
|
position: absolute;
|
|
top: 10px;
|
|
right: 10px;
|
|
}
|
|
</style>
|