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

Removed Edit Ability for Non-owned sketches #2904

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

vivekbopaliya
Copy link
Contributor

Fixes #870

Changes:

bandicam.2024-01-15.18-38-01-506.mp4

Mobile view:

Screenshot (232)

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:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

Copy link
Collaborator

@lindapaiste lindapaiste left a 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
Copy link
Collaborator

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.

Comment on lines +511 to +515
// 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
: ''
Copy link
Collaborator

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.

Comment on lines +604 to +607
// eslint-disable-next-line react/forbid-prop-types
user: PropTypes.object.isRequired,
// eslint-disable-next-line react/forbid-prop-types
project: PropTypes.object.isRequired,
Copy link
Collaborator

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'
Copy link
Collaborator

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.

Comment on lines +259 to +260
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
<p
Copy link
Collaborator

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>.

Comment on lines +120 to +121
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
<p
Copy link
Collaborator

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.

Comment on lines +222 to +223
user={user}
project={project}
Copy link
Collaborator

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} ...

Comment on lines +167 to +175
&.contrast {
background-color: #F5DC23;
color: black;
}

&.normal {
background-color: $p5js-pink;
color: white;
}
Copy link
Collaborator

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).

@vivekbopaliya
Copy link
Contributor Author

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.

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, "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." i think one of the primary reason that we are implementing this feature is to help users distinguish between their and others sketches as it is easy to get confused here. let's see how we are tackling this one!

@raclim
Copy link
Collaborator

raclim commented Jan 16, 2024

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?

i think one of the primary reason that we are implementing this feature is to help users #870 (comment) their and others sketches as it is easy to get confused here. let's see how we are tackling this one!

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.

@vivekbopaliya
Copy link
Contributor Author

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?

i think one of the primary reason that we are implementing this feature is to help users #870 (comment) their and others sketches as it is easy to get confused here. let's see how we are tackling this one!

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'm down to implement something that signals to a user that they're working on a sketch that isn't their's more prominently"
i think this can be tackled with simple "You're working on someone's sketch" the first time the user edits a sketch.
might be to add "Set as Read Only" or "Set as Un-copyable" options for an individual sketch
However, this doesn't completely solve the issue, as there will be even more scenarios for users to get confused about if we don't acknowledge them that they are trying to edit a non-owned, read-only sketch.

I believe these are two different features, so there must be two different approaches for each individually:

  1. End the confusion between owned and non-owned sketches (show a toast on edit or something).
  2. Letting users make their sketch read-only (this time we actually remove the ability to edit and duplicate non-owned sketches).

@vivekbopaliya
Copy link
Contributor Author

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.

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!

@raclim @catarak let me know how you want this to function.

@raclim
Copy link
Collaborator

raclim commented Jan 25, 2024

Sorry about that, I definitely was proposing two different features! 😅

  1. End the confusion between owned and non-owned sketches (show a toast on edit or something).

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!

  1. Letting users make their sketch read-only (this time we actually remove the ability to edit and duplicate non-owned sketches).

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.

the idea similar to this has already been discussed #1094 (comment). 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.

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!

@vivekbopaliya
Copy link
Contributor Author

Sorry about that, I definitely was proposing two different features! 😅

  1. End the confusion between owned and non-owned sketches (show a toast on edit or something).

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!

  1. Letting users make their sketch read-only (this time we actually remove the ability to edit and duplicate non-owned sketches).

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.

the idea similar to this has already been discussed #1094 (comment). 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.

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.

Screenshot (234)

  • In the current behavior, users can freely experiment with unowned sketches without duplication. The alternative way to duplicate a sketch is to simply save it (Ctrl + S), and it will be duplicated.

  • what we can do here is, for unowned sketches, we can display a small label (kinda similar to the above PR one) but without 'to edit,' simply saying Duplicate Sketch or Clone Original Sketch This way, without restricting editing ability, we can caution the user that they are working on someone else's sketch. A label with a background color always attracts eyes' attention.

Screenshot (236)

  • along with that, on the user's first edit, we can show a toast message that goes something like 'You are working on a non-owned sketch; you might want to duplicate it first.' However, personally, this feels a little spoon-feeding lol.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Edit Ability for Non-owned sketches
3 participants