Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix - changed API for OrgAssets items #687

Merged
merged 1 commit into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": "gulp build",
"clean": "gulp clean",
"test": "gulp test",
"serve": "gulp serve",
"prepublishOnly": "gulp",
"versionUpdater": "gulp versionUpdater",
"karma": "karma start --circle true",
Expand Down
8 changes: 4 additions & 4 deletions src/services/OrgAssetsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export class OrgAssetsService extends FileBrowserService {

public getSiteMediaLibraries = async (includePageLibraries: boolean = false): Promise<ILibrary[]> => {
try {
const restApi = `${this.context.pageContext.web.absoluteUrl}/_api/Microsoft.Online.SharePoint.TenantManagement.Office365Tenant/GetOrgAssets`;
const restApi = `${this.context.pageContext.web.absoluteUrl}/_api/SP.Publishing.SitePageService.FilePickerTabOptions`;
const orgAssetsResult = await this.context.spHttpClient.get(restApi, SPHttpClient.configurations.v1);

if (!orgAssetsResult || !orgAssetsResult.ok) {
throw new Error(`Something went wrong when executing request. Status='${orgAssetsResult.status}'`);
}
const orgAssetsData = await orgAssetsResult.json();
if (!orgAssetsData || !orgAssetsData.OrgAssetsLibraries || !orgAssetsData.OrgAssetsLibraries.Items || orgAssetsData.OrgAssetsLibraries.Items.length <= 0) {
if (!orgAssetsData || !orgAssetsData.OrgAssets || !orgAssetsData.OrgAssets.OrgAssetsLibraries || !orgAssetsData.OrgAssets.OrgAssetsLibraries.Items || orgAssetsData.OrgAssets.OrgAssetsLibraries.Items.length <= 0) {
return null;
}

this._orgAssetsLibraryServerRelativeSiteUrl = orgAssetsData ? orgAssetsData.Url.DecodedUrl : null;
const libs: ILibrary[] = orgAssetsData ? orgAssetsData.OrgAssetsLibraries.Items.map((libItem) => { return this._parseOrgAssetsLibraryItem(libItem); }) : [];
this._orgAssetsLibraryServerRelativeSiteUrl = orgAssetsData ? orgAssetsData.OrgAssets.Url.DecodedUrl : null;
const libs: ILibrary[] = orgAssetsData && orgAssetsData.OrgAssets ? orgAssetsData.OrgAssets.OrgAssetsLibraries.Items.map((libItem) => { return this._parseOrgAssetsLibraryItem(libItem); }) : [];
return libs;
} catch (error) {
console.error(`[OrgAssetsService.getOrganisationAssetsLibraries]: Err='${error.message}'`);
Expand Down