-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Removed Edit Ability for Non-owned sketches #2904
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this feature because we have it tagged as a high priority and something that we definitely want to do but I personally don't really like it 🤷♀️. I think it's nice to be able to edit a line or two in someone's code and see the changes without having to clone the whole thing. @raclim what are your thoughts?
There's a lot of cleanup before this could be considered for merging. But before you work on any of that, let's hear from @raclim about how we want this to function.
@@ -505,7 +505,14 @@ class Editor extends React.Component { | |||
const editorHolderClass = classNames({ | |||
'editor-holder': true, | |||
'editor-holder--hidden': | |||
this.props.file.fileType === 'folder' || this.props.file.url | |||
this.props.file.fileType === 'folder' || this.props.file.url, | |||
// eslint-disable-next-line no-dupe-keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any dupe keys? You can probably delete this disable
.
// Check if there is a project owner, the user has a username, | ||
// and the project owner's username is not the same as the user's username | ||
this.props.project.owner && this.props.user.username | ||
? this.props.project.owner?.username !== this.props.user.username | ||
: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to store the isReadOnly
(or canEdit
) condition to a variable because it is used in multiple places. But I don't think this logic is 100% correct because it would allow editing someone else's saved sketch if the user is not logged in.
// eslint-disable-next-line react/forbid-prop-types | ||
user: PropTypes.object.isRequired, | ||
// eslint-disable-next-line react/forbid-prop-types | ||
project: PropTypes.object.isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the better thing to do here would be to determine the isReadOnly
/canEdit
condition in a Redux selector. For right now we would add it to mapStateToProps
and eventually when we re-write this component we can use the same selector function in a useSelector
. That way we are only adding one new prop with a boolean
value instead of passing down these complex objects.
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions | ||
<p | ||
className={`toolbar__duplicatetoedit ${ | ||
theme === 'contrast' ? 'contrast' : 'normal' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need to access the theme
directly here. You should use theme variables in the .scss
instead. I can explain that more later if we decide to work with this PR.
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions | ||
<p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason that you are getting all of these eslint errors is because you are using a <p>
element instead of <button>
. Keyboards, screen readers, etc. will not handle it properly unless it is a <button>
.
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions | ||
<p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a <button>
too.
user={user} | ||
project={project} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments re: Editor.propTypes
. I think that the condition which you are using currently is the equivalent of the isUserOwner
variable here. Could be something like <Editor canEdit={isUserOwner} ...
&.contrast { | ||
background-color: #F5DC23; | ||
color: black; | ||
} | ||
|
||
&.normal { | ||
background-color: $p5js-pink; | ||
color: white; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments re theme
in components. We want this to look like color: getThemifyVariable('secondary-text-color');
(with whatever the correct variable name is).
Sure, i'll be on it right after we hear from @raclim, thank you for all the above quality inputs though. (always appreciate them haha). Moreover, |
Now that I'm looking at this I'm honestly not too sure! I don't think I've personally had issues with the current setup, but can see how it can be hard to distinguish whether the sketch is yours or not. I'm down to implement something that signals to a user that they're working on a sketch that isn't their's more prominently, but I think I also feel hesitant about removing the edit ability altogether. This is straying from the original issue and is just an idea, but I think one way "removing the edit ability" could be implemented as well might be to add "Set as Read Only" or "Set as Un-copyable" options for an individual sketch, so a user can choose if they don't want their sketches to be interacted with. |
I believe these are two different features, so there must be two different approaches for each individually:
|
the idea similar to this has already been discussed here. This can address both issues: hiding the open API keys as well as removing the ability to edit sketches if they are private or set to read-only. A week ago, I wasn't in favor of letting users keep their sketches as read-only because it seemed to lead to even more confusion and lots of work that might not be worth it?! However, now it appears to be more user-friendly than simply taking away the authority to edit every sketch haha. I am down to close this pull request and create a new one! |
Sorry about that, I definitely was proposing two different features! 😅
I think I'm personally leaning towards implementing this one regardless because for me, it feels like the simplest way to address the issue of a user having difficulty distinguishing whether a sketch is theirs or not. Down to rethink some of this though if this doesn't feel like enough!
I did stray from the original issue here—I proposed this as a way to implement this feature (removing the edit ability) in a way that might feel like a choice for the user if still we did want to integrate this into the editor.
I've actually been hoping to implement the privating sketches feature in the near future! @vivekbopaliya These are all my thoughts, but I'm also wondering what makes sense to you here as well! |
yes right! imo there are two ways to approach first proposal, which of one is similar to codepen's apporach.
this was for the first proposal only. once we resolve this, afterwards we can move on to the private sketch feature and discuss how we will want it to function. |
Fixes #870
Changes:
bandicam.2024-01-15.18-38-01-506.mp4
Mobile view:
I was planning to introduce a 'Remix' function as it was talked about here then I realized that there's already a feature similar to 'Clone' (duplicate sketch) regardless you can still edit sketches that aren't yours (you can't add files/folders, though). To make it easier for users that help them distinguish between owned and non-owned sketches, we could make it necessary to duplicate sketches before making changes if they don't own them.
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123