Skip to content

Conversation

@netux
Copy link
Contributor

@netux netux commented Mar 13, 2025

When viewing other people's projects, show a "Fork" button in place of the "Edit" button that would be present for owned projects.

fork button next to an open project dropdown

Also, ensure we have the name of the current project, even if not owned, by detecting when $currentProjectUUID is not present in $projects, then fetching and storing it.

netux added 5 commits March 13, 2025 08:34
Reuses `duplicateProject()`, with some adaptations to ensure the forked project is loaded so we can get its name
Add the current project to the $projects store. This will make the project's title appear in the projects dropdown
Copy link
Owner

@Mitcheljager Mitcheljager left a comment

Choose a reason for hiding this comment

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

I really like the idea, but I don't really agree with the implementation or the UX. I think it makes more sense to keep the projects dropdown strictly to the user's own projects. Perhaps the button could be kept to the same notice telling you the project is not yours? Something like this maybe:
image

Comment on lines +64 to +68
$: if ($currentProjectUUID && !$projects.some(({ uuid }) => uuid === $currentProjectUUID)) {
fetchProject($currentProjectUUID).then((currentProject) => {
$projects.push(currentProject)
})
}
Copy link
Owner

Choose a reason for hiding this comment

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

I'd prefer $projects to not ever contain a project that is not owned by the user

Copy link
Contributor Author

@netux netux Mar 15, 2025

Choose a reason for hiding this comment

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

Would you be okay with at least renaming it $user/ownProjects? Its naming is a bit vague otherwise.

I also noticed a lot of checks for $currentProject?.is_owner, making it seem like we could have a project in $projects that could be owned by some other user ($currentProject derives from $projects).

Comment on lines +16 to +19
let ownProjects = []
let filteredProjects = []

$: ownProjects = $projects.filter(({ is_owner }) => is_owner)
Copy link
Owner

Choose a reason for hiding this comment

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

I don't really want the state of projects that are not part of your project to be handled in the projects dropdown, I think it would make more sense somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.
Considering my comment above, what do you think about renaming $projects to $user/ownProjects, and having a $projects that contains a cache of all known projects (essentially what I do here with the current $projects)?

Then $user/ownProjects can derive from $projects, filtering out any projects that have is_owner set to false.

Comment on lines 145 to 147
<button class="w-auto text-base ml-1/8" on:click={() => duplicateProject(true)}>
Fork
</button>
Copy link
Owner

Choose a reason for hiding this comment

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

The editor is meant as a bridge for users who aren't very familiar with programming just yet. The term "fork" is not exactly common outside of the programming world, so I'd prefer something else. Especially because this isn't a fork, it's just a copy. You aren't really forking off of some main branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was also thinking about that.

I decided to go with Fork anyway because we already use that terminology in workshop.codes itself for marking codes as forks of other projects. The term "fork" there also really means a project "being based off of" another project, so it doesn't quite line up with the way we use "fork" in the showbiz either.

I can rename this "Clone" or "Clone for myself" or something else that makes it clearer what this is about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe in the future we could consider having a sort of real forking system though? Where a project is marked as being based-off another project, and there is a button to merge changes coming from upstream (the original project) into the other project?

Ehh, maybe its not that useful. At that point just why not go and replicate Git completely, right?

return string.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g, letter => letter.toUpperCase())
}

export function trimmed(string: string, limit: number, ellipsis = "..."): string {
Copy link
Owner

Choose a reason for hiding this comment

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

This is more commonly called truncate, but I think it might make more sense to do this via CSS so it's not screen width dependent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like truncate better also 👍

Suggested change
export function trimmed(string: string, limit: number, ellipsis = "..."): string {
export function truncate(string: string, limit: number, ellipsis = "..."): string {

Also 👍 to implementing this through CSS. I mostly just wanted to get rid of the inline logic in <ProjectsDropdown>, which came out of nowhere and was a bit of an eyesore to me 😅.
Moving that logic into a helper was the quickest solution.

Comment on lines 78 to 80
{#if $currentProject && !$currentProject.is_owner}
<small>(read-only)</small>
{/if}
Copy link
Owner

Choose a reason for hiding this comment

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

It's not really read-only, you can still edit the project, just not save.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah... I struggled to come up with a term that'd fit into the dropdown.

Maybe it'd be better if the title of a project not owned by the user is shown outside the projects dropdown, and the projects dropdown is left exclusively for navigating to your own projects.

@netux
Copy link
Contributor Author

netux commented Mar 15, 2025

Perhaps the button could be kept to the same notice telling you the project is not yours? Something like this maybe:
image

👍 While we are at it, can we decrease the contrast on this little banner/pill thingy? Bright orange and white don't really go along well.

@Mitcheljager
Copy link
Owner

@netux Sure!

netux added 8 commits March 14, 2025 22:13
Makes an ellipsis appear on horizontal text overflow.

Note that this should usually be combined with a static width for the overflow to trigger.
…jects endpoint

Fixes projects not appearing in the projects dropdown.
…ct" warning

Simply removing `warning--orange` does the trick, since the default background color is also a darker shade of orange.
…cts not owned by the current user

This is deceiving, because the projects _are_ editable, just not saveable.
Besides, we already have the "You do not own this project" warning in <editor-actions>
@netux netux marked this pull request as draft March 15, 2025 01:42
@netux
Copy link
Contributor Author

netux commented Mar 15, 2025

@Mitcheljager what do you think of like this "Clone and Save" button in place of the "Fork" button?

editor on someone else's user, showcasing a new "Clone and Save" button where the "Save" button would be

I like this more even because it triggers on the Ctrl + S keybind as well (I'm reusing the <Save> component), which matches what I've seen other online text editors do when you try to save on a file that's not yours.

@Mitcheljager
Copy link
Owner

@netux I think that works!

netux added 3 commits March 15, 2025 00:29
…ror" when a project fails to be created

This is more in line with other helper methods in this file.
…ethod

A little house-keeping.
I noticed this was the only /projects API call which wasn't in utils/project.ts, since it really is only used once.
… projects that aren't owned by the user

This replaces the previous "Fork" button.

The new button is situated in place of the "Save" button that appears in projects owned by the user, and even shares the same component.

This matches the behavior seen in other online IDEs/text editors, when attempting to save a file that isn't your own.
@netux
Copy link
Contributor Author

netux commented Mar 15, 2025

@Mitcheljager any opinions on the $ownProjects store deriving from $projects?

@Mitcheljager
Copy link
Owner

@netux I don't think it's a good idea to ever put any projects in there that are not your own. Ideally no store is needed for a project that is someone else's.

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