Skip to content

Commit e9c7e3a

Browse files
author
Piotr Siatka
committed
Add support for AppCustomizer.
Add missing default export.
1 parent f972238 commit e9c7e3a

File tree

9 files changed

+21
-14
lines changed

9 files changed

+21
-14
lines changed

src/controls/filePicker/FilePicker.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ export class FilePicker extends React.Component<IFilePickerProps, IFilePickerSta
3939
telemetry.track('FilePicker', {});
4040

4141
// Initialize file browser services
42-
this.fileBrowserService = new FileBrowserService(props.webPartContext, this.props.itemsCountQueryLimit);
43-
this.oneDriveService = new OneDriveService(props.webPartContext, this.props.itemsCountQueryLimit);
44-
this.orgAssetsService = new OrgAssetsService(props.webPartContext, this.props.itemsCountQueryLimit);
45-
this.fileSearchService = new FilesSearchService(props.webPartContext, this.props.bingAPIKey);
42+
this.fileBrowserService = new FileBrowserService(props.context, this.props.itemsCountQueryLimit);
43+
this.oneDriveService = new OneDriveService(props.context, this.props.itemsCountQueryLimit);
44+
this.orgAssetsService = new OrgAssetsService(props.context, this.props.itemsCountQueryLimit);
45+
this.fileSearchService = new FilesSearchService(props.context, this.props.bingAPIKey);
4646

4747
this.state = {
4848
panelOpen: false,
@@ -68,7 +68,7 @@ export class FilePicker extends React.Component<IFilePickerProps, IFilePickerSta
6868

6969
const linkTabProps = {
7070
accepts: accepts,
71-
context: this.props.webPartContext,
71+
context: this.props.context,
7272
onClose: () => this._handleClosePanel(),
7373
onSave: (value: IFilePickerResult) => { this._handleSave(value); }
7474
};

src/controls/filePicker/FilePicker.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { WebPartContext } from "@microsoft/sp-webpart-base";
22
import { IBreadcrumbItem } from "office-ui-fabric-react/lib/Breadcrumb";
33
import { IFile, ILibrary } from "../../services/FileBrowserService.types";
4+
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";
45

56
export interface FilePickerBreadcrumbItem extends IBreadcrumbItem {
67
libraryData?: ILibrary;
78
folderData?: IFile;
89
}
910

1011
export interface IFilePickerTab {
11-
context: WebPartContext;
12+
context: ApplicationCustomizerContext | WebPartContext;
1213
accepts: string[];
1314
onSave: (value: IFilePickerResult) => void;
1415
onClose: () => void;

src/controls/filePicker/IFilePickerProps.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { WebPartContext } from "@microsoft/sp-webpart-base";
22
import { IFilePickerResult } from "./FilePicker.types";
3+
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";
34

45
export interface IFilePickerProps {
56
/**
@@ -29,7 +30,7 @@ export interface IFilePickerProps {
2930
/**
3031
* Current context.
3132
*/
32-
webPartContext: WebPartContext;
33+
context: ApplicationCustomizerContext | WebPartContext;
3334

3435
/**
3536
* File extensions to be displayed.

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export * from './ListItemAttachments';
1010
export * from './ChartControl';
1111
export * from './Progress';
1212
export * from './DateTimePicker';
13+
export * from './FilePicker';
1314

1415
export * from './IFrameDialog';
1516
export * from './IFramePanel';

src/services/FileBrowserService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import { WebPartContext } from "@microsoft/sp-webpart-base";
22
import { IFile, FilesQueryResult, ILibrary } from "./FileBrowserService.types";
33
import { SPHttpClient } from "@microsoft/sp-http";
44
import { GeneralHelper } from "..";
5+
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";
56

67
export class FileBrowserService {
78
protected itemsToDownloadCount: number;
8-
protected context: WebPartContext;
9+
protected context: ApplicationCustomizerContext | WebPartContext;
910

1011
protected driveAccessToken: string;
1112
protected mediaBaseUrl: string;
1213
protected callerStack: string;
1314

14-
constructor(context: WebPartContext, itemsToDownloadCount: number = 100) {
15+
constructor(context: ApplicationCustomizerContext | WebPartContext, itemsToDownloadCount: number = 100) {
1516
this.context = context;
1617

1718
this.itemsToDownloadCount = itemsToDownloadCount;

src/services/FilesSearchService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { WebPartContext } from "@microsoft/sp-webpart-base";
22
import { IHttpClientOptions, SPHttpClient, SPHttpClientResponse } from "@microsoft/sp-http";
33
import { ISearchResult, BingQuerySearchParams, IRecentFile } from "./FilesSearchService.types";
44
import { find } from "office-ui-fabric-react/lib/Utilities";
5+
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";
56

67
/**
78
* Maximum file size when searching
@@ -14,10 +15,10 @@ const MAXFILESIZE = 52428800;
1415
const MAXRESULTS = 100;
1516

1617
export class FilesSearchService {
17-
private context: WebPartContext;
18+
private context: ApplicationCustomizerContext | WebPartContext;
1819
private bingAPIKey: string;
1920

20-
constructor(context: WebPartContext, bingAPIKey: string) {
21+
constructor(context: ApplicationCustomizerContext | WebPartContext, bingAPIKey: string) {
2122
this.context = context;
2223
this.bingAPIKey = bingAPIKey;
2324
}

src/services/OneDriveService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import { IGetListDataAsStreamResult, IRow } from './IOneDriveService';
77
import { GeneralHelper } from "../Utilities";
88
import { FileBrowserService } from "./FileBrowserService";
99
import { IFile, FilesQueryResult } from "./FileBrowserService.types";
10+
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";
1011

1112
export class OneDriveService extends FileBrowserService {
1213
protected oneDrivePersonalUrl: string;
1314
protected oneDriveRootFolderRelativeUrl: string;
1415
protected oneDriveRootFolderAbsoluteUrl: string;
1516
protected oneDrivePersonalLibraryTitle: string;
1617

17-
constructor(context: WebPartContext, itemsToDownloadCount?: number) {
18+
constructor(context: ApplicationCustomizerContext | WebPartContext, itemsToDownloadCount?: number) {
1819
super(context, itemsToDownloadCount);
1920

2021
this.oneDrivePersonalUrl = null;

src/services/OrgAssetsService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { FileBrowserService } from "./FileBrowserService";
22
import { WebPartContext } from "@microsoft/sp-webpart-base";
33
import { SPHttpClient } from "@microsoft/sp-http";
44
import { ILibrary, FilesQueryResult } from "./FileBrowserService.types";
5+
import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";
56

67
export class OrgAssetsService extends FileBrowserService {
78
private _orgAssetsLibraryServerRelativeSiteUrl: string = null;
89

9-
constructor(context: WebPartContext, itemsToDownloadCount?: number) {
10+
constructor(context: ApplicationCustomizerContext | WebPartContext, itemsToDownloadCount?: number) {
1011
super(context, itemsToDownloadCount);
1112
}
1213

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
809809
buttonIcon="FileImage"
810810
onSave={(filePickerResult: IFilePickerResult) => { this.setState({ filePickerResult }); }}
811811
onChanged={(filePickerResult: IFilePickerResult) => { this.setState({ filePickerResult }); }}
812-
webPartContext={this.props.context}
812+
context={this.props.context}
813813
/>
814814
{
815815
this.state.filePickerResult &&

0 commit comments

Comments
 (0)