From c66120080405efef9167a4a7436a5061d7a021e0 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 21 Nov 2023 12:48:06 +0300 Subject: [PATCH] Common: add share method --- packages/common/api/files/index.js | 18 ++++++++++-------- packages/common/store/InfoPanelStore.js | 9 +++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/packages/common/api/files/index.js b/packages/common/api/files/index.js index aaea991601..ae661de82c 100644 --- a/packages/common/api/files/index.js +++ b/packages/common/api/files/index.js @@ -1039,7 +1039,7 @@ export function changeDocumentServiceLocation( }); } -export function getExternalLinks(fileId, startIndex = 0, count = 5) { +export function getExternalLinks(fileId, startIndex = 0, count = 50) { const linkParams = `?startIndex=${startIndex}&count=${count}`; return request({ @@ -1058,13 +1058,15 @@ export function getPrimaryLink(fileId) { export function editExternalLink(fileId, linkId, access, primary, internal) { return request({ method: "put", - url: `/files/file/${fileId}/links`, - data: { - linkId, - access, - primary, - internal, - }, + data: { linkId, access, primary, internal }, + }); +} + +export function addExternalLink(fileId, access, primary, internal) { + return request({ + method: "put", + url: `/files/file/${fileId}/links`, + data: { access, primary, internal }, }); } diff --git a/packages/common/store/InfoPanelStore.js b/packages/common/store/InfoPanelStore.js index 3ee27f5cf6..3db78a37db 100644 --- a/packages/common/store/InfoPanelStore.js +++ b/packages/common/store/InfoPanelStore.js @@ -10,6 +10,7 @@ import { getPrimaryLink, getExternalLinks, editExternalLink, + addExternalLink, } from "../api/files"; const observedKeys = [ @@ -362,7 +363,7 @@ class InfoPanelStore { return res; }; - getAdditionalFileLinks = async (fileId) => { + getFileLinks = async (fileId) => { const res = await getExternalLinks(fileId); return res; }; @@ -375,7 +376,11 @@ class InfoPanelStore { primary, internal ); - console.log(res); + return res; + }; + + addFileLink = async (fileId, access, primary, internal) => { + const res = await addExternalLink(fileId, access, primary, internal); return res; }; }