2020-10-24 23:57:45 +05:30
|
|
|
<script>
|
2021-04-29 21:17:54 +05:30
|
|
|
import { GlDrawer, GlInfiniteScroll, GlResizeObserverDirective } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mapState, mapActions } from 'vuex';
|
2021-01-03 14:25:43 +05:30
|
|
|
import Tracking from '~/tracking';
|
2021-01-29 00:20:46 +05:30
|
|
|
import { getDrawerBodyHeight } from '../utils/get_drawer_body_height';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Feature from './feature.vue';
|
|
|
|
import SkeletonLoader from './skeleton_loader.vue';
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
const trackingMixin = Tracking.mixin();
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlDrawer,
|
2021-01-29 00:20:46 +05:30
|
|
|
GlInfiniteScroll,
|
2021-01-03 14:25:43 +05:30
|
|
|
SkeletonLoader,
|
2021-02-22 17:27:13 +05:30
|
|
|
Feature,
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
directives: {
|
|
|
|
GlResizeObserver: GlResizeObserverDirective,
|
|
|
|
},
|
2021-01-03 14:25:43 +05:30
|
|
|
mixins: [trackingMixin],
|
2020-11-24 15:15:51 +05:30
|
|
|
props: {
|
2021-04-29 21:17:54 +05:30
|
|
|
versionDigest: {
|
2020-11-24 15:15:51 +05:30
|
|
|
type: String,
|
2021-01-03 14:25:43 +05:30
|
|
|
required: true,
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
computed: {
|
2021-02-22 17:27:13 +05:30
|
|
|
...mapState(['open', 'features', 'pageInfo', 'drawerBodyHeight', 'fetching']),
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
mounted() {
|
2021-04-29 21:17:54 +05:30
|
|
|
this.openDrawer(this.versionDigest);
|
2021-06-08 01:23:25 +05:30
|
|
|
this.fetchFreshItems();
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
const body = document.querySelector('body');
|
|
|
|
const namespaceId = body.getAttribute('data-namespace-id');
|
|
|
|
|
|
|
|
this.track('click_whats_new_drawer', { label: 'namespace_id', value: namespaceId });
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2021-01-29 00:20:46 +05:30
|
|
|
...mapActions(['openDrawer', 'closeDrawer', 'fetchItems', 'setDrawerBodyHeight']),
|
|
|
|
bottomReached() {
|
2021-02-22 17:27:13 +05:30
|
|
|
const page = this.pageInfo.nextPage;
|
|
|
|
if (page) {
|
2021-06-08 01:23:25 +05:30
|
|
|
this.fetchFreshItems(page);
|
2021-01-29 00:20:46 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
handleResize() {
|
|
|
|
const height = getDrawerBodyHeight(this.$refs.drawer.$el);
|
|
|
|
this.setDrawerBodyHeight(height);
|
|
|
|
},
|
2021-06-08 01:23:25 +05:30
|
|
|
fetchFreshItems(page) {
|
|
|
|
const { versionDigest } = this;
|
|
|
|
|
|
|
|
this.fetchItems({ page, versionDigest });
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
2021-01-29 00:20:46 +05:30
|
|
|
<gl-drawer
|
|
|
|
ref="drawer"
|
|
|
|
v-gl-resize-observer="handleResize"
|
2021-06-08 01:23:25 +05:30
|
|
|
class="whats-new-drawer gl-reset-line-height"
|
2021-03-08 18:12:59 +05:30
|
|
|
:z-index="700"
|
2021-01-29 00:20:46 +05:30
|
|
|
:open="open"
|
|
|
|
@close="closeDrawer"
|
|
|
|
>
|
2021-09-30 23:02:18 +05:30
|
|
|
<template #title>
|
2021-03-08 18:12:59 +05:30
|
|
|
<h4 class="page-title gl-my-2">{{ __("What's new") }}</h4>
|
2020-10-24 23:57:45 +05:30
|
|
|
</template>
|
2021-02-22 17:27:13 +05:30
|
|
|
<template v-if="features.length">
|
|
|
|
<gl-infinite-scroll
|
|
|
|
:fetched-items="features.length"
|
|
|
|
:max-list-height="drawerBodyHeight"
|
|
|
|
class="gl-p-0"
|
|
|
|
@bottomReached="bottomReached"
|
|
|
|
>
|
|
|
|
<template #items>
|
|
|
|
<feature v-for="feature in features" :key="feature.title" :feature="feature" />
|
|
|
|
</template>
|
|
|
|
</gl-infinite-scroll>
|
|
|
|
</template>
|
2021-01-29 00:20:46 +05:30
|
|
|
<div v-else class="gl-mt-5">
|
|
|
|
<skeleton-loader />
|
|
|
|
<skeleton-loader />
|
2020-11-24 15:15:51 +05:30
|
|
|
</div>
|
2020-10-24 23:57:45 +05:30
|
|
|
</gl-drawer>
|
2021-06-08 01:23:25 +05:30
|
|
|
<div v-if="open" class="whats-new-modal-backdrop modal-backdrop" @click="closeDrawer"></div>
|
2020-10-24 23:57:45 +05:30
|
|
|
</div>
|
|
|
|
</template>
|