158 paginated data list (#180)

* working: rename OrganizationTeamsList to PaginatedDataList

* convert org notifications list fully to PaginatedDataList

* update NotificationList tests

* refactor org access to use PaginatedDataList

* update tests for org access refactor; fix pagination & sorting

* restore Add Role functionality to Org roles

* fix displayed text when list of items is empty

* preserve query params when navigating through pagination

* fix bugs after RBAC rebase

* fix lint errors, fix add org access button
This commit is contained in:
Keith Grant
2019-04-29 10:08:50 -04:00
committed by GitHub
parent 3c06c97c32
commit 9d66b583b7
36 changed files with 4133 additions and 1427 deletions

View File

@@ -11,6 +11,7 @@ export const encodeQueryString = (params) => {
return Object.keys(params)
.sort()
.filter(key => params[key] !== null)
.map(key => ([key, params[key]]))
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join('&');
@@ -27,7 +28,7 @@ export const encodeQueryString = (params) => {
export const parseQueryString = (queryString, integerFields = ['page', 'page_size']) => {
if (!queryString) return {};
const keyValuePairs = queryString.split('&')
const keyValuePairs = queryString.replace(/^\?/, '').split('&')
.map(s => s.split('='))
.map(([key, value]) => {
if (integerFields.includes(key)) {

16
src/util/strings.js Normal file
View File

@@ -0,0 +1,16 @@
export function pluralize (str) {
return str[str.length - 1] === 's' ? `${str}es` : `${str}s`;
}
export function getArticle (str) {
const first = str[0];
if (('aeiou').includes(first)) {
return 'an';
}
return 'a';
}
export function ucFirst (str) {
return `${str[0].toUpperCase()}${str.substr(1)}`;
}