Skip to content

Commit

Permalink
Merge pull request #687 from gautamdsheth/bugfix/orgAssetsPermissionFix
Browse files Browse the repository at this point in the history
Feature/fix - changed API for OrgAssets items
  • Loading branch information
AJIXuMuK authored Oct 7, 2020
2 parents 4fa08a2 + 2f0261f commit 17e196e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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

0 comments on commit 17e196e

Please sign in to comment.