Skip to content

Commit 002b885

Browse files
authored
Fix: Allow transcripts to work without timestamp (#63)
Also updates some test files
1 parent 7080dbe commit 002b885

6 files changed

Lines changed: 37 additions & 37 deletions

File tree

src/components/Transcript/Transcript.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@ const Transcript = ({ skill: { entries } }: Props) =>
3838
>
3939
<Column
4040
dataKey='appears'
41-
width={35}
41+
className='buik-transcript-time-column'
42+
width={45}
4243
flexShrink={0}
43-
cellRenderer={({ cellData }) => formatTime(cellData[0].start)}
44+
cellRenderer={({ cellData }): string => {
45+
if (Array.isArray(cellData) && !!cellData[0] && typeof cellData[0].start === 'number') {
46+
return formatTime(cellData[0].start);
47+
}
48+
return '--';
49+
}}
4450
/>
4551
<Column
4652
dataKey='text'

src/components/Transcript/Transcript.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313
.buik-transcript-column {
1414
padding: 8px 15px 8px 0;
1515
}
16+
17+
.buik-transcript-time-column {
18+
text-align: center;
19+
}

src/util/Xhr.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,17 @@ class Xhr {
195195
headers[HEADER_CLIENT_VERSION] = this.version;
196196
}
197197

198-
return this.getToken(id).then((token) => {
199-
if (token) {
200-
// Only add a token when there was one found
201-
headers.Authorization = `Bearer ${token}`;
202-
}
203-
return headers;
204-
});
198+
return this.getToken(id)
199+
.then((token) => {
200+
if (token) {
201+
// Only add a token when there was one found
202+
headers.Authorization = `Bearer ${token}`;
203+
}
204+
return headers;
205+
})
206+
.catch(() => {
207+
throw error;
208+
});
205209
}
206210

207211
/**

test/explorer-no-react.html

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@
3939
<div class="inputs">
4040
<div>
4141
<label>
42-
<div>Folder Id</div>
42+
<div>Root Folder Id</div>
4343
<input class="folder" type="text" placeholder="Enter root folder id" value="0" />
4444
</label>
45+
<label>
46+
<div>Current Folder Id</div>
47+
<input class="currentFolder" type="text" placeholder="Enter root folder id" value="38437418331" />
48+
</label>
4549
<label>
4650
<div>Auth Token</div>
4751
<input class="token" type="text" placeholder="Enter auth token" />
@@ -50,7 +54,7 @@
5054
<button type="button" onclick="load()">Submit</button>
5155
</div>
5256
<div class="container">
53-
<h1>Content Explorer</h1>
57+
<h1>Content Explorer With Filtering to folders and navigating to another folder on load and token generator</h1>
5458
<div class="explorer1"></div>
5559
</div>
5660
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js"></script>
@@ -61,30 +65,20 @@ <h1>Content Explorer</h1>
6165
const { ContentExplorer } = Box;
6266
const token = document.querySelector('.token').value || localStorage.getItem('token');
6367
const folderId = document.querySelector('.folder').value || localStorage.getItem('folder');
68+
const currentFolderId = document.querySelector('.currentFolder').value || localStorage.getItem('currentFolder');
6469

6570
localStorage.setItem('token', token);
6671
localStorage.setItem('folder', folderId);
6772

68-
const tokenGenerator1 = (id) => {
69-
if (id === `folder_${folderId}`) {
70-
return Promise.resolve(token);
71-
} else {
72-
return Promise.reject()
73-
}
74-
};
75-
const tokenGenerator2 = (id) => {
76-
if (id === `folder_${folderId}`) {
77-
return Promise.resolve({ [`folder_${folderId}`]: token });
78-
} else {
79-
return Promise.reject()
80-
}
73+
const tokenGenerator = (id) => {
74+
return Promise.resolve({ [id]: token });
8175
};
8276

8377
const explorer1 = new ContentExplorer();
8478
document.querySelector('.explorer1').innerHTML = '';
85-
explorer1.show(folderId, token, {
79+
explorer1.show(folderId, tokenGenerator, {
8680
container: '.explorer1',
87-
currentFolderId: '4579229774',
81+
currentFolderId: currentFolderId,
8882
canShare: false,
8983
autoFocus: true,
9084
logoUrl: 'https://d30y9cdsu7xlg0.cloudfront.net/png/12458-200.png',

test/pickers.html

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,10 @@ <h1>Folder Picker (max 3 items / token generator / no upload)</h1>
9090
localStorage.setItem('folder', folderId);
9191

9292
const tokenGenerator1 = (id) => {
93-
if (id === `folder_${folderId}`) {
94-
return Promise.resolve(token);
95-
} else {
96-
return Promise.reject()
97-
}
93+
return Promise.resolve(token);
9894
};
9995
const tokenGenerator2 = (id) => {
100-
if (id === `folder_${folderId}`) {
101-
return Promise.resolve({ [`folder_${folderId}`]: token });
102-
} else {
103-
return Promise.reject()
104-
}
96+
return Promise.resolve({ [id]: token });
10597
};
10698

10799
const filePicker1 = new FilePicker();

test/preview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
window.onload = function() {
2323
const { ContentExplorer } = Box;
2424
const explorer = new ContentExplorer();
25-
explorer.show('0', 'nBG3XQcNNNcoJfX0qowIDT8hrmeIVWI5', {
25+
explorer.show('0', 'HlswnEPcgSbDR2KC9CQeMLwcLohSovTp', {
2626
hasPreviewSidebar: true
2727
});
2828
}

0 commit comments

Comments
 (0)