2019-02-15 15:39:39 +05:30
< script >
2021-01-03 14:25:43 +05:30
import { GlEmptyState , GlLink , GlButton } 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 { 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 ReleaseSkeletonLoader from './release_skeleton_loader.vue' ;
2021-03-11 19:13:27 +05:30
import ReleasesPagination from './releases_pagination.vue' ;
2021-01-29 00:20:46 +05:30
import ReleasesSort from './releases_sort.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 ,
2021-01-29 00:20:46 +05:30
ReleasesSort ,
2019-02-15 15:39:39 +05:30
} ,
computed : {
2021-04-29 21:17:54 +05:30
... mapState ( 'index' , [
2020-11-24 15:15:51 +05:30
'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-04-29 21:17:54 +05:30
... mapActions ( 'index' , {
2021-01-03 14:25:43 +05:30
fetchReleasesStoreAction : 'fetchReleases' ,
} ) ,
fetchReleases ( ) {
this . fetchReleasesStoreAction ( {
before : getParameterByName ( 'before' ) ,
after : getParameterByName ( 'after' ) ,
} ) ;
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" >
2021-01-29 00:20:46 +05:30
< 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"
2021-06-08 01:23:25 +05:30
data - testid = "new-release-button"
2021-01-29 00:20:46 +05:30
>
{ { _ _ ( 'New release' ) } }
< / gl-button >
< / div >
2020-04-08 14:13:33 +05:30
2021-06-08 01:23:25 +05:30
< release-skeleton-loader v-if = "isLoading" / >
2019-02-15 15:39:39 +05:30
< gl-empty-state
v - else - if = "shouldRenderEmptyState"
2021-06-08 01:23:25 +05:30
data - testid = "empty-state"
2019-02-15 15:39:39 +05:30
: 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
2021-06-08 01:23:25 +05:30
< div v -else -if = " shouldRenderSuccessState " data -testid = " success -state " >
2019-02-15 15:39:39 +05:30
< 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 : 1 px ;
content : ' ' ;
border : 1 px solid # e5e5e5 ;
height : 17 px ;
top : 100 % ;
position : absolute ;
left : 32 px ;
}
< / style >