Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f34c24a7
Commit
f34c24a7
authored
May 25, 2021
by
Jose Vargas
Committed by
Jose Ivan Vargas
May 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor showPagination function
parent
cecccc88
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
16 deletions
+28
-16
app/assets/javascripts/jobs/components/table/constants.js
app/assets/javascripts/jobs/components/table/constants.js
+9
-1
app/assets/javascripts/jobs/components/table/jobs_table_app.vue
...sets/javascripts/jobs/components/table/jobs_table_app.vue
+4
-13
spec/frontend/jobs/components/table/job_table_app_spec.js
spec/frontend/jobs/components/table/job_table_app_spec.js
+15
-2
No files found.
app/assets/javascripts/jobs/components/table/constants.js
View file @
f34c24a7
export
const
GRAPHQL_PAGE_SIZE
=
10
;
export
const
GRAPHQL_PAGE_SIZE
=
30
;
export
const
initialPaginationState
=
{
currentPage
:
1
,
prevPageCursor
:
''
,
nextPageCursor
:
''
,
first
:
GRAPHQL_PAGE_SIZE
,
last
:
null
,
};
app/assets/javascripts/jobs/components/table/jobs_table_app.vue
View file @
f34c24a7
<
script
>
<
script
>
import
{
GlAlert
,
GlPagination
,
GlSkeletonLoader
}
from
'
@gitlab/ui
'
;
import
{
GlAlert
,
GlPagination
,
GlSkeletonLoader
}
from
'
@gitlab/ui
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
GRAPHQL_PAGE_SIZE
}
from
'
./constants
'
;
import
{
GRAPHQL_PAGE_SIZE
,
initialPaginationState
}
from
'
./constants
'
;
import
GetJobs
from
'
./graphql/queries/get_jobs.query.graphql
'
;
import
GetJobs
from
'
./graphql/queries/get_jobs.query.graphql
'
;
import
JobsTable
from
'
./jobs_table.vue
'
;
import
JobsTable
from
'
./jobs_table.vue
'
;
import
JobsTableEmptyState
from
'
./jobs_table_empty_state.vue
'
;
import
JobsTableEmptyState
from
'
./jobs_table_empty_state.vue
'
;
import
JobsTableTabs
from
'
./jobs_table_tabs.vue
'
;
import
JobsTableTabs
from
'
./jobs_table_tabs.vue
'
;
const
initialPaginationState
=
{
currentPage
:
1
,
prevPageCursor
:
''
,
nextPageCursor
:
''
,
first
:
GRAPHQL_PAGE_SIZE
,
last
:
null
,
};
export
default
{
export
default
{
i18n
:
{
i18n
:
{
errorMsg
:
__
(
'
There was an error fetching the jobs for your project.
'
),
errorMsg
:
__
(
'
There was an error fetching the jobs for your project.
'
),
...
@@ -79,7 +71,7 @@ export default {
...
@@ -79,7 +71,7 @@ export default {
return
this
.
jobs
.
pageInfo
?.
hasNextPage
?
this
.
pagination
.
currentPage
+
1
:
null
;
return
this
.
jobs
.
pageInfo
?.
hasNextPage
?
this
.
pagination
.
currentPage
+
1
:
null
;
},
},
showPaginationControls
()
{
showPaginationControls
()
{
return
Boolean
(
this
.
prevPage
||
this
.
nextPage
);
return
Boolean
(
this
.
prevPage
||
this
.
nextPage
)
&&
!
this
.
$apollo
.
loading
;
},
},
},
},
methods
:
{
methods
:
{
...
@@ -99,8 +91,8 @@ export default {
...
@@ -99,8 +91,8 @@ export default {
};
};
}
else
{
}
else
{
this
.
pagination
=
{
this
.
pagination
=
{
last
PageSize
:
GRAPHQL_PAGE_SIZE
,
last
:
GRAPHQL_PAGE_SIZE
,
first
PageSize
:
null
,
first
:
null
,
prevPageCursor
:
startCursor
,
prevPageCursor
:
startCursor
,
currentPage
:
page
,
currentPage
:
page
,
};
};
...
@@ -147,7 +139,6 @@ export default {
...
@@ -147,7 +139,6 @@ export default {
<gl-pagination
<gl-pagination
v-if=
"showPaginationControls"
v-if=
"showPaginationControls"
:disabled=
"$apollo.loading"
:value=
"pagination.currentPage"
:value=
"pagination.currentPage"
:prev-page=
"prevPage"
:prev-page=
"prevPage"
:next-page=
"nextPage"
:next-page=
"nextPage"
...
...
spec/frontend/jobs/components/table/job_table_app_spec.js
View file @
f34c24a7
...
@@ -104,7 +104,6 @@ describe('Job table app', () => {
...
@@ -104,7 +104,6 @@ describe('Job table app', () => {
},
},
jobs
:
{
jobs
:
{
pageInfo
:
{
pageInfo
:
{
hasNextPage
:
false
,
hasPreviousPage
:
true
,
hasPreviousPage
:
true
,
startCursor
:
'
abc
'
,
startCursor
:
'
abc
'
,
endCursor
:
'
bcd
'
,
endCursor
:
'
bcd
'
,
...
@@ -113,12 +112,24 @@ describe('Job table app', () => {
...
@@ -113,12 +112,24 @@ describe('Job table app', () => {
},
},
});
});
await
wrapper
.
vm
.
$nextTick
();
wrapper
.
setData
({
jobs
:
{
pageInfo
:
{
hasNextPage
:
false
,
},
},
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
findPrevious
().
exists
()).
toBe
(
true
);
expect
(
findPrevious
().
exists
()).
toBe
(
true
);
expect
(
findNext
().
exists
()).
toBe
(
true
);
expect
(
findNext
().
exists
()).
toBe
(
true
);
expect
(
findNext
().
classes
(
'
disabled
'
)).
toBe
(
true
);
expect
(
findNext
().
classes
(
'
disabled
'
)).
toBe
(
true
);
});
});
it
(
'
should disable the pre
iv
ous page button on the first page
'
,
async
()
=>
{
it
(
'
should disable the pre
vi
ous page button on the first page
'
,
async
()
=>
{
createComponent
({
createComponent
({
handler
:
successHandler
,
handler
:
successHandler
,
mountFn
:
mount
,
mountFn
:
mount
,
...
@@ -137,6 +148,8 @@ describe('Job table app', () => {
...
@@ -137,6 +148,8 @@ describe('Job table app', () => {
},
},
});
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
findPrevious
().
exists
()).
toBe
(
true
);
expect
(
findPrevious
().
exists
()).
toBe
(
true
);
expect
(
findPrevious
().
classes
(
'
disabled
'
)).
toBe
(
true
);
expect
(
findPrevious
().
classes
(
'
disabled
'
)).
toBe
(
true
);
expect
(
findNext
().
exists
()).
toBe
(
true
);
expect
(
findNext
().
exists
()).
toBe
(
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment