2018-12-20 04:31:32 -05:00
< script >
2020-09-24 11:09:51 -04:00
import { GlEmptyState , GlLink , GlButton } from '@gitlab/ui' ;
2021-02-14 13:09:20 -05:00
import { mapState , mapActions } from 'vuex' ;
2020-09-18 11:09:22 -04:00
import { getParameterByName } from '~/lib/utils/common_utils' ;
2020-03-13 08:09:22 -04:00
import { _ _ } from '~/locale' ;
2018-12-20 04:31:32 -05:00
import ReleaseBlock from './release_block.vue' ;
2020-09-24 11:09:51 -04:00
import ReleaseSkeletonLoader from './release_skeleton_loader.vue' ;
2021-02-14 13:09:20 -05:00
import ReleasesPagination from './releases_pagination.vue' ;
2020-11-11 13:09:10 -05:00
import ReleasesSort from './releases_sort.vue' ;
2018-12-20 04:31:32 -05:00
export default {
name : 'ReleasesApp' ,
components : {
GlEmptyState ,
2020-03-13 08:09:22 -04:00
GlLink ,
2020-05-07 17:09:26 -04:00
GlButton ,
2020-09-24 11:09:51 -04:00
ReleaseBlock ,
ReleasesPagination ,
ReleaseSkeletonLoader ,
2020-11-11 13:09:10 -05:00
ReleasesSort ,
2018-12-20 04:31:32 -05:00
} ,
computed : {
2020-09-18 05:09:32 -04:00
... mapState ( 'list' , [
'documentationPath' ,
'illustrationPath' ,
'newReleasePath' ,
'isLoading' ,
'releases' ,
'hasError' ,
] ) ,
2018-12-20 04:31:32 -05:00
shouldRenderEmptyState ( ) {
return ! this . releases . length && ! this . hasError && ! this . isLoading ;
} ,
shouldRenderSuccessState ( ) {
return this . releases . length && ! this . isLoading && ! this . hasError ;
} ,
2020-03-13 08:09:22 -04:00
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." ,
) ;
} ,
2018-12-20 04:31:32 -05:00
} ,
created ( ) {
2020-09-18 11:09:22 -04:00
this . fetchReleases ( ) ;
window . addEventListener ( 'popstate' , this . fetchReleases ) ;
2018-12-20 04:31:32 -05:00
} ,
methods : {
2020-09-18 11:09:22 -04:00
... 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' ) ,
} ) ;
2019-11-22 13:06:00 -05:00
} ,
2018-12-20 04:31:32 -05:00
} ,
} ;
< / script >
< template >
2020-03-13 08:09:22 -04:00
< div class = "flex flex-column mt-2" >
2020-11-11 13:09:10 -05:00
< div class = "gl-align-self-end gl-mb-3" >
< releases-sort class = "gl-mr-2" @sort:changed ="fetchReleases" / >
< gl-button
v - if = "newReleasePath"
: href = "newReleasePath"
: aria - describedby = "shouldRenderEmptyState && 'releases-description'"
category = "primary"
variant = "success"
class = "js-new-release-btn"
>
{ { _ _ ( 'New release' ) } }
< / gl-button >
< / div >
2020-03-13 08:09:22 -04:00
2020-09-24 11:09:51 -04:00
< release-skeleton-loader v-if = "isLoading" class="js-loading" / >
2018-12-20 04:31:32 -05:00
< gl-empty-state
v - else - if = "shouldRenderEmptyState"
class = "js-empty-state"
: title = "__('Getting started with releases')"
: svg - path = "illustrationPath"
2020-03-13 08:09:22 -04:00
>
< 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 >
2018-12-20 04:31:32 -05:00
< div v -else -if = " shouldRenderSuccessState " class = "js-success-state" >
< release-block
v - for = "(release, index) in releases"
2020-04-01 17:07:56 -04:00
: key = "index"
2018-12-20 04:31:32 -05:00
: release = "release"
: class = "{ 'linked-card': releases.length > 1 && index !== releases.length - 1 }"
/ >
< / div >
2019-11-22 13:06:00 -05:00
2020-09-18 11:09:22 -04:00
< releases-pagination v-if = "!isLoading" / >
2018-12-20 04:31:32 -05:00
< / div >
< / template >
< style >
. linked - card : : after {
width : 1 px ;
content : ' ' ;
border : 1 px solid # e5e5e5 ;
height : 17 px ;
top : 100 % ;
position : absolute ;
left : 32 px ;
}
< / style >