Merge branch 'develop' into feature/refactoring-auth-store

This commit is contained in:
Timofey Boyko 2024-01-30 09:32:03 +03:00
commit 9a3279c6d7
6 changed files with 78 additions and 56 deletions

View File

@ -287,6 +287,7 @@ const PureConnectDialogContainer = (props) => {
)}
<FieldContainer
labelVisible
labelText={t("Login")}
isRequired
isVertical
@ -305,6 +306,7 @@ const PureConnectDialogContainer = (props) => {
/>
</FieldContainer>
<FieldContainer
labelVisible
labelText={t("Common:Password")}
isRequired
isVertical

View File

@ -43,12 +43,9 @@ const ThirdPartyStorage = ({
}) => {
const onChangeIsThirdparty = () => {
if (isDisabled) return;
if (connectItems.length) {
onChangeStorageLocation({
...storageLocation,
isThirdparty: !storageLocation.isThirdparty,
});
} else {
if (!connectItems.length) {
const data = isRoomAdmin ? (
<Text as="p">{t("ThirdPartyStorageRoomAdminNoStorageAlert")}</Text>
) : (
@ -66,7 +63,14 @@ const ThirdPartyStorage = ({
);
toastr.warning(data, null, 5000, true, false);
return;
}
onChangeStorageLocation({
...storageLocation,
isThirdparty: !storageLocation.isThirdparty,
});
};
const onChangeProvider = async (provider) => {
@ -91,13 +95,13 @@ const ThirdPartyStorage = ({
return (
<StyledThirdPartyStorage>
{/* <ToggleParam
<ToggleParam
id="shared_third-party-storage-toggle"
title={t("Common:ThirdPartyStorage")}
description={t("ThirdPartyStorageDescription")}
isChecked={storageLocation.isThirdparty}
onCheckedChange={onChangeIsThirdparty}
/> */}
/>
{storageLocation.isThirdparty && (
<ThirdPartyComboBox

View File

@ -33,7 +33,7 @@ const GeneralSettings = ({
isChecked={storeForceSave}
/>
</Box>
{/* //TODO: Uncomment when third-party storages will be stable
<Box className="settings-section">
<Heading className="heading" level={2} size="xsmall">
{t("ThirdPartyAccounts")}
@ -44,7 +44,7 @@ const GeneralSettings = ({
onChange={onChangeThirdParty}
isChecked={enableThirdParty}
/>
</Box> */}
</Box>
</StyledSettings>
);
};

View File

@ -125,20 +125,18 @@ class FilesSettingsStore {
if (!settings.enableThirdParty || this.publicRoomStore.isPublicRoom)
return;
// TODO: enable after supporting third-party
// return axios
// .all([
// api.files.getThirdPartyCapabilities(),
// api.files.getThirdPartyList(),
// ])
// .then(([capabilities, providers]) => {
// for (let item of capabilities) {
// item.splice(1, 1);
// }
// this.thirdPartyStore.setThirdPartyCapabilities(capabilities); //TODO: Out of bounds read: 1
// this.thirdPartyStore.setThirdPartyProviders(providers);
// });
return axios
.all([
api.files.getThirdPartyCapabilities(),
api.files.getThirdPartyList(),
])
.then(([capabilities, providers]) => {
for (let item of capabilities) {
item.splice(1, 1);
}
this.thirdPartyStore.setThirdPartyCapabilities(capabilities); //TODO: Out of bounds read: 1
this.thirdPartyStore.setThirdPartyProviders(providers);
});
})
.catch(() => this.setIsErrorSettings(true));
};
@ -173,7 +171,7 @@ class FilesSettingsStore {
};
setEnableThirdParty = async (data, setting) => {
const res = await api.files.thirdParty(data);
const res = await api.files.enableThirdParty(data);
this.setFilesSetting(setting, res);
if (data) {

View File

@ -28,6 +28,7 @@ import {
TSendEditorNotify,
TSharedUsers,
TThirdPartyCapabilities,
TTirdParties,
TUploadOperation,
} from "./types";
@ -860,39 +861,44 @@ export async function changeKeepNewFileName(val: boolean) {
return res;
}
// export function thirdParty(val) {
// const data = { set: val };
// return request({ method: "put", url: "files/thirdparty", data });
// }
export function enableThirdParty(val: boolean) {
const data = { set: val };
return request({ method: "put", url: "files/thirdparty", data });
}
// export function getThirdPartyList() {
// return request({ method: "get", url: "files/thirdparty" });
// }
export async function getThirdPartyList() {
const res = (await request({
method: "get",
url: "files/thirdparty",
})) as TTirdParties;
// export function saveThirdParty(
// url,
// login,
// password,
// token,
// isCorporate,
// customerTitle,
// providerKey,
// providerId,
// isRoomsStorage,
// ) {
// const data = {
// url,
// login,
// password,
// token,
// isCorporate,
// customerTitle,
// providerKey,
// providerId,
// isRoomsStorage,
// };
// return request({ method: "post", url: "files/thirdparty", data });
// }
return res;
}
export function saveThirdParty(
url: string,
login: string,
password: string,
token: string,
isCorporate: boolean,
customerTitle: string,
providerKey: string,
providerId: string,
isRoomsStorage: boolean,
) {
const data = {
url,
login,
password,
token,
isCorporate,
customerTitle,
providerKey,
providerId,
isRoomsStorage,
};
return request({ method: "post", url: "files/thirdparty", data });
}
// TODO: Need update res type
export function saveSettingsThirdParty(
@ -1322,3 +1328,4 @@ export function deleteFilesFromRecent(fileIds: number[]) {
},
});
}

View File

@ -173,6 +173,16 @@ export type TUploadOperation = {
export type TThirdPartyCapabilities = string[][];
export type TThierdParty = {
corporate: boolean;
roomsStorage: boolean;
customerTitle: string;
providerId: string;
providerKey: string;
};
export type TTirdParties = TThierdParty[];
export type TFilesSettings = {
automaticallyCleanUp: {
gap: number;
@ -335,3 +345,4 @@ export type TFileLink = {
title: string;
};
};