Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨Public and restricted doc editable #357

Merged
merged 2 commits into from
Oct 23, 2024
Merged

Conversation

AntoLC
Copy link
Collaborator

@AntoLC AntoLC commented Oct 18, 2024

Purpose

We increased the visibility options for docs:

  • public
  • restricted
  • authenticated

We also have 2 editability options:

  • readonly
  • editable

The editability options are only available for public and authenticated docs.

Proposal

  • ♻️(frontend) minor components update
  • ✨(frontend) increase doc visibility options
  • tests

Demo

scrnli_VZHQd70DS9qxw9.webm

@AntoLC AntoLC self-assigned this Oct 18, 2024
This was linked to issues Oct 18, 2024
@AntoLC AntoLC force-pushed the feature/doc-public-editable branch 4 times, most recently from 6ed9f15 to 00e7b27 Compare October 22, 2024 10:00
@AntoLC AntoLC changed the title ✨Public doc editable ✨Public and restricted doc editable Oct 22, 2024
@AntoLC AntoLC force-pushed the feature/doc-public-editable branch from 00e7b27 to 1d1832b Compare October 22, 2024 11:29
@AntoLC AntoLC marked this pull request as ready for review October 22, 2024 11:43
@AntoLC AntoLC requested a review from PanchoutNathan October 22, 2024 11:43
Copy link
Collaborator

@PanchoutNathan PanchoutNathan left a comment

Choose a reason for hiding this comment

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

✅ Nice work ! This is a cool feature !

Small observations :

  • there is a slight shift in height when the restrictions are displayed or not.
  • I might have liked to know that we are on the document as an unconnected guest. Maybe not, I thought about it quickly so I'm sharing it

Comment on lines +96 to +107
navigator.clipboard
.writeText(window.location.href)
.then(() => {
toast(t('Link Copied !'), VariantType.SUCCESS, {
duration: 3000,
});
})
.catch(() => {
toast(t('Failed to copy link'), VariantType.ERROR, {
duration: 3000,
});
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be good to turn it into a hook, because I think we could need it in the home page list via the "..." for example. Or even an invitation link for new members instead of inviting one by one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When we will need it somewhere else, yes you are right, but we use it only here for the moment, let's keep it scoped until we need it outside.

Comment on lines +30 to 45
export enum LinkRole {
READER = 'reader',
EDITOR = 'editor',
}

export type Base64 = string;

export interface Doc {
id: string;
title: string;
content: Base64;
link_reach: LinkReach;
link_role: 'reader' | 'editor';
link_role: LinkRole;
accesses: Access[];
created_at: string;
updated_at: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this type is not only related to this feature, but can be used everywhere. I moved this file to the root of the feature/docs folder. But maybe in another PR? and maybe. And maybe you don't agree with that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The feature doc-management actually is for related things about doc that can be used in others features.

Comment on lines 112 to 120
{
label: t('Read only'),
value: LinkRole.READER,
},
{
label: t('Can read and edit'),
value: LinkRole.EDITOR,
},
].map((radio) => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe create a constant above?

Comment on lines 95 to 96
{(doc.link_reach === LinkReach.AUTHENTICATED ||
doc.link_reach === LinkReach.PUBLIC) && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

what do you think of creating a constant with explicit naming? like for example :

const showRestrictedOptions = doc.link_reach === LinkReach.AUTHENTICATED || doc.link_reach === LinkReach.PUBLIC

or

const showRestrictedOptions = [LinkReach.AUTHENTICATED, LinkReach.PUBLIC].includes(doc.link_reach);

@@ -164,14 +164,22 @@ test.describe('Document list members', () => {
const shareModal = page.getByLabel('Share modal');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add tests to know if restrictions should be shown or not based on visibility

@AntoLC AntoLC force-pushed the feature/doc-public-editable branch from 562cc79 to 2721c4e Compare October 22, 2024 14:12
Copy link
Collaborator Author

@AntoLC AntoLC left a comment

Choose a reason for hiding this comment

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

✅ Nice work ! This is a cool feature

Yes this feature is waited since the beginning of the project. ^^

Comment on lines +96 to +107
navigator.clipboard
.writeText(window.location.href)
.then(() => {
toast(t('Link Copied !'), VariantType.SUCCESS, {
duration: 3000,
});
})
.catch(() => {
toast(t('Failed to copy link'), VariantType.ERROR, {
duration: 3000,
});
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When we will need it somewhere else, yes you are right, but we use it only here for the moment, let's keep it scoped until we need it outside.

Comment on lines +30 to 45
export enum LinkRole {
READER = 'reader',
EDITOR = 'editor',
}

export type Base64 = string;

export interface Doc {
id: string;
title: string;
content: Base64;
link_reach: LinkReach;
link_role: 'reader' | 'editor';
link_role: LinkRole;
accesses: Access[];
created_at: string;
updated_at: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The feature doc-management actually is for related things about doc that can be used in others features.

@AntoLC AntoLC requested a review from PanchoutNathan October 22, 2024 14:15
- change flex property of Box component
- Forward the ref of Text component
- globalize tooltip padding
We now have 3 visibility options for docs:
- public
- restricted
- authenticated

We also have 2 editability options:
- readonly
- editable

The editability options are only available
for public and authenticated docs.
@AntoLC AntoLC force-pushed the feature/doc-public-editable branch from 2721c4e to 9c901b5 Compare October 23, 2024 09:11
@AntoLC AntoLC enabled auto-merge (rebase) October 23, 2024 09:11
@AntoLC AntoLC merged commit ff364f8 into main Oct 23, 2024
13 of 16 checks passed
@AntoLC AntoLC deleted the feature/doc-public-editable branch October 23, 2024 09:20
@AntoLC AntoLC mentioned this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add edit roles "anyone with the link" ✨Link doc
2 participants