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 ( update = async (
id: string, id: string,
content: Partial<DriveFile>, content: Partial<DriveFile> & { is_update_access_to_share_link?: boolean },
context: CompanyExecutionContext, context: CompanyExecutionContext,
): Promise<DriveFile> => { ): Promise<DriveFile> => {
if (!context) { if (!context) {
@@ -614,7 +614,7 @@ export class DocumentsService {
} }
if (key === "access_info") { if (key === "access_info") {
// if manage access is disabled, we don't allow changing access level // 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; delete content.access_info;
} else if (content.access_info) { } else if (content.access_info) {
const sharedWith = content.access_info.entities.filter( const sharedWith = content.access_info.entities.filter(
@@ -257,7 +257,7 @@ export class DocumentsController {
update = async ( update = async (
request: FastifyRequest<{ request: FastifyRequest<{
Params: ItemRequestParams; Params: ItemRequestParams;
Body: Partial<DriveFile>; Body: Partial<DriveFile> & { is_update_access_to_share_link?: boolean };
Querystring: { public_token?: string }; Querystring: { public_token?: string };
}>, }>,
): Promise<DriveFile> => { ): 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>( return await Api.post<Partial<DriveItem>, DriveItem>(
`/internal/services/documents/v1/companies/${companyId}/item/${id}${appendTdriveToken()}`, `/internal/services/documents/v1/companies/${companyId}/item/${id}${appendTdriveToken()}`,
update, update,
@@ -235,7 +235,7 @@ export const useDriveActions = (inPublicSharing?: boolean) => {
); );
const update = useCallback( 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 { try {
const newItem = await DriveApiClient.update(companyId, id, update); const newItem = await DriveApiClient.update(companyId, id, update);
if (previousName && previousName !== newItem.name && !update.name) if (previousName && previousName !== newItem.name && !update.name)
@@ -65,7 +65,7 @@ export const useDriveItem = (id: string) => {
}, [id, setLoading, refresh, item?.item?.parent_id]); }, [id, setLoading, refresh, item?.item?.parent_id]);
const update = useCallback( 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); if (!skipLoading) setLoading(true);
try { try {
await _update(update, id, item?.item?.parent_id || ''); await _update(update, id, item?.item?.parent_id || '');
@@ -140,7 +140,10 @@ const PublicLinkModalContent = (props: {
disabled={loading} disabled={loading}
level={item?.access_info?.public?.level || 'none'} level={item?.access_info?.public?.level || 'none'}
onChange={level => { onChange={level => {
item && update(changePublicLink(item, { level })); item && update({
...changePublicLink(item, { level }),
is_update_access_to_share_link: true,
});
}} }}
/> />
<SwitchToAdvancedSettingsRow <SwitchToAdvancedSettingsRow