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

feat: add visibility when fork a project (#1272) #1617

Merged
merged 6 commits into from
Dec 23, 2021

Conversation

andre-code
Copy link
Contributor

@andre-code andre-code commented Dec 21, 2021

Added a Visibility option to the modal dialog. The initial value should be the same as the project being forked, and only as visible or less visible options should be available.

For a public project: public, internal, private
For an internal project: internal, private
For a private project: private

Display an informative text in the fork modal dialog when the project was forked but the custom visibility can't be added.

Successful fork

fork-project

Error setting visibility

error-fork-project

Error when setting visibility when closing the modal

error-fork-project-notification

closes #1272
/deploy

@andre-code andre-code requested a review from a team as a code owner December 21, 2021 11:28
@andre-code andre-code temporarily deployed to renku-ci-ui-1617 December 21, 2021 11:29 Inactive
@RenkuBot
Copy link
Contributor

You can access the deployment of this PR at https://renku-ci-ui-1617.dev.renku.ch

@andre-code andre-code temporarily deployed to renku-ci-ui-1617 December 21, 2021 12:23 Inactive
@andre-code andre-code changed the title 1272 add visibility when fork a project 1272 add visibility when fork a project (#1272) Dec 21, 2021
@andre-code andre-code changed the title 1272 add visibility when fork a project (#1272) feat: add visibility when fork a project (#1272) Dec 21, 2021
@andre-code andre-code temporarily deployed to renku-ci-ui-1617 December 21, 2021 12:28 Inactive
@lorenzo-cavazzi lorenzo-cavazzi force-pushed the 1272-add-visibility-forking-project branch from acf2352 to b42270d Compare December 21, 2021 13:11
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1617 December 21, 2021 13:11 Inactive
@lorenzo-cavazzi lorenzo-cavazzi temporarily deployed to renku-ci-ui-1617 December 21, 2021 13:23 Inactive
…ect' into 1272-add-visibility-forking-project

# Conflicts:
#	client/src/project/new/ProjectNew.container.js
#	client/src/project/new/ProjectNew.present.js
@andre-code andre-code temporarily deployed to renku-ci-ui-1617 December 21, 2021 16:51 Inactive
Copy link
Member

@lorenzo-cavazzi lorenzo-cavazzi left a comment

Choose a reason for hiding this comment

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

It works well in all cases I tried! 🎉

Just a tiny change on using an input field a a condition to show the element to set that input.

I also added a note on a function you created. Feel free to ignore it if it's not easy to derive a common function

Comment on lines 162 to 194
async getVisibilities(namespace, projectVisibility = "private") {
const computeVisibilities = (options) => {
if (options.includes("private")) {
return {
visibilities: ["private"],
default: "private",
};
}
else if (options.includes("internal")) {
return {
visibilities: ["private", "internal"],
default: "internal",
};
}
return {
visibilities: ["private", "internal", "public"],
default: "public"
};
};

let availableVisibilities = null;
if (!namespace || !projectVisibility)
return null;

if (namespace?.kind === "user") {
return computeVisibilities(["public", projectVisibility]);
}
else if (namespace?.kind === "group") {
// get group visibility
const group = await this.client.getGroupByPath(namespace.full_path).then(r => r.data);
return computeVisibilities([group.visibility, projectVisibility]);
}
return availableVisibilities;
Copy link
Member

Choose a reason for hiding this comment

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

This is a very nice function!
We have something on the same line in ProjectNew.state.js at line 466 (async getVisibilities(namespace)). I'm wondering if it would make sense to merge the 2, or extrapolate a common function. Maybe it's not that straightforward tho...

Copy link
Member

Choose a reason for hiding this comment

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

P.S. this is just a "nice to have". If you think it's feasible (and reasonably easy) let's include it in the PR. Otherwise, feel free to leave this out.

Copy link
Contributor

Choose a reason for hiding this comment

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

At the very least, I think it would be nice to merge the computeVisibilities functions. It may be necessary to introduce a maxVisibility(projectVisibility, groupVisibility) function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I refactor the function to be used also by the NewProjectCoordinator class.

client/src/project/new/ProjectNew.present.js Show resolved Hide resolved
@ciyer
Copy link
Contributor

ciyer commented Dec 22, 2021

This is great and works well! I tried several cases, and all were handled properly. On minor request. Not critical, but nice to have if easy. Could the message shown when updating the visibility be changed to Determining options instead of Verifying?

image

@andre-code andre-code temporarily deployed to renku-ci-ui-1617 December 22, 2021 14:56 Inactive
@andre-code andre-code force-pushed the 1272-add-visibility-forking-project branch from dec10ff to 9e5bacc Compare December 22, 2021 15:46
@andre-code andre-code temporarily deployed to renku-ci-ui-1617 December 22, 2021 15:46 Inactive
@andre-code andre-code deployed to renku-ci-ui-1617 December 22, 2021 16:00 Active
Copy link
Member

@lorenzo-cavazzi lorenzo-cavazzi left a comment

Choose a reason for hiding this comment

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

Very nice addition to the fork feature! 🚀

Copy link
Contributor

@ciyer ciyer left a comment

Choose a reason for hiding this comment

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

Very nice!

@andre-code andre-code merged commit 942d47a into master Dec 23, 2021
@andre-code andre-code deleted the 1272-add-visibility-forking-project branch December 23, 2021 14:17
@RenkuBot
Copy link
Contributor

Tearing down the temporary RenkuLab deplyoment for this PR.

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.

Add a visibility option to the project fork dialog
4 participants