Skip to content

Commit 3b5ff58

Browse files
authored
New: Adding option to filter out response (#46)
1 parent ba339eb commit 3b5ff58

17 files changed

Lines changed: 156 additions & 52 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ render(
8686
| logoUrl | string | | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
8787
| sharedLink | string | | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
8888
| sharedLinkPassword | string | | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
89-
| defaultView | string | `files` | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
89+
| defaultView | string | `files` | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
90+
| responseFilter | function | | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
9091

9192
### Keyboard Shortcuts
9293
*See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-keyboard-shortcuts).*
@@ -139,6 +140,7 @@ render(
139140
| chooseButtonLabel | string | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
140141
| cancelButtonLabel | string | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
141142
| defaultView | string | `files` | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
143+
| responseFilter | function | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
142144

143145
### Keyboard Shortcuts
144146
*See the [developer docs](https://developer.box.com/docs/box-content-picker#section-keyboard-shortcuts).*
@@ -179,6 +181,7 @@ render(
179181
| logoUrl | string | | *See the [developer docs](https://developer.box.com/docs/box-content-uploader#section-options).* |
180182
| sharedLink | string | | *See the [developer docs](https://developer.box.com/docs/box-content-uploader#section-options).* |
181183
| sharedLinkPassword | string | | *See the [developer docs](https://developer.box.com/docs/box-content-uploader#section-options).* |
184+
| responseFilter | function | | *See the [developer docs](https://developer.box.com/docs/box-content-uploader#section-options).* |
182185

183186

184187
## Content Tree ([Documentation](https://developer.box.com/docs/box-content-tree))
@@ -218,6 +221,7 @@ render(
218221
| logoUrl | string | | *See the [developer docs](https://developer.box.com/docs/box-content-tree#section-options).* |
219222
| sharedLink | string | | *See the [developer docs](https://developer.box.com/docs/box-content-tree#section-options).* |
220223
| sharedLinkPassword | string | | *See the [developer docs](https://developer.box.com/docs/box-content-tree#section-options).* |
224+
| responseFilter | function | | *See the [developer docs](https://developer.box.com/docs/box-content-tree#section-options).* |
221225

222226

223227
## Content Preview ([Documentation](https://developer.box.com/docs/box-content-preview))

src/api/Search.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ class Search extends Base {
252252

253253
// Save references
254254
this.offset = 0;
255-
this.query = this.getEncodedQuery(query);
255+
this.query = query;
256256
this.id = id;
257-
this.key = this.getCacheKey(id, this.query);
257+
this.key = this.getCacheKey(id, this.getEncodedQuery(this.query));
258258
this.successCallback = successCallback;
259259
this.errorCallback = errorCallback;
260260
this.sortBy = sortBy;

src/api/__tests__/Search-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('api/Search', () => {
8686
expect(search.sortDirection).to.equal('direction');
8787
expect(search.key).to.equal('key');
8888
expect(search.offset).to.equal(0);
89-
expect(search.query).to.equal('foo%20query');
89+
expect(search.query).to.equal('foo query');
9090
});
9191
it('should save args and not make search request when cached', () => {
9292
search.searchRequest = sandbox.mock().never();
@@ -101,7 +101,7 @@ describe('api/Search', () => {
101101
expect(search.sortDirection).to.equal('direction');
102102
expect(search.key).to.equal('key');
103103
expect(search.offset).to.equal(0);
104-
expect(search.query).to.equal('foo%20query');
104+
expect(search.query).to.equal('foo query');
105105
});
106106
it('should save args and make search request when cached but forced to fetch', () => {
107107
search.searchRequest = sandbox.mock();
@@ -116,7 +116,7 @@ describe('api/Search', () => {
116116
expect(search.sortDirection).to.equal('direction');
117117
expect(search.key).to.equal('key');
118118
expect(search.offset).to.equal(0);
119-
expect(search.query).to.equal('foo%20query');
119+
expect(search.query).to.equal('foo query');
120120
});
121121
});
122122

src/components/Breadcrumbs/Breadcrumb.scss

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
@import '../variables';
22

33
.buik-breadcrumb {
4+
display: flex;
5+
min-width: 20px;
6+
7+
&:first-child {
8+
min-width: 64px;
9+
}
10+
411
.buik-btn.buik-btn-plain {
512
color: $sevens;
6-
max-width: 100px;
7-
overflow: hidden;
8-
text-overflow: ellipsis;
9-
white-space: nowrap;
1013

1114
&:last-child {
1215
color: $twos;

src/components/Breadcrumbs/BreadcrumbDropdown.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@
66

77
&.buik-breadcrumbs-condensed {
88
letter-spacing: inherit;
9-
line-height: 6px;
10-
padding-right: 2px;
11-
vertical-align: sub;
129
}
1310
}

src/components/Breadcrumbs/Breadcrumbs.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function getBreadcrumb(crumbs: Crumb | Crumb[], isLast: boolean, onCrumbClick: F
4646
if (Array.isArray(crumbs)) {
4747
const condensed = delimiter !== DELIMITER_CARET;
4848
return (
49-
<span>
49+
<span className='buik-breadcrumb-more'>
5050
<BreadcrumbDropdown
5151
onCrumbClick={onCrumbClick}
5252
crumbs={crumbs}
@@ -76,14 +76,12 @@ const Breadcrumbs = ({ rootId, crumbs, onCrumbClick, delimiter, isSmall = false
7676
const lastBreadcrumb = <Breadcrumb name={crumb.name} onClick={onClick} isLast />;
7777

7878
// Always show the second last/parent breadcrumb when there are at least 2 crumbs.
79-
const secondLastBreadcrumb = length > 1
80-
? getBreadcrumb(filteredCrumbs[length - 2], false, onCrumbClick, delimiter)
81-
: null;
79+
const secondLastBreadcrumb =
80+
length > 1 ? getBreadcrumb(filteredCrumbs[length - 2], false, onCrumbClick, delimiter) : null;
8281

8382
// Only show the more dropdown when there were at least 4 crumbs.
84-
const moreBreadcrumbs = length > 3
85-
? getBreadcrumb(filteredCrumbs.slice(1, length - 2), false, onCrumbClick, delimiter)
86-
: null;
83+
const moreBreadcrumbs =
84+
length > 3 ? getBreadcrumb(filteredCrumbs.slice(1, length - 2), false, onCrumbClick, delimiter) : null;
8785

8886
// Only show the root breadcrumb when there are at least 3 crumbs.
8987
const firstBreadcrumb = length > 2 ? getBreadcrumb(filteredCrumbs[0], false, onCrumbClick, delimiter) : null;
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
@import '../variables';
22

33
.buik-breadcrumbs {
4-
display: inline-block;
5-
text-overflow: ellipsis;
6-
white-space: nowrap;
4+
display: flex;
5+
min-width: 0;
6+
padding-right: 20px;
7+
}
8+
9+
.buik-breadcrumb-more {
10+
display: flex;
11+
min-width: 35px;
712
}

src/components/Breadcrumbs/InlineBreadcrumbs.scss

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@
22

33
.buik-inline-breadcrumbs {
44
color: $sevens;
5+
display: flex;
56
font-size: 11px;
7+
min-width: 0;
68

7-
.buik-breadcrumb .buik-btn.buik-btn-plain {
8-
color: inherit;
9-
font-size: 11px;
9+
.buik-breadcrumbs {
10+
padding-right: 0;
11+
}
12+
13+
.buik-breadcrumb {
14+
&:first-child {
15+
min-width: 43px;
16+
}
17+
18+
.buik-btn.buik-btn-plain {
19+
color: inherit;
20+
font-size: 11px;
21+
}
22+
}
23+
24+
.buik-breadcrumb-more {
25+
min-width: 16px;
1026
}
1127
}

src/components/ContentExplorer/ContentExplorer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ type Props = {
9191
defaultView: DefaultView,
9292
logoUrl?: string,
9393
sharedLink?: string,
94-
sharedLinkPassword?: string
94+
sharedLinkPassword?: string,
95+
responseFilter?: Function
9596
};
9697

9798
type State = {
@@ -193,14 +194,16 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
193194
apiHost,
194195
uploadHost,
195196
sortBy,
196-
sortDirection
197+
sortDirection,
198+
responseFilter
197199
}: Props = props;
198200
this.api = new API({
199201
token,
200202
sharedLink,
201203
sharedLinkPassword,
202204
apiHost,
203205
uploadHost,
206+
responseFilter,
204207
clientName: CLIENT_NAME_CONTENT_EXPLORER,
205208
id: `folder_${rootFolderId}`
206209
});

src/components/ContentPicker/ContentPicker.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ type Props = {
8383
cancelButtonLabel?: string,
8484
logoUrl?: string,
8585
sharedLink?: string,
86-
sharedLinkPassword?: string
86+
sharedLinkPassword?: string,
87+
responseFilter?: Function
8788
};
8889

8990
type State = {
@@ -170,7 +171,8 @@ class ContentPicker extends Component<DefaultProps, Props, State> {
170171
uploadHost,
171172
sortBy,
172173
sortDirection,
173-
clientName
174+
clientName,
175+
responseFilter
174176
} = props;
175177
this.api = new API({
176178
token,
@@ -179,6 +181,7 @@ class ContentPicker extends Component<DefaultProps, Props, State> {
179181
apiHost,
180182
uploadHost,
181183
clientName,
184+
responseFilter,
182185
id: `folder_${rootFolderId}`
183186
});
184187
this.id = uniqueid('bcp_');

0 commit comments

Comments
 (0)