Skip to content

Fix/file picker org assets root site #1954

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

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
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 .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions src/services/OrgAssetsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ export class OrgAssetsService extends FileBrowserService {
// Site organization assets library server relative URL
private _orgAssetsLibraryServerRelativeSiteUrl: string = null;

private get orgAssetsLibraryServerRelativeSiteUrl(): string {
return this._orgAssetsLibraryServerRelativeSiteUrl;
}

private set orgAssetsLibraryServerRelativeSiteUrl(value: string) {
if (value === "/") {
this._orgAssetsLibraryServerRelativeSiteUrl = "";
}
else {
this._orgAssetsLibraryServerRelativeSiteUrl = value?.replace(/\/$/, "") ?? null
}
}

/**
* Constructor
* @param context Component context
Expand All @@ -35,11 +48,11 @@ export class OrgAssetsService extends FileBrowserService {
}

// Remove all the rest of the folder path
let libName = folderPath.replace(`${this._orgAssetsLibraryServerRelativeSiteUrl}/`, '');
let libName = folderPath.replace(`${this.orgAssetsLibraryServerRelativeSiteUrl}/`, '');
libName = libName.split('/')[0];

// Build absolute library URL
const libFullUrl = this.buildAbsoluteUrl(`${this._orgAssetsLibraryServerRelativeSiteUrl}/${libName}`);
const libFullUrl = this.buildAbsoluteUrl(`${this.orgAssetsLibraryServerRelativeSiteUrl}/${libName}`);

let queryStringParams: string = "";
// Do not pass FolderServerRelativeUrl as query parameter
Expand All @@ -66,7 +79,7 @@ export class OrgAssetsService extends FileBrowserService {
/**
* Gets document and media libraries from the site
* @param includePageLibraries Unused parameter (not used in this implementation)
* @returns Document and media libraries from the site
* @returns Document and media libraries from the site
*/
public getSiteMediaLibraries = async (includePageLibraries: boolean = false): Promise<ILibrary[]> => {
try {
Expand All @@ -81,7 +94,7 @@ export class OrgAssetsService extends FileBrowserService {
return null;
}

this._orgAssetsLibraryServerRelativeSiteUrl = orgAssetsData ? orgAssetsData.OrgAssets.Url.DecodedUrl : null;
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) {
Expand All @@ -100,7 +113,7 @@ export class OrgAssetsService extends FileBrowserService {
absoluteUrl: this.buildAbsoluteUrl(libItem.LibraryUrl.DecodedUrl),
title: libItem.DisplayName,
serverRelativeUrl: libItem.LibraryUrl.DecodedUrl,
iconPath: libItem.ThumbnailUrl && libItem.ThumbnailUrl.DecodedUrl ? this.buildAbsoluteUrl(`${this._orgAssetsLibraryServerRelativeSiteUrl}/${libItem.ThumbnailUrl.DecodedUrl}`) : null
iconPath: libItem.ThumbnailUrl && libItem.ThumbnailUrl.DecodedUrl ? this.buildAbsoluteUrl(`${this.orgAssetsLibraryServerRelativeSiteUrl}/${libItem.ThumbnailUrl.DecodedUrl}`) : null
};

return orgAssetsLibrary;
Expand Down