debian-mirror-gitlab/app/assets/javascripts/releases/components/app_index.vue

121 lines
3.2 KiB
Vue
Raw Normal View History

2019-02-15 15:39:39 +05:30
<script>
import { mapState, mapActions } from 'vuex';
2021-01-03 14:25:43 +05:30
import { GlEmptyState, GlLink, GlButton } from '@gitlab/ui';
import { getParameterByName } from '~/lib/utils/common_utils';
2020-04-08 14:13:33 +05:30
import { __ } from '~/locale';
2019-02-15 15:39:39 +05:30
import ReleaseBlock from './release_block.vue';
2021-01-03 14:25:43 +05:30
import ReleasesPagination from './releases_pagination.vue';
import ReleaseSkeletonLoader from './release_skeleton_loader.vue';
2019-02-15 15:39:39 +05:30
export default {
name: 'ReleasesApp',
components: {
GlEmptyState,
2020-04-08 14:13:33 +05:30
GlLink,
2020-05-24 23:13:21 +05:30
GlButton,
2021-01-03 14:25:43 +05:30
ReleaseBlock,
ReleasesPagination,
ReleaseSkeletonLoader,
2019-02-15 15:39:39 +05:30
},
computed: {
2020-11-24 15:15:51 +05:30
...mapState('list', [
'documentationPath',
'illustrationPath',
'newReleasePath',
'isLoading',
'releases',
'hasError',
]),
2019-02-15 15:39:39 +05:30
shouldRenderEmptyState() {
return !this.releases.length && !this.hasError && !this.isLoading;
},
shouldRenderSuccessState() {
return this.releases.length && !this.isLoading && !this.hasError;
},
2020-04-08 14:13:33 +05:30
emptyStateText() {
return __(
"Releases are based on Git tags and mark specific points in a project's development history. They can contain information about the type of changes and can also deliver binaries, like compiled versions of your software.",
);
},
2019-02-15 15:39:39 +05:30
},
created() {
2021-01-03 14:25:43 +05:30
this.fetchReleases();
window.addEventListener('popstate', this.fetchReleases);
2019-02-15 15:39:39 +05:30
},
methods: {
2021-01-03 14:25:43 +05:30
...mapActions('list', {
fetchReleasesStoreAction: 'fetchReleases',
}),
fetchReleases() {
this.fetchReleasesStoreAction({
// these two parameters are only used in "GraphQL mode"
before: getParameterByName('before'),
after: getParameterByName('after'),
// this parameter is only used when in "REST mode"
page: getParameterByName('page'),
});
2020-01-01 13:55:28 +05:30
},
2019-02-15 15:39:39 +05:30
},
};
</script>
<template>
2020-04-08 14:13:33 +05:30
<div class="flex flex-column mt-2">
2020-05-24 23:13:21 +05:30
<gl-button
2020-04-08 14:13:33 +05:30
v-if="newReleasePath"
:href="newReleasePath"
:aria-describedby="shouldRenderEmptyState && 'releases-description'"
2020-05-24 23:13:21 +05:30
category="primary"
variant="success"
class="align-self-end mb-2 js-new-release-btn"
2020-04-08 14:13:33 +05:30
>
{{ __('New release') }}
2020-05-24 23:13:21 +05:30
</gl-button>
2020-04-08 14:13:33 +05:30
2021-01-03 14:25:43 +05:30
<release-skeleton-loader v-if="isLoading" class="js-loading" />
2019-02-15 15:39:39 +05:30
<gl-empty-state
v-else-if="shouldRenderEmptyState"
class="js-empty-state"
:title="__('Getting started with releases')"
:svg-path="illustrationPath"
2020-04-08 14:13:33 +05:30
>
<template #description>
<span id="releases-description">
{{ emptyStateText }}
<gl-link
:href="documentationPath"
:aria-label="__('Releases documentation')"
target="_blank"
>
{{ __('More information') }}
</gl-link>
</span>
</template>
</gl-empty-state>
2019-02-15 15:39:39 +05:30
<div v-else-if="shouldRenderSuccessState" class="js-success-state">
<release-block
v-for="(release, index) in releases"
2020-04-22 19:07:51 +05:30
:key="index"
2019-02-15 15:39:39 +05:30
:release="release"
:class="{ 'linked-card': releases.length > 1 && index !== releases.length - 1 }"
/>
</div>
2020-01-01 13:55:28 +05:30
2021-01-03 14:25:43 +05:30
<releases-pagination v-if="!isLoading" />
2019-02-15 15:39:39 +05:30
</div>
</template>
<style>
.linked-card::after {
width: 1px;
content: ' ';
border: 1px solid #e5e5e5;
height: 17px;
top: 100%;
position: absolute;
left: 32px;
}
</style>