Merge branch 'release/rc-v1.2.0' of github.com:ONLYOFFICE/DocSpace into release/rc-v1.2.0

This commit is contained in:
Elyor Djalilov 2022-12-27 16:29:16 +05:00
commit f2a5f77c07
9 changed files with 61 additions and 27 deletions

View File

@ -359,7 +359,12 @@ export default inject(
name = splitted[0]; name = splitted[0];
} }
const { personal, theme } = auth.settingsStore; const { personal, theme } = auth.settingsStore;
const { getIconSrc, isArchive } = settingsStore; const {
canViewedDocs,
isMediaOrImage,
getIconSrc,
isArchive,
} = settingsStore;
const { const {
uploaded, uploaded,
primaryProgressDataStore, primaryProgressDataStore,
@ -377,8 +382,7 @@ export default inject(
setCurrentItem, setCurrentItem,
} = mediaViewerDataStore; } = mediaViewerDataStore;
const { loadingFile: file } = primaryProgressDataStore; const { loadingFile: file } = primaryProgressDataStore;
const isMedia = const isMedia = isMediaOrImage(ext);
item.viewAccessability?.ImageView || item.viewAccessability?.MediaView;
const isMediaActive = const isMediaActive =
playlist.findIndex((el) => el.fileId === item.fileId) !== -1; playlist.findIndex((el) => el.fileId === item.fileId) !== -1;
@ -391,8 +395,7 @@ export default inject(
? loadingFile.percent ? loadingFile.percent
: null; : null;
const downloadInCurrentTab = const downloadInCurrentTab = isArchive(ext) || !canViewedDocs(ext);
isArchive(ext) || !item.viewAccessability?.WebView;
return { return {
isPersonal: personal, isPersonal: personal,

View File

@ -1017,14 +1017,14 @@ class ContextOptionsStore {
key: "pin-room", key: "pin-room",
label: t("PinToTop"), label: t("PinToTop"),
icon: "/static/images/pin.react.svg", icon: "/static/images/pin.react.svg",
onClick: pinRooms, onClick: () => pinRooms(t),
disabled: false, disabled: false,
} }
: { : {
key: "unpin-room", key: "unpin-room",
label: t("Unpin"), label: t("Unpin"),
icon: "/static/images/unpin.react.svg", icon: "/static/images/unpin.react.svg",
onClick: unpinRooms, onClick: () => unpinRooms(t),
disabled: false, disabled: false,
}; };

View File

@ -194,8 +194,22 @@ class SettingsStore {
this.hideConfirmConvertSave = hideConfirmConvertSave; this.hideConfirmConvertSave = hideConfirmConvertSave;
}; };
canViewedDocs = (extension) =>
presentInArray(this.extsWebPreviewed, extension);
canConvert = (extension) => presentInArray(this.extsMustConvert, extension); canConvert = (extension) => presentInArray(this.extsMustConvert, extension);
isMediaOrImage = (fileExst) => {
if (
this.extsVideo.includes(fileExst) ||
this.extsImage.includes(fileExst) ||
this.extsAudio.includes(fileExst)
) {
return true;
}
return false;
};
isArchive = (extension) => presentInArray(this.extsArchive, extension); isArchive = (extension) => presentInArray(this.extsArchive, extension);
isImage = (extension) => presentInArray(this.extsImage, extension); isImage = (extension) => presentInArray(this.extsImage, extension);

View File

@ -53,14 +53,15 @@ class AuthStore {
this.skipRequest = skipRequest; this.skipRequest = skipRequest;
try { await this.settingsStore.init();
await this.userStore.init();
} catch (e) {
console.error(e);
}
const requests = []; const requests = [];
requests.push(this.settingsStore.init());
if (this.settingsStore.isLoaded && this.settingsStore.socketUrl) {
requests.push(this.userStore.init());
} else {
this.userStore.setIsLoaded(true);
}
if (this.isAuthenticated && !skipRequest) { if (this.isAuthenticated && !skipRequest) {
requests.push( requests.push(
@ -222,7 +223,7 @@ class AuthStore {
get isAuthenticated() { get isAuthenticated() {
return ( return (
this.userStore.isAuthenticated || (this.settingsStore.isLoaded && this.settingsStore.socketUrl) || //this.userStore.isAuthenticated ||
this.settingsStore.tenantStatus === TenantStatus.PortalRestore this.settingsStore.tenantStatus === TenantStatus.PortalRestore
); );
} }

View File

@ -31,7 +31,11 @@ class UserStore {
this.setIsLoading(true); this.setIsLoading(true);
await this.loadCurrentUser(); try {
await this.loadCurrentUser();
} catch (e) {
console.error(e);
}
this.setIsLoading(false); this.setIsLoading(false);
this.setIsLoaded(true); this.setIsLoaded(true);

View File

@ -82,7 +82,13 @@ public class WhitelabelController : BaseSettingsController
foreach (var l in inDto.Logo) foreach (var l in inDto.Logo)
{ {
logoDict.Add(Int32.Parse(l.Key), new KeyValuePair<string, string>(l.Value.Light, l.Value.Dark)); var key = Int32.Parse(l.Key);
if (key == (int)WhiteLabelLogoTypeEnum.Favicon && !(l.Value.Light.EndsWith("ico") || l.Value.Light.EndsWith("svg")))
{
throw new InvalidOperationException("Favicon must have .ico or .svg extension");
}
logoDict.Add(key, new KeyValuePair<string, string>(l.Value.Light, l.Value.Dark));
} }
await _tenantWhiteLabelSettingsHelper.SetLogo(settings, logoDict, null); await _tenantWhiteLabelSettingsHelper.SetLogo(settings, logoDict, null);

View File

@ -64,10 +64,15 @@ public class LogoUploader
reader.Read(data, 0, (int)logo.Length); reader.Read(data, 0, (int)logo.Length);
reader.Close(); reader.Close();
if (logo.ContentType.Contains("svg")) if (logo.ContentType.Contains("image/x-icon"))
{ {
result.Success = true; result.Success = true;
result.Message = await userPhotoManager.SaveTempSvg(data, setupInfo.MaxImageUploadSize); result.Message = await userPhotoManager.SaveTempPhoto(data, setupInfo.MaxImageUploadSize, "ico");
}
else if (logo.ContentType.Contains("image/svg+xml"))
{
result.Success = true;
result.Message = await userPhotoManager.SaveTempPhoto(data, setupInfo.MaxImageUploadSize, "svg");
} }
else else
{ {

View File

@ -768,7 +768,7 @@ public class UserPhotoManager
return (await store.SaveAsync(_tempDomainName, fileName, stream)).ToString(); return (await store.SaveAsync(_tempDomainName, fileName, stream)).ToString();
} }
public async Task<string> SaveTempSvg(byte[] data, long maxFileSize) public async Task<string> SaveTempPhoto(byte[] data, long maxFileSize, string ext)
{ {
if (maxFileSize != -1 && data.Length > maxFileSize) if (maxFileSize != -1 && data.Length > maxFileSize)
{ {
@ -776,7 +776,7 @@ public class UserPhotoManager
} }
using var stream = new MemoryStream(data); using var stream = new MemoryStream(data);
var fileName = Guid.NewGuid() + ".svg"; var fileName = Guid.NewGuid() + $".{ext}";
var store = GetDataStore(); var store = GetDataStore();
return (await store.SaveAsync(_tempDomainName, fileName, stream)).ToString(); return (await store.SaveAsync(_tempDomainName, fileName, stream)).ToString();
} }

View File

@ -562,7 +562,13 @@ public class TenantWhiteLabelSettingsHelper
return partnerLogoPath; return partnerLogoPath;
} }
return _webImageSupplier.GetAbsoluteWebPath($"logo/" + BuildLogoFileName(type, "svg", dark)); var ext = type switch
{
WhiteLabelLogoTypeEnum.Favicon => "ico",
_ => "svg"
};
return _webImageSupplier.GetAbsoluteWebPath($"logo/" + BuildLogoFileName(type, ext, dark));
} }
private async Task<string> GetPartnerStorageLogoPath(WhiteLabelLogoTypeEnum type, bool dark) private async Task<string> GetPartnerStorageLogoPath(WhiteLabelLogoTypeEnum type, bool dark)
@ -647,11 +653,6 @@ public class TenantWhiteLabelSettingsHelper
return $"{(dark ? "dark_" : "")}{type.ToString().ToLowerInvariant()}.{fileExt}"; return $"{(dark ? "dark_" : "")}{type.ToString().ToLowerInvariant()}.{fileExt}";
} }
if (type == WhiteLabelLogoTypeEnum.Favicon)
{
return "favicon.ico";
}
return $"{type.ToString().ToLowerInvariant()}.{fileExt}"; return $"{type.ToString().ToLowerInvariant()}.{fileExt}";
} }