Skip to content

Commit

Permalink
Merge pull request #792 from pnp/filepicker-site-pages
Browse files Browse the repository at this point in the history
#601 - allow display Site Pages on Site tab
  • Loading branch information
AJIXuMuK authored Jan 29, 2021
2 parents bd85345 + c507b16 commit 2d6f962
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/documentation/docs/controls/FilePicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The FilePicker component can be configured with the following properties:
| 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` |
| renderCustomUploadTabContent | (filePickerResult: IFilePickerResult) => JSX.Element \| null | no | Optional renderer to add custom user-defined fields to "Upload" tab |
| renderCustomLinkTabContent | (filePickerResult: IFilePickerResult) => JSX.Element \| null | no | Optional renderer to add custom user-defined fields to "Link" tab |
| includePageLibraries | boolean | no | Specifies if Site Pages library to be visible on Sites tab |

interface `IFilePickerResult`

Expand Down
1 change: 1 addition & 0 deletions src/controls/filePicker/FilePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export class FilePicker extends React.Component<
{this.state.selectedTab === "keySite" && (
<SiteFilePickerTab
fileBrowserService={this.fileBrowserService}
includePageLibraries={this.props.includePageLibraries}
{...linkTabProps}
/>
)}
Expand Down
5 changes: 5 additions & 0 deletions src/controls/filePicker/IFilePickerProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,9 @@ export interface IFilePickerProps {
* Optional additional renderer for Upload tab
*/
renderCustomUploadTabContent?: (filePickerResult: IFilePickerResult) => JSX.Element | null;

/**
* Specifies if Site Pages library to be visible on Sites tab
*/
includePageLibraries?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export interface ISiteFilePickerTabProps extends IFilePickerTab {
* Represents the base node in the breadrumb navigation
*/
breadcrumbFirstNode?: IBreadcrumbItem;

includePageLibraries?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class SiteFilePickerTab extends React.Component<ISiteFilePickerTa
{this.state.libraryAbsolutePath === undefined &&
<DocumentLibraryBrowser
fileBrowserService={this.props.fileBrowserService}
includePageLibraries={this.props.includePageLibraries}
onOpenLibrary={(selectedLibrary: ILibrary) => this._handleOpenLibrary(selectedLibrary, true)} />}
{this.state.libraryAbsolutePath !== undefined &&
<FileBrowser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class DocumentLibraryBrowser extends React.Component<IDocumentLibraryBrow
}

public async componentDidMount() {
const lists = await this.props.fileBrowserService.getSiteMediaLibraries();
const lists = await this.props.fileBrowserService.getSiteMediaLibraries(this.props.includePageLibraries);
this.setState({
lists: lists,
isLoading: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import { ILibrary } from "../../../../services/FileBrowserService.types";
export interface IDocumentLibraryBrowserProps {
fileBrowserService: FileBrowserService;
onOpenLibrary: (selectedLibrary: ILibrary) => void;
includePageLibraries?: boolean;
}
6 changes: 5 additions & 1 deletion src/controls/filePicker/controls/FileBrowser/FileBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export class FileBrowser extends React.Component<IFileBrowserProps, IFileBrowser
const folderIcon: string = strings.FolderIconUrl;
// TODO: Improve file icon URL
const isPhoto = GeneralHelper.isImage(item.name);
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`;
let fileType = item.fileType;
if (fileType.toLowerCase() === 'aspx') {
fileType = 'html';
}
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`;

const altText: string = item.isFolder ? strings.FolderAltText : strings.ImageAltText.replace('{0}', item.fileType);
return <div className={styles.fileTypeIcon}>
Expand Down
1 change: 1 addition & 0 deletions src/webparts/controlsTest/components/ControlsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
onChange={(filePickerResult: IFilePickerResult) => { console.log(filePickerResult.fileName); }}
context={this.props.context}
hideRecentTab={false}
includePageLibraries={true}
/>
{
this.state.filePickerResult &&
Expand Down

0 comments on commit 2d6f962

Please sign in to comment.