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
d0a5428a
Commit
d0a5428a
authored
Nov 18, 2016
by
Regis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
constant variable hardcoding
parent
758cdf54
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
20 deletions
+39
-20
app/assets/javascripts/vue_pagination/index.js.es6
app/assets/javascripts/vue_pagination/index.js.es6
+21
-11
app/assets/javascripts/vue_pipelines_index/index.js.es6
app/assets/javascripts/vue_pipelines_index/index.js.es6
+1
-1
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
+12
-6
app/assets/javascripts/vue_pipelines_index/store.js.es6
app/assets/javascripts/vue_pipelines_index/store.js.es6
+5
-2
No files found.
app/assets/javascripts/vue_pagination/index.js.es6
View file @
d0a5428a
...
...
@@ -2,6 +2,14 @@
/* eslint-disable no-param-reassign, no-plusplus */
((gl) => {
const PAGINATION_SIZE = 30;
const PAGINATION_UI_BUTTON_LIMIT = 4;
const SPREAD = '...';
const PREV = 'Prev';
const NEXT = 'Next';
const FIRST = '<< First';
const LAST = 'Last >>';
gl.VueGlPagination = Vue.extend({
props: [
'changepage',
...
...
@@ -10,40 +18,42 @@
],
computed: {
last() {
return Math.ceil(+this.count /
30
);
return Math.ceil(+this.count /
PAGINATION_SIZE
);
},
getItems() {
const total = +this.last;
const page = +this.pagenum;
const items = [];
if (page > 1) items.push({ title:
'<< First'
, where: 1 });
if (page > 1) items.push({ title:
FIRST
, where: 1 });
if (page > 1) {
items.push({ title:
'Prev'
, where: page - 1 });
items.push({ title:
PREV
, where: page - 1 });
} else {
items.push({ title:
'Prev'
, where: page - 1, disabled: true });
items.push({ title:
PREV
, where: page - 1, disabled: true });
}
if (page > 6) items.push({ title:
'...'
, separator: true });
if (page > 6) items.push({ title:
SPREAD
, separator: true });
const start = Math.max(page -
4
, 1);
const end = Math.min(page +
4
, total);
const start = Math.max(page -
PAGINATION_UI_BUTTON_LIMIT
, 1);
const end = Math.min(page +
PAGINATION_UI_BUTTON_LIMIT
, total);
for (let i = start; i <= end; i++) {
const isActive = i === page;
items.push({ title: i, active: isActive, where: i });
}
if (total - page > 4) items.push({ title: '...', separator: true });
if (total - page > PAGINATION_UI_BUTTON_LIMIT) {
items.push({ title: SPREAD, separator: true });
}
if (page === total) {
items.push({ title:
'Next'
, where: page + 1, disabled: true });
items.push({ title:
NEXT
, where: page + 1, disabled: true });
} else if (total - page >= 1) {
items.push({ title:
'Next'
, where: page + 1 });
items.push({ title:
NEXT
, where: page + 1 });
}
if (total - page >= 1) items.push({ title:
'Last >>'
, where: total });
if (total - page >= 1) items.push({ title:
LAST
, where: total });
return items;
},
...
...
app/assets/javascripts/vue_pipelines_index/index.js.es6
View file @
d0a5428a
...
...
@@ -29,7 +29,7 @@
store: new gl.PipelineStore(),
},
components: {
'vue-pipelines': gl.VuePipe
L
ines,
'vue-pipelines': gl.VuePipe
l
ines,
},
template: `
<div>
...
...
app/assets/javascripts/vue_pipelines_index/pipelines.js.es6
View file @
d0a5428a
...
...
@@ -2,7 +2,13 @@
/* eslint-disable no-param-reassign, no-bitwise*/
((gl) => {
gl.VuePipeLines = Vue.extend({
const SPREAD = '...';
const PREV = 'Prev';
const NEXT = 'Next';
const FIRST = '<< First';
const LAST = 'Last >>';
gl.VuePipelines = Vue.extend({
components: {
runningPipeline: gl.VueRunningPipeline,
pipelineActions: gl.VuePipelineActions,
...
...
@@ -41,12 +47,12 @@
methods: {
changepage(e, last) {
const text = e.target.innerText;
if (text ===
'...'
) return;
if (text ===
SPREAD
) return;
if (/^-?[\d.]+(?:e-?\d+)?$/.test(text)) this.pagenum = +text;
if (text ===
'Last >>'
) this.pagenum = last;
if (text ===
'Next'
) this.pagenum = +this.pagenum + 1;
if (text ===
'Prev'
) this.pagenum = +this.pagenum - 1;
if (text ===
'<< First'
) this.pagenum = 1;
if (text ===
LAST
) this.pagenum = last;
if (text ===
NEXT
) this.pagenum = +this.pagenum + 1;
if (text ===
PREV
) this.pagenum = +this.pagenum - 1;
if (text ===
FIRST
) this.pagenum = 1;
window.history.pushState({}, null, `?p=${this.pagenum}`);
clearInterval(this.intervalId);
...
...
app/assets/javascripts/vue_pipelines_index/store.js.es6
View file @
d0a5428a
...
...
@@ -2,6 +2,9 @@
/* eslint-disable no-param-reassign */
((gl) => {
const PAGINATION_LIMIT = 31;
const SLICE_LIMIT = 29;
class PipelineUpdater {
constructor(pipelines) {
this.pipelines = pipelines;
...
...
@@ -11,8 +14,8 @@
});
};
this.currentPageSlicer = (update) => {
if (update.length <
= 30
) return update;
return update.slice(0,
29
);
if (update.length <
PAGINATION_LIMIT
) return update;
return update.slice(0,
SLICE_LIMIT
);
};
}
...
...
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