Skip to content

Commit 1b59da3

Browse files
authored
Delay fetching resource info until there’s a token (#978)
1 parent 3b97378 commit 1b59da3

File tree

7 files changed

+39
-4
lines changed

7 files changed

+39
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
66
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
12+
- Fixed `<manifold-resource-list>` and `<manifold-resource-container>` to not send requests without
13+
a token.
14+
815
## [0.9.7] - 2020-03-11
916

1017
### Fixed
@@ -536,6 +543,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
536543
- Changed the `manifold-resource-credentials` component to use the standalone `manifold-credentials`
537544
component.
538545

546+
[unreleased]: https://github.com/manifoldco/ui/compare/v0.9.7...HEAD
539547
[0.9.7]: https://github.com/manifoldco/ui/compare/v0.9.6...v0.9.7
540548
[0.9.6]: https://github.com/manifoldco/ui/compare/v0.9.5...v0.9.6
541549
[0.9.5]: https://github.com/manifoldco/ui/compare/v0.9.4...v0.9.5

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@storybook/html": "^5.2.5",
9494
"@types/fetch-mock": "^7.3.1",
9595
"@types/jest": "24.0.23",
96-
"@types/puppeteer": "2.0.1",
96+
"@types/puppeteer": "1.20.4",
9797
"@typescript-eslint/eslint-plugin": "^1.13.0",
9898
"@typescript-eslint/parser": "^1.13.0",
9999
"babel-loader": "^8.0.6",

src/components/manifold-resource-container/manifold-resource-container.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { newSpecPage, SpecPage } from '@stencil/core/testing';
22
import fetchMock from 'fetch-mock';
33

4+
// mock connection before import
5+
jest.mock('../../global/app', () => ({
6+
connection: { getAuthToken: () => '1234' },
7+
}));
8+
9+
/* eslint-disable import/first */
410
import { ManifoldResourceContainer } from './manifold-resource-container';
511
import { createGraphqlFetch } from '../../utils/graphqlFetch';
612
import { ResourceStatusLabel } from '../../types/graphql';

src/components/manifold-resource-container/manifold-resource-container.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export class ManifoldResourceContainer {
5555
return;
5656
}
5757

58+
// for this component, wait for auth before fetching
59+
if (!connection.getAuthToken()) {
60+
return;
61+
}
62+
5863
const variables: ResourceWithOwnerQueryVariables = { resourceLabel, owner: this.ownerId };
5964
const { data, errors } = await this.graphqlFetch<ResourceWithOwnerQuery>({
6065
query: queryWithOwner,

src/components/manifold-resource-list/manifold-resource-list.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { newSpecPage } from '@stencil/core/testing';
22
import fetchMock from 'fetch-mock';
33

4+
// mock connection before import
5+
jest.mock('../../global/app', () => ({
6+
connection: { getAuthToken: () => '1234' },
7+
}));
8+
9+
/* eslint-disable import/first */
410
import { ManifoldResourceList } from './manifold-resource-list';
511
import { connections } from '../../utils/connections';
612
import resource from '../../spec/mock/elegant-cms/resource';
@@ -44,6 +50,11 @@ describe('<manifold-resource-list>', () => {
4450

4551
afterEach(fetchMock.restore);
4652

53+
// unmock connection
54+
afterAll(() => {
55+
jest.unmock('../../global/app');
56+
});
57+
4758
it('The resources list are rendered if given.', async () => {
4859
fetchMock.mock(connections.prod.graphql, { data });
4960

src/components/manifold-resource-list/manifold-resource-list.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export class ManifoldResourceList {
5454
return;
5555
}
5656

57+
// for this component, wait for auth before fetching
58+
if (!connection.getAuthToken()) {
59+
return;
60+
}
61+
5762
const variables: Resources_With_OwnerQueryVariables = {
5863
first: 50,
5964
after: '',

0 commit comments

Comments
 (0)