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

View File

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

View File

@ -194,8 +194,22 @@ class SettingsStore {
this.hideConfirmConvertSave = hideConfirmConvertSave;
};
canViewedDocs = (extension) =>
presentInArray(this.extsWebPreviewed, 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);
isImage = (extension) => presentInArray(this.extsImage, extension);

View File

@ -53,14 +53,15 @@ class AuthStore {
this.skipRequest = skipRequest;
try {
await this.userStore.init();
} catch (e) {
console.error(e);
}
await this.settingsStore.init();
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) {
requests.push(
@ -222,7 +223,7 @@ class AuthStore {
get isAuthenticated() {
return (
this.userStore.isAuthenticated ||
(this.settingsStore.isLoaded && this.settingsStore.socketUrl) || //this.userStore.isAuthenticated ||
this.settingsStore.tenantStatus === TenantStatus.PortalRestore
);
}

View File

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

View File

@ -81,8 +81,14 @@ public class WhitelabelController : BaseSettingsController
var logoDict = new Dictionary<int, KeyValuePair<string, string>>();
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);

View File

@ -64,10 +64,15 @@ public class LogoUploader
reader.Read(data, 0, (int)logo.Length);
reader.Close();
if (logo.ContentType.Contains("svg"))
if (logo.ContentType.Contains("image/x-icon"))
{
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
{

View File

@ -768,7 +768,7 @@ public class UserPhotoManager
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)
{
@ -776,7 +776,7 @@ public class UserPhotoManager
}
using var stream = new MemoryStream(data);
var fileName = Guid.NewGuid() + ".svg";
var fileName = Guid.NewGuid() + $".{ext}";
var store = GetDataStore();
return (await store.SaveAsync(_tempDomainName, fileName, stream)).ToString();
}

View File

@ -562,7 +562,13 @@ public class TenantWhiteLabelSettingsHelper
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)
@ -647,11 +653,6 @@ public class TenantWhiteLabelSettingsHelper
return $"{(dark ? "dark_" : "")}{type.ToString().ToLowerInvariant()}.{fileExt}";
}
if (type == WhiteLabelLogoTypeEnum.Favicon)
{
return "favicon.ico";
}
return $"{type.ToString().ToLowerInvariant()}.{fileExt}";
}