Skip to content

Commit 2d6f962

Browse files
authored
Merge pull request #792 from pnp/filepicker-site-pages
#601 - allow display Site Pages on Site tab
2 parents bd85345 + c507b16 commit 2d6f962

File tree

9 files changed

+18
-2
lines changed

9 files changed

+18
-2
lines changed

docs/documentation/docs/controls/FilePicker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ The FilePicker component can be configured with the following properties:
7979
| storeLastActiveTab | boolean | no | Specifies if last active tab will be stored after the Upload panel has been closed. Note: the value of selected tab is stored in the queryString hash. Default `true` |
8080
| renderCustomUploadTabContent | (filePickerResult: IFilePickerResult) => JSX.Element \| null | no | Optional renderer to add custom user-defined fields to "Upload" tab |
8181
| renderCustomLinkTabContent | (filePickerResult: IFilePickerResult) => JSX.Element \| null | no | Optional renderer to add custom user-defined fields to "Link" tab |
82+
| includePageLibraries | boolean | no | Specifies if Site Pages library to be visible on Sites tab |
8283

8384
interface `IFilePickerResult`
8485

src/controls/filePicker/FilePicker.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export class FilePicker extends React.Component<
211211
{this.state.selectedTab === "keySite" && (
212212
<SiteFilePickerTab
213213
fileBrowserService={this.fileBrowserService}
214+
includePageLibraries={this.props.includePageLibraries}
214215
{...linkTabProps}
215216
/>
216217
)}

src/controls/filePicker/IFilePickerProps.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,9 @@ export interface IFilePickerProps {
137137
* Optional additional renderer for Upload tab
138138
*/
139139
renderCustomUploadTabContent?: (filePickerResult: IFilePickerResult) => JSX.Element | null;
140+
141+
/**
142+
* Specifies if Site Pages library to be visible on Sites tab
143+
*/
144+
includePageLibraries?: boolean;
140145
}

src/controls/filePicker/SiteFilePickerTab/ISiteFilePickerTabProps.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ export interface ISiteFilePickerTabProps extends IFilePickerTab {
99
* Represents the base node in the breadrumb navigation
1010
*/
1111
breadcrumbFirstNode?: IBreadcrumbItem;
12+
13+
includePageLibraries?: boolean;
1214
}

src/controls/filePicker/SiteFilePickerTab/SiteFilePickerTab.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default class SiteFilePickerTab extends React.Component<ISiteFilePickerTa
4646
{this.state.libraryAbsolutePath === undefined &&
4747
<DocumentLibraryBrowser
4848
fileBrowserService={this.props.fileBrowserService}
49+
includePageLibraries={this.props.includePageLibraries}
4950
onOpenLibrary={(selectedLibrary: ILibrary) => this._handleOpenLibrary(selectedLibrary, true)} />}
5051
{this.state.libraryAbsolutePath !== undefined &&
5152
<FileBrowser

src/controls/filePicker/controls/DocumentLibraryBrowser/DocumentLibraryBrowser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class DocumentLibraryBrowser extends React.Component<IDocumentLibraryBrow
4141
}
4242

4343
public async componentDidMount() {
44-
const lists = await this.props.fileBrowserService.getSiteMediaLibraries();
44+
const lists = await this.props.fileBrowserService.getSiteMediaLibraries(this.props.includePageLibraries);
4545
this.setState({
4646
lists: lists,
4747
isLoading: false

src/controls/filePicker/controls/DocumentLibraryBrowser/IDocumentLibraryBrowserProps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import { ILibrary } from "../../../../services/FileBrowserService.types";
44
export interface IDocumentLibraryBrowserProps {
55
fileBrowserService: FileBrowserService;
66
onOpenLibrary: (selectedLibrary: ILibrary) => void;
7+
includePageLibraries?: boolean;
78
}

src/controls/filePicker/controls/FileBrowser/FileBrowser.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ export class FileBrowser extends React.Component<IFileBrowserProps, IFileBrowser
4444
const folderIcon: string = strings.FolderIconUrl;
4545
// TODO: Improve file icon URL
4646
const isPhoto = GeneralHelper.isImage(item.name);
47-
const iconUrl = isPhoto ? strings.PhotoIconUrl : `https://spoprod-a.akamaihd.net/files/odsp-next-prod_2019-01-11_20190116.001/odsp-media/images/itemtypes/20_2x/${item.fileType}.png`;
47+
let fileType = item.fileType;
48+
if (fileType.toLowerCase() === 'aspx') {
49+
fileType = 'html';
50+
}
51+
const iconUrl = isPhoto ? strings.PhotoIconUrl : `https://spoprod-a.akamaihd.net/files/odsp-next-prod_2019-01-11_20190116.001/odsp-media/images/itemtypes/20_2x/${fileType}.png`;
4852

4953
const altText: string = item.isFolder ? strings.FolderAltText : strings.ImageAltText.replace('{0}', item.fileType);
5054
return <div className={styles.fileTypeIcon}>

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
14451445
onChange={(filePickerResult: IFilePickerResult) => { console.log(filePickerResult.fileName); }}
14461446
context={this.props.context}
14471447
hideRecentTab={false}
1448+
includePageLibraries={true}
14481449
/>
14491450
{
14501451
this.state.filePickerResult &&

0 commit comments

Comments
 (0)