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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
18b906c0
Commit
18b906c0
authored
Jun 06, 2019
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creates pagination component graphql
creates a pagination component for the graphql api
parent
fd19f887
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
9 deletions
+140
-9
app/assets/javascripts/vue_shared/components/pagination/constants.js
...javascripts/vue_shared/components/pagination/constants.js
+9
-0
app/assets/javascripts/vue_shared/components/pagination/graphql_pagination.vue
...s/vue_shared/components/pagination/graphql_pagination.vue
+47
-0
app/assets/javascripts/vue_shared/components/table_pagination.vue
...ts/javascripts/vue_shared/components/table_pagination.vue
+9
-9
changelogs/unreleased/62788-graphql-pagination.yml
changelogs/unreleased/62788-graphql-pagination.yml
+5
-0
spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js
...e_shared/components/pagination/graphql_pagination_spec.js
+70
-0
No files found.
app/assets/javascripts/vue_shared/components/pagination/constants.js
0 → 100644
View file @
18b906c0
import
{
s__
}
from
'
~/locale
'
;
export
const
PAGINATION_UI_BUTTON_LIMIT
=
4
;
export
const
UI_LIMIT
=
6
;
export
const
SPREAD
=
'
...
'
;
export
const
PREV
=
s__
(
'
Pagination|Prev
'
);
export
const
NEXT
=
s__
(
'
Pagination|Next
'
);
export
const
FIRST
=
s__
(
'
Pagination|« First
'
);
export
const
LAST
=
s__
(
'
Pagination|Last »
'
);
app/assets/javascripts/vue_shared/components/pagination/graphql_pagination.vue
0 → 100644
View file @
18b906c0
<
script
>
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
PREV
,
NEXT
}
from
'
~/vue_shared/components/pagination/constants
'
;
/**
* Pagination Component for graphql API
*/
export
default
{
name
:
'
GraphqlPaginationComponent
'
,
components
:
{
GlButton
,
},
labels
:
{
prev
:
PREV
,
next
:
NEXT
,
},
props
:
{
hasNextPage
:
{
required
:
true
,
type
:
Boolean
,
},
hasPreviousPage
:
{
required
:
true
,
type
:
Boolean
,
},
},
};
</
script
>
<
template
>
<div
class=
"justify-content-center d-flex prepend-top-default"
>
<div
class=
"btn-group"
>
<gl-button
class=
"js-prev-btn page-link"
:disabled=
"!hasPreviousPage"
@
click=
"$emit('previousClicked')"
>
{{
$options
.
labels
.
prev
}}
</gl-button
>
<gl-button
class=
"js-next-btn page-link"
:disabled=
"!hasNextPage"
@
click=
"$emit('nextClicked')"
>
{{
$options
.
labels
.
next
}}
</gl-button
>
</div>
</div>
</
template
>
app/assets/javascripts/vue_shared/components/table_pagination.vue
View file @
18b906c0
<
script
>
<
script
>
import
{
s__
}
from
'
../../locale
'
;
import
{
PAGINATION_UI_BUTTON_LIMIT
,
const
PAGINATION_UI_BUTTON_LIMIT
=
4
;
UI_LIMIT
,
const
UI_LIMIT
=
6
;
SPREAD
,
const
SPREAD
=
'
...
'
;
PREV
,
const
PREV
=
s__
(
'
Pagination|Prev
'
);
NEXT
,
const
NEXT
=
s__
(
'
Pagination|Next
'
);
FIRST
,
const
FIRST
=
s__
(
'
Pagination|« First
'
);
LAST
,
const
LAST
=
s__
(
'
Pagination|Last »
'
)
;
}
from
'
~/vue_shared/components/pagination/constants
'
;
export
default
{
export
default
{
props
:
{
props
:
{
...
...
changelogs/unreleased/62788-graphql-pagination.yml
0 → 100644
View file @
18b906c0
---
title
:
Adds pagination component for graphql api
merge_request
:
29277
author
:
type
:
added
spec/javascripts/vue_shared/components/pagination/graphql_pagination_spec.js
0 → 100644
View file @
18b906c0
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
GraphqlPagination
from
'
~/vue_shared/components/pagination/graphql_pagination.vue
'
;
describe
(
'
Graphql Pagination component
'
,
()
=>
{
let
wrapper
;
function
factory
({
hasNextPage
=
true
,
hasPreviousPage
=
true
})
{
wrapper
=
shallowMount
(
GraphqlPagination
,
{
propsData
:
{
hasNextPage
,
hasPreviousPage
,
},
});
}
afterEach
(()
=>
{
wrapper
.
destroy
();
});
describe
(
'
without previous page
'
,
()
=>
{
beforeEach
(()
=>
{
factory
({
hasPreviousPage
:
false
});
});
it
(
'
renders disabled previous button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-prev-btn
'
).
attributes
().
disabled
).
toEqual
(
'
true
'
);
});
});
describe
(
'
with previous page
'
,
()
=>
{
beforeEach
(()
=>
{
factory
({
hasPreviousPage
:
true
});
});
it
(
'
renders enabled previous button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-prev-btn
'
).
attributes
().
disabled
).
toEqual
(
undefined
);
});
it
(
'
emits previousClicked on click
'
,
()
=>
{
wrapper
.
find
(
'
.js-prev-btn
'
).
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
().
previousClicked
.
length
).
toBe
(
1
);
});
});
describe
(
'
without next page
'
,
()
=>
{
beforeEach
(()
=>
{
factory
({
hasNextPage
:
false
});
});
it
(
'
renders disabled next button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-next-btn
'
).
attributes
().
disabled
).
toEqual
(
'
true
'
);
});
});
describe
(
'
with next page
'
,
()
=>
{
beforeEach
(()
=>
{
factory
({
hasNextPage
:
true
});
});
it
(
'
renders enabled next button
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-next-btn
'
).
attributes
().
disabled
).
toEqual
(
undefined
);
});
it
(
'
emits nextClicked on click
'
,
()
=>
{
wrapper
.
find
(
'
.js-next-btn
'
).
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
().
nextClicked
.
length
).
toBe
(
1
);
});
});
});
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