@jetbrains/ring-ui 4.2.8 → 4.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,7 +69,7 @@ export default class Pager extends PureComponent {
69
69
  return {selected, data};
70
70
  }
71
71
 
72
- getTotal() {
72
+ getPagesAmount() {
73
73
  const {total, pageSize} = this.props;
74
74
  return Math.ceil(total / pageSize);
75
75
  }
@@ -89,7 +89,7 @@ export default class Pager extends PureComponent {
89
89
  handleNextClick = () => {
90
90
  const {currentPage, onLoadPage} = this.props;
91
91
  const nextPage = currentPage + 1;
92
- const total = this.getTotal();
92
+ const total = this.getPagesAmount();
93
93
  if (currentPage !== total) {
94
94
  this.props.onPageChange(nextPage);
95
95
  } else if (this.props.openTotal) {
@@ -154,7 +154,8 @@ export default class Pager extends PureComponent {
154
154
 
155
155
  const prevLinkAvailable = this.props.currentPage !== 1;
156
156
 
157
- const nextLinkAvailable = this.props.openTotal || this.props.currentPage !== this.getTotal();
157
+ const nextLinkAvailable = this.props.openTotal ||
158
+ this.props.currentPage !== this.getPagesAmount();
158
159
 
159
160
  const nextIcon = (
160
161
  <Icon glyph={chevronRightIcon} key="icon"/>
@@ -232,17 +233,16 @@ export default class Pager extends PureComponent {
232
233
 
233
234
  getPagerContent() {
234
235
  const {currentPage, visiblePagesLimit} = this.props;
235
- const totalPages = this.getTotal();
236
+ const pagesAmount = this.getPagesAmount();
236
237
 
237
- if (totalPages < 2 && !this.props.openTotal) {
238
+ if (pagesAmount < 2 && !this.props.openTotal) {
238
239
  return null;
239
240
  }
240
241
 
241
242
  let start = 1;
242
- let end = totalPages;
243
+ let end = pagesAmount;
243
244
 
244
- // eslint-disable-next-line no-magic-numbers
245
- if (totalPages >= visiblePagesLimit + 6) {
245
+ if (pagesAmount >= visiblePagesLimit) {
246
246
  const leftHalfFrameSize = Math.ceil(visiblePagesLimit / 2) - 1;
247
247
  const rightHalfFrameSize = visiblePagesLimit - leftHalfFrameSize - 1;
248
248
 
@@ -255,8 +255,8 @@ export default class Pager extends PureComponent {
255
255
  end += tail;
256
256
  }
257
257
 
258
- if (end > totalPages) {
259
- const tail = end - totalPages;
258
+ if (end > pagesAmount) {
259
+ const tail = end - pagesAmount;
260
260
  start -= tail;
261
261
  end -= tail;
262
262
  }
@@ -271,7 +271,7 @@ export default class Pager extends PureComponent {
271
271
  buttons.push(this.getButton(i, i, i, i === currentPage));
272
272
  }
273
273
 
274
- const lastPageButtonAvailable = (end < totalPages && !this.props.openTotal) ||
274
+ const lastPageButtonAvailable = (end < pagesAmount && !this.props.openTotal) ||
275
275
  (this.props.openTotal && this.props.canLoadLastPageWithOpenTotal);
276
276
 
277
277
  return (
@@ -292,9 +292,9 @@ export default class Pager extends PureComponent {
292
292
 
293
293
  {buttons}
294
294
 
295
- {end < totalPages && this.getButton(end + 1, '...')}
295
+ {end < pagesAmount && this.getButton(end + 1, '...')}
296
296
 
297
- {end === totalPages && this.props.openTotal && (
297
+ {end === pagesAmount && this.props.openTotal && (
298
298
  <Button
299
299
  href={this.generateHref(end + 1)}
300
300
  disabled={this.props.loader}
@@ -307,7 +307,7 @@ export default class Pager extends PureComponent {
307
307
  (
308
308
  <ButtonGroup>
309
309
  {this.getButton(
310
- this.props.openTotal ? -1 : totalPages,
310
+ this.props.openTotal ? -1 : pagesAmount,
311
311
  this.props.translations.lastPage
312
312
  )}
313
313
  </ButtonGroup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetbrains/ring-ui",
3
- "version": "4.2.8",
3
+ "version": "4.2.9",
4
4
  "description": "JetBrains UI library",
5
5
  "author": "JetBrains",
6
6
  "license": "Apache-2.0",
@@ -221,5 +221,5 @@
221
221
  "node": ">=7.4",
222
222
  "npm": ">=6.0.0"
223
223
  },
224
- "gitHead": "de28120e16fa8f1f9d011af5e7e2e4930a2c3fc4"
224
+ "gitHead": "f3629bb73589725e9470d3bd9912382d36754098"
225
225
  }