Skip to content

Commit b491e9a

Browse files
authored
Merge pull request #514 from gautamdsheth/filePickerFixes
Fix: additional check for OrgAssets HTTP request
2 parents e1c2dc8 + cc4752c commit b491e9a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/controls/filePicker/FilePicker.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { IFilePickerProps } from './IFilePickerProps';
33
import { IFilePickerState } from './IFilePickerState';
44

5-
import { PrimaryButton, ActionButton } from 'office-ui-fabric-react/lib/components/Button';
5+
import { PrimaryButton, ActionButton } from 'office-ui-fabric-react/lib/components/Button';
66
import { Panel, PanelType } from 'office-ui-fabric-react/lib/components/Panel';
77
import { Label } from 'office-ui-fabric-react/lib/components/Label';
88
import { Nav, INavLink, INavLinkGroup } from 'office-ui-fabric-react/lib/Nav';
@@ -54,19 +54,22 @@ export class FilePicker extends React.Component<IFilePickerProps, IFilePickerSta
5454

5555
public async componentDidMount() {
5656
// Load information about Organisation Assets Library
57-
const orgAssetsLibraries = await this.orgAssetsService.getSiteMediaLibraries();
58-
const organisationAssetsEnabled = orgAssetsLibraries ? true : false;
57+
let orgAssetsEnabled: boolean = false;
58+
if (this.props.hideOrganisationalAssetTab != undefined && !this.props.hideOrganisationalAssetTab) {
59+
const orgAssetsLibraries = await this.orgAssetsService.getSiteMediaLibraries();
60+
orgAssetsEnabled = orgAssetsLibraries ? true : false;
61+
}
5962

6063
this.setState({
61-
organisationAssetsEnabled
64+
organisationAssetsEnabled: orgAssetsEnabled
6265
});
6366
}
6467

6568
public render(): JSX.Element {
6669
// If no acceptable file type was passed, and we're expecting images, set the default image filter
6770
const accepts: string[] = this.props.accepts;
68-
const buttonClassName :string = this.props.buttonClassName ? this.props.buttonClassName : '';
69-
const panelClassName :string = this.props.panelClassName ? this.props.panelClassName : '';
71+
const buttonClassName: string = this.props.buttonClassName ? this.props.buttonClassName : '';
72+
const panelClassName: string = this.props.panelClassName ? this.props.panelClassName : '';
7073

7174
const linkTabProps = {
7275
accepts: accepts,
@@ -281,7 +284,7 @@ export class FilePicker extends React.Component<IFilePickerProps, IFilePickerSta
281284
});
282285
}
283286

284-
let groups: INavLinkGroup[] = [ { links} ];
287+
let groups: INavLinkGroup[] = [{ links }];
285288
return groups;
286289
}
287290

0 commit comments

Comments
 (0)