2019-02-15 15:39:39 +05:30
< script >
import { mapState , mapActions } from 'vuex' ;
2019-03-02 22:35:43 +05:30
import { GlSkeletonLoading , GlEmptyState } from '@gitlab/ui' ;
2020-01-01 13:55:28 +05:30
import {
getParameterByName ,
historyPushState ,
buildUrlWithCurrentLocation ,
} from '~/lib/utils/common_utils' ;
import TablePagination from '~/vue_shared/components/pagination/table_pagination.vue' ;
2019-02-15 15:39:39 +05:30
import ReleaseBlock from './release_block.vue' ;
export default {
name : 'ReleasesApp' ,
components : {
2019-03-02 22:35:43 +05:30
GlSkeletonLoading ,
2019-02-15 15:39:39 +05:30
GlEmptyState ,
ReleaseBlock ,
2020-01-01 13:55:28 +05:30
TablePagination ,
2019-02-15 15:39:39 +05:30
} ,
props : {
projectId : {
type : String ,
required : true ,
} ,
documentationLink : {
type : String ,
required : true ,
} ,
illustrationPath : {
type : String ,
required : true ,
} ,
} ,
computed : {
2020-03-09 13:42:32 +05:30
... mapState ( 'list' , [ 'isLoading' , 'releases' , 'hasError' , 'pageInfo' ] ) ,
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 ;
} ,
} ,
created ( ) {
2020-01-01 13:55:28 +05:30
this . fetchReleases ( {
page : getParameterByName ( 'page' ) ,
projectId : this . projectId ,
} ) ;
2019-02-15 15:39:39 +05:30
} ,
methods : {
2020-03-09 13:42:32 +05:30
... mapActions ( 'list' , [ 'fetchReleases' ] ) ,
2020-01-01 13:55:28 +05:30
onChangePage ( page ) {
historyPushState ( buildUrlWithCurrentLocation ( ` ?page= ${ page } ` ) ) ;
this . fetchReleases ( { page , projectId : this . projectId } ) ;
} ,
2019-02-15 15:39:39 +05:30
} ,
} ;
< / script >
< template >
< div class = "prepend-top-default" >
2019-03-02 22:35:43 +05:30
< gl-skeleton-loading 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"
: description = "
_ _ (
2020-03-09 13:42:32 +05:30
'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
)
"
: primary - button - link = "documentationLink"
: primary - button - text = "__('Open Documentation')"
/ >
< div v -else -if = " shouldRenderSuccessState " class = "js-success-state" >
< release-block
v - for = "(release, index) in releases"
: key = "release.tag_name"
: release = "release"
: class = "{ 'linked-card': releases.length > 1 && index !== releases.length - 1 }"
/ >
< / div >
2020-01-01 13:55:28 +05:30
< table-pagination v-if = "!isLoading" :change="onChangePage" :page-info="pageInfo" / >
2019-02-15 15:39:39 +05:30
< / 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 >