Skip to content

Feat/add share link to drive files#386

Open
egalvis27 wants to merge 6 commits into
mainfrom
feat/add-share-link-to-drive-files
Open

Feat/add share link to drive files#386
egalvis27 wants to merge 6 commits into
mainfrom
feat/add-share-link-to-drive-files

Conversation

@egalvis27

Copy link
Copy Markdown

What is Changed / Added


  • Restored and updated Nautilus context menu behavior for virtual drive items.
  • Temporarily disabled the Make Available Offline menu action.
  • Added a new Copy Internxt Link action in Nautilus, shown only for single remote item selection.
  • Wired the new menu action end-to-end:
    • Nautilus extension calls hydration API.
    • Hydration route and controller now handle copy-link requests.
    • Main process generates a valid sharing link and returns it to the caller.
  • Implemented sharing-link generation in a modular structure under nautilus-extension/create-sharing-link:
    • Shareable item resolution from path.
    • Public sharing domain selection.
    • Sharing creation request.
    • Link assembly and normalized error mapping.
  • Added/updated drive-server service wrappers to use the project shared HTTP client for:
    • File metadata by path.
    • Folder metadata by path.
    • Sharing creation.
    • Public sharing domains retrieval.
  • Added focused tests for link generation flow and updated related mocks/bootstrap wiring.
  • Bumped Nautilus extension version to trigger extension refresh/reinstall behavior.
  • Included minor supporting maintenance changes:
    • TypeScript max errors script threshold update.
    • Consistency adjustments in related virtual drive/bootstrap test paths.

Why

  • Improve Linux Nautilus integration by giving users a direct way to create and copy Internxt sharing links from the context menu.
  • Keep offline hydration UX controlled while the share-link feature is rolled out safely.
  • Ensure the new action is available only in valid contexts (single remote item), reducing incorrect usage.
  • Reuse the project-standard drive-server client and service layer to keep architecture consistent and maintainable.
  • Increase reliability and confidence through targeted test coverage and explicit error handling.

Comment thread scripts/tsc-max-errors.sh Outdated
# TODO: Decrease this number as errors are fixed, never increase it
# Note: CI environment may have different error count than local due to dependency differences
MAX_ERRORS=146
MAX_ERRORS=150

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several errors had crept in because the interfaces in the diagrams are unusual, but I managed to minimize them to avoid raising the threshold.

}
};

const copyLink = async (req: Request, res: Response, next: NextFunction) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt we use function? Also this method lacks tests

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

});
}

return result.data as SharingResponse;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont force the type, why not infer the type directly from result.data?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,32 @@
import { createSharing } from '../../../../infra/drive-server/services/sharings/services/create-sharing';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this file lacks tests, and maybe it could be a good oportunity to move this functionality inside backend?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const domains = getDomains(result.data);

if (domains.length === 0) {
throw new Error('No share domains available');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldnt it be better to the user to show a native notification, pretty much like we show a toast in drive web?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

};

export async function resolveShareableItem({ path }: Props) {
const candidatePaths = Array.from(new Set([path, path.startsWith('/') ? path.slice(1) : `/${path}`].filter(Boolean)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the reason behind this expression? What where you trying to achieve? Seems quite hacky and hard to understand at a first glance

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That line generates an array of the file or folder path with and without a trailing slash, to retrieve the file information without encountering an error because it is stored in the backend with an extra trailing slash.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expression creates an array with two elements: the file/folder path with and without a trailing slash. To avoid issues related to how the backend stores the path when retrieving metadata, both options are validated, and the result is returned as soon as the required information is found.

list: string[];
};

export type CreateSharingPayload = components['schemas']['CreateSharingDto'];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt this go inside the dto file inside infra? This way we have these type of dto centralized

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1 +1 @@
export const LATEST_NAUTILUS_EXTENSION_VERSION = 1;
export const LATEST_NAUTILUS_EXTENSION_VERSION = 2;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the version change necessary?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the application is packaged, the app checks this version against the one stored in the settings to reinstall the extension; otherwise, it would continue to use the last installed version rather than the updated Python script.

In development, the extension is forced to reinstall itself on every startup, but this does not happen in production.

Comment on lines +17 to +19
if (error) return { error };

return { data };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just return the result of the fetch

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it’s helpful retrun the Result structure so we can log errors when they occur and pinpoint exactly where the failure happened.

Comment on lines +17 to +19
if (error) return { error };

return { data };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it’s helpful retrun the Result structure so we can log errors when they occur and pinpoint exactly where the failure happened.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants