Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Commit

Permalink
feat(ui): align project creation UX to new designs (#264)
Browse files Browse the repository at this point in the history
* Publish new projects by default
* Adjust validation message alignment
* Remove imgUrl from projects
  • Loading branch information
rudolfs committed Apr 2, 2020
1 parent 3ada468 commit c98a082
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 152 deletions.
12 changes: 2 additions & 10 deletions cypress/integration/project_creation.spec.js
Expand Up @@ -82,14 +82,6 @@ context("project creation", () => {
});
});

context("avatar url", () => {
it("prevents user from submitting an invalid avatar URL", () => {
// shows a validation message when avatar URL is not a valid URL
cy.get('[data-cy="page"] [data-cy="avatar-url"]').type("htttp");
cy.get('[data-cy="page"]').contains("Not a valid avatar URL");
});
});

context("new repository", () => {
it("prevents the user from picking an invalid directory", () => {
// shows a validation message when new project path is empty
Expand All @@ -107,7 +99,7 @@ context("project creation", () => {

// shows a validation message when existing project path is empty
cy.get('[data-cy="page"] [data-cy="existing-project"]')
.contains("Pick an existing repository for the new project")
.contains("Pick a directory with an existing repository")
.should("exist");

// TODO(rudolfs): test empty directory validation
Expand All @@ -125,7 +117,7 @@ context("project creation", () => {
cy.get('[data-cy="page"] [data-cy="existing-project"]').click();
// shows a validation message when existing project path is empty
cy.get('[data-cy="page"] [data-cy="existing-project"]')
.contains("Pick an existing repository for the new project")
.contains("Pick a directory with an existing repository")
.should("exist");
});
});
Expand Down
8 changes: 2 additions & 6 deletions cypress/support/commands.js
Expand Up @@ -42,29 +42,25 @@ Cypress.Commands.add(
(
name = "Monadic",
description = "Monadic is currently supporting radicle.",
defaultBranch = "master",
imgUrl = "https://res.cloudinary.com/juliendonck/image/upload/v1549554598/monadic-icon_myhdjk.svg"
defaultBranch = "master"
) => {
client.mutate({
variables: {
name: name,
description: description,
defaultBranch: defaultBranch,
imgUrl: imgUrl
defaultBranch: defaultBranch
},
mutation: gql`
mutation CreateProjectWithFixture(
$name: String!
$description: String!
$defaultBranch: String!
$imgUrl: String!
) {
createProjectWithFixture(
metadata: {
name: $name
description: $description
defaultBranch: $defaultBranch
imgUrl: $imgUrl
}
) {
id
Expand Down
51 changes: 19 additions & 32 deletions proxy/src/coco.rs
Expand Up @@ -8,7 +8,7 @@ use std::str::FromStr;

use librad::git;
use librad::keys;
use librad::meta::{self, common::Url};
use librad::meta;
use librad::paths::Paths;
use librad::peer;
use librad::project;
Expand Down Expand Up @@ -420,18 +420,15 @@ pub fn init_project(
name: &str,
description: &str,
default_branch: &str,
img_url: &str,
) -> Result<(git::ProjectId, meta::Project), error::Error> {
let key = keys::device::Key::new();
let peer_id = peer::PeerId::from(key.public());
let founder = meta::contributor::Contributor::new();
let sources = git2::Repository::open(std::path::Path::new(path))?;
let img = Url::parse(img_url)?;
let mut meta = meta::Project::new(name, &peer_id);

meta.description = Some(description.to_string());
meta.default_branch = default_branch.to_string();
meta.add_rel(meta::Relation::Url("img_url".to_string(), img));

let id = git::GitProject::init(librad_paths, &key, &sources, meta.clone(), founder)?;

Expand Down Expand Up @@ -477,7 +474,6 @@ pub fn replicate_platinum(
name: &str,
description: &str,
default_branch: &str,
img_url: &str,
) -> Result<(git::ProjectId, meta::Project), error::Error> {
// Craft the absolute path to git-platinum fixtures.
let mut platinum_path = env::current_dir()?;
Expand Down Expand Up @@ -540,7 +536,6 @@ pub fn replicate_platinum(
name,
description,
default_branch,
img_url,
)?;
let mut rad_remote = platinum_repo.find_remote("rad")?;

Expand All @@ -560,38 +555,30 @@ pub fn replicate_platinum(
/// [`librad::paths::Paths`].
pub fn setup_fixtures(librad_paths: &Paths, root: &str) -> Result<(), error::Error> {
let infos = vec![
(
"monokel",
"A looking glass into the future",
"master",
"https://res.cloudinary.com/juliendonck/image/upload/v1557488019/Frame_2_bhz6eq.svg",
),
(
"Monadic",
"Open source organization of amazing things.",
"master",
"https://res.cloudinary.com/juliendonck/image/upload/v1549554598/monadic-icon_myhdjk.svg",
),
(
"open source coin",
"Research for the sustainability of the open source community.",
"master",
"https://avatars0.githubusercontent.com/u/31632242",
),
(
"radicle",
"Decentralized open source collaboration",
"master",
"https://avatars0.githubusercontent.com/u/48290027",
),
];
("monokel", "A looking glass into the future", "master"),
(
"Monadic",
"Open source organization of amazing things.",
"master",
),
(
"open source coin",
"Research for the sustainability of the open source community.",
"master",
),
(
"radicle",
"Decentralized open source collaboration",
"master",
),
];

for info in infos {
let path = format!("{}/{}/{}", root, "repos", info.0);
std::fs::create_dir_all(path.clone())?;

init_repo(path.clone())?;
init_project(librad_paths, &path, info.0, info.1, info.2, info.3)?;
init_project(librad_paths, &path, info.0, info.1, info.2)?;
}

Ok(())
Expand Down
8 changes: 0 additions & 8 deletions proxy/src/graphql/schema.rs
Expand Up @@ -90,7 +90,6 @@ impl Mutation {
&metadata.name,
&metadata.description,
&metadata.default_branch,
&metadata.img_url,
)?;

Ok(project::Project {
Expand Down Expand Up @@ -373,7 +372,6 @@ impl ControlMutation {
&metadata.name,
&metadata.description,
&metadata.default_branch,
&metadata.img_url,
)?;

Ok(project::Project {
Expand Down Expand Up @@ -622,8 +620,6 @@ pub struct ProjectMetadataInput {
pub description: String,
/// Default branch for checkouts, often used as mainline as well.
pub default_branch: String,
/// Image url for the project.
pub img_url: String,
}

#[juniper::object]
Expand Down Expand Up @@ -673,10 +669,6 @@ impl project::Metadata {
&self.description
}

fn img_url(&self) -> &str {
&self.img_url
}

fn name(&self) -> &str {
&self.name
}
Expand Down
25 changes: 0 additions & 25 deletions proxy/src/project.rs
Expand Up @@ -5,9 +5,6 @@ use librad::meta;
use librad::project;
use radicle_registry_client as registry;

/// Metadata key used to store an image url for a project.
const IMG_URL_LABEL: &str = "img_url";

/// Object the API returns for project metadata.
pub struct Metadata {
/// Project name.
Expand All @@ -16,36 +13,14 @@ pub struct Metadata {
pub description: String,
/// Default branch for checkouts, often used as mainline as well.
pub default_branch: String,
/// Image url for the project.
pub img_url: String,
}

impl From<meta::Project> for Metadata {
fn from(project_meta: meta::Project) -> Self {
let img_url = project_meta
.rel
.into_iter()
.filter_map(|r| {
if let meta::Relation::Url(label, url) = r {
Some((label, url))
} else {
None
}
})
.find_map(|(label, url)| {
if *label == *IMG_URL_LABEL {
Some(url.to_string())
} else {
None
}
})
.unwrap_or_else(|| "".to_string());

Self {
name: project_meta.name.unwrap_or_else(|| "name unknown".into()),
description: project_meta.description.unwrap_or_else(|| "".into()),
default_branch: project_meta.default_branch,
img_url,
}
}
}
Expand Down
1 change: 0 additions & 1 deletion proxy/tests/common/mod.rs
Expand Up @@ -20,7 +20,6 @@ where
"git-platinum",
"fixture data",
"master",
"https://avatars0.githubusercontent.com/u/48290027",
)
.unwrap();

Expand Down
6 changes: 0 additions & 6 deletions proxy/tests/graphql_mutation.rs
Expand Up @@ -71,7 +71,6 @@ fn create_project_existing_repo() {
InputValue::scalar("Code collaboration without intermediates."),
);
metadata_input.insert("defaultBranch".into(), InputValue::scalar("master"));
metadata_input.insert("imgUrl".into(), InputValue::scalar("https://raw.githubusercontent.com/radicle-dev/radicle-upstream/master/app/public/icon.png"));

let mut vars = Variables::new();
vars.insert("metadata".into(), InputValue::object(metadata_input));
Expand All @@ -85,7 +84,6 @@ fn create_project_existing_repo() {
name
description
defaultBranch
imgUrl
}
}
}";
Expand All @@ -100,7 +98,6 @@ fn create_project_existing_repo() {
"name": "upstream",
"description": "Code collaboration without intermediates.",
"defaultBranch": "master",
"imgUrl": "https://raw.githubusercontent.com/radicle-dev/radicle-upstream/master/app/public/icon.png",
},
},
})
Expand All @@ -126,7 +123,6 @@ fn create_project() {
InputValue::scalar("Code collaboration without intermediates."),
);
metadata_input.insert("defaultBranch".into(), InputValue::scalar("master"));
metadata_input.insert("imgUrl".into(), InputValue::scalar("https://raw.githubusercontent.com/radicle-dev/radicle-upstream/master/app/public/icon.png"));

let mut vars = Variables::new();
vars.insert("metadata".into(), InputValue::object(metadata_input));
Expand All @@ -140,7 +136,6 @@ fn create_project() {
name
description
defaultBranch
imgUrl
}
registered {
... on OrgRegistration {
Expand Down Expand Up @@ -168,7 +163,6 @@ fn create_project() {
"name": "upstream",
"description": "Code collaboration without intermediates.",
"defaultBranch": "master",
"imgUrl": "https://raw.githubusercontent.com/radicle-dev/radicle-upstream/master/app/public/icon.png",
},
"registered": None,
"stats": {
Expand Down
25 changes: 8 additions & 17 deletions proxy/tests/graphql_query.rs
Expand Up @@ -612,16 +612,14 @@ fn project() {
let path = repo_dir.path().to_str().expect("repo path").to_string();
coco::init_repo(path.clone()).expect("repo init failed");

let (project_id, _project_meta) =
coco::init_project(
&librad_paths,
&path,
"upstream",
"Code collaboration without intermediates.",
"master",
"https://raw.githubusercontent.com/radicle-dev/radicle-upstream/master/app/public/icon.png",
)
.expect("project init failed");
let (project_id, _project_meta) = coco::init_project(
&librad_paths,
&path,
"upstream",
"Code collaboration without intermediates.",
"master",
)
.expect("project init failed");

let id = project_id.to_string();
let mut vars = Variables::new();
Expand All @@ -634,7 +632,6 @@ fn project() {
name
description
defaultBranch
imgUrl
}
registered {
... on OrgRegistration {
Expand All @@ -658,7 +655,6 @@ fn project() {
"name": "upstream",
"description": "Code collaboration without intermediates.",
"defaultBranch": "master",
"imgUrl": "https://raw.githubusercontent.com/radicle-dev/radicle-upstream/master/app/public/icon.png",
},
"registered": None,
},
Expand Down Expand Up @@ -751,7 +747,6 @@ fn user() {
// name
// description
// defaultBranch
// imgUrl
// }
// }
// }";
Expand All @@ -767,31 +762,27 @@ fn user() {
// "name": "Monadic",
// "description": "Open source organization of amazing
// things.", "defaultBranch": "stable",
// "imgUrl": "https://res.cloudinary.com/juliendonck/image/upload/v1549554598/monadic-icon_myhdjk.svg",
// },
// },
// {
// "metadata": {
// "name": "monokel",
// "description": "A looking glass into the future",
// "defaultBranch": "master",
// "imgUrl": "https://res.cloudinary.com/juliendonck/image/upload/v1557488019/Frame_2_bhz6eq.svg",
// },
// },
// {
// "metadata": {
// "name": "open source coin",
// "description": "Research for the sustainability of the
// open source community.", "defaultBranch":
// "master", "imgUrl": "https://avatars0.githubusercontent.com/u/31632242",
// },
// },
// {
// "metadata": {
// "name": "radicle",
// "description": "Decentralized open source collaboration",
// "defaultBranch": "dev",
// "imgUrl": "https://avatars0.githubusercontent.com/u/48290027",
// },
// },
// ],
Expand Down
1 change: 0 additions & 1 deletion ui/DesignSystem/Component/ProjectList.svelte
Expand Up @@ -16,7 +16,6 @@
id
metadata {
defaultBranch
imgUrl
description
name
}
Expand Down

0 comments on commit c98a082

Please sign in to comment.