Add flag to always allow share by link

This commit is contained in:
lethemanh
2025-05-16 20:19:20 +07:00
parent 7595a6d856
commit d831ffc5fe
6 changed files with 10 additions and 7 deletions
@@ -550,7 +550,7 @@ export class DocumentsService {
*/
update = async (
id: string,
content: Partial<DriveFile>,
content: Partial<DriveFile> & { is_update_access_to_share_link?: boolean },
context: CompanyExecutionContext,
): Promise<DriveFile> => {
if (!context) {
@@ -614,7 +614,7 @@ export class DocumentsService {
}
if (key === "access_info") {
// if manage access is disabled, we don't allow changing access level
if (!this.manageAccessEnabled) {
if (!this.manageAccessEnabled && !content.is_update_access_to_share_link) {
delete content.access_info;
} else if (content.access_info) {
const sharedWith = content.access_info.entities.filter(
@@ -257,7 +257,7 @@ export class DocumentsController {
update = async (
request: FastifyRequest<{
Params: ItemRequestParams;
Body: Partial<DriveFile>;
Body: Partial<DriveFile> & { is_update_access_to_share_link?: boolean };
Querystring: { public_token?: string };
}>,
): Promise<DriveFile> => {
@@ -114,7 +114,7 @@ export class DriveApiClient {
);
}
static async update(companyId: string, id: string, update: Partial<DriveItem>) {
static async update(companyId: string, id: string, update: Partial<DriveItem> & { is_update_access_to_share_link?: boolean }) {
return await Api.post<Partial<DriveItem>, DriveItem>(
`/internal/services/documents/v1/companies/${companyId}/item/${id}${appendTdriveToken()}`,
update,
@@ -235,7 +235,7 @@ export const useDriveActions = (inPublicSharing?: boolean) => {
);
const update = useCallback(
async (update: Partial<DriveItem>, id: string, parentId: string, previousName?: string) => {
async (update: Partial<DriveItem> & { is_update_access_to_share_link?: boolean }, id: string, parentId: string, previousName?: string) => {
try {
const newItem = await DriveApiClient.update(companyId, id, update);
if (previousName && previousName !== newItem.name && !update.name)
@@ -65,7 +65,7 @@ export const useDriveItem = (id: string) => {
}, [id, setLoading, refresh, item?.item?.parent_id]);
const update = useCallback(
async (update: Partial<DriveItem>, skipLoading = false) => {
async (update: Partial<DriveItem> & { is_update_access_to_share_link?: boolean }, skipLoading = false) => {
if (!skipLoading) setLoading(true);
try {
await _update(update, id, item?.item?.parent_id || '');
@@ -140,7 +140,10 @@ const PublicLinkModalContent = (props: {
disabled={loading}
level={item?.access_info?.public?.level || 'none'}
onChange={level => {
item && update(changePublicLink(item, { level }));
item && update({
...changePublicLink(item, { level }),
is_update_access_to_share_link: true,
});
}}
/>
<SwitchToAdvancedSettingsRow