Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
cob: Redesign merge state
Alexis Sellier committed 3 years ago
commit 90cf62b0274c85f8b10c38ad6d046e1c5aa868ae
parent 8880c49c1d8ec2caa5f98e4f5a9a5bfa40ff18f9
3 files changed +29 -20
modified radicle-httpd/src/api.rs
@@ -153,10 +153,10 @@ pub enum PatchState {
impl PatchState {
    pub fn matches(&self, patch: &patch::State) -> bool {
        match self {
-
            Self::Open => matches!(patch, patch::State::Open),
+
            Self::Open => matches!(patch, patch::State::Open { .. }),
            Self::Draft => matches!(patch, patch::State::Draft),
            Self::Archived => matches!(patch, patch::State::Archived),
-
            Self::Merged => matches!(patch, patch::State::Merged),
+
            Self::Merged => matches!(patch, patch::State::Merged { .. }),
        }
    }
}
modified radicle-httpd/src/api/json.rs
@@ -123,6 +123,14 @@ pub(crate) fn patch(
        "state": patch.state(),
        "target": patch.target(),
        "tags": patch.tags().collect::<Vec<_>>(),
+
        "merges": patch.merges().map(|(a, m)| {
+
            json!({
+
                "author": a,
+
                "revision": m.revision,
+
                "commit": m.commit,
+
                "timestamp": m.timestamp
+
            })
+
        }).collect::<Vec<_>>(),
        "revisions": patch.revisions().map(|(id, rev)| {
            json!({
                "id": id,
@@ -130,7 +138,6 @@ pub(crate) fn patch(
                "base": rev.base(),
                "oid": rev.head(),
                "refs": get_refs(repo, patch.author().id(), &rev.head()).unwrap_or(vec![]),
-
                "merges": rev.merges().collect::<Vec<_>>(),
                "discussions": rev.discussion().comments()
                  .map(|(id, comment)| Comment::new(id, comment, rev.discussion(), aliases))
                  .collect::<Vec<_>>(),
modified radicle-httpd/src/api/v1/projects.rs
@@ -1745,6 +1745,7 @@ mod routes {
                "state": { "status": "open" },
                "target": "delegates",
                "tags": [],
+
                "merges": [],
                "revisions": [
                  {
                    "id": CONTRIBUTOR_PATCH_ID,
@@ -1754,7 +1755,6 @@ mod routes {
                    "refs": [
                      "refs/heads/master",
                    ],
-
                    "merges": [],
                    "discussions": [],
                    "timestamp": TIMESTAMP,
                    "reviews": [],
@@ -1784,6 +1784,7 @@ mod routes {
                "state": { "status": "open" },
                "target": "delegates",
                "tags": [],
+
                "merges": [],
                "revisions": [
                  {
                    "id": CONTRIBUTOR_PATCH_ID,
@@ -1793,7 +1794,6 @@ mod routes {
                    "refs": [
                      "refs/heads/master",
                    ],
-
                    "merges": [],
                    "discussions": [],
                    "timestamp": TIMESTAMP,
                    "reviews": [],
@@ -1862,6 +1862,7 @@ mod routes {
                "state": { "status": "open" },
                "target": "delegates",
                "tags": [],
+
                "merges": [],
                "revisions": [
                  {
                    "id": CREATED_PATCH_ID,
@@ -1871,7 +1872,6 @@ mod routes {
                    "refs": [
                      "refs/heads/master",
                    ],
-
                    "merges": [],
                    "discussions": [],
                    "timestamp": TIMESTAMP,
                    "reviews": [],
@@ -1925,6 +1925,7 @@ mod routes {
                "bug",
                "design"
              ],
+
              "merges": [],
              "revisions": [
                {
                  "id": CONTRIBUTOR_PATCH_ID,
@@ -1934,7 +1935,6 @@ mod routes {
                  "refs": [
                    "refs/heads/master",
                  ],
-
                  "merges": [],
                  "discussions": [],
                  "timestamp": TIMESTAMP,
                  "reviews": [],
@@ -1985,6 +1985,7 @@ mod routes {
              "state": { "status": "open" },
              "target": "delegates",
              "tags": [],
+
              "merges": [],
              "revisions": [
                {
                  "id": CONTRIBUTOR_PATCH_ID,
@@ -1994,7 +1995,6 @@ mod routes {
                  "refs": [
                    "refs/heads/master",
                  ],
-
                  "merges": [],
                  "discussions": [],
                  "timestamp": TIMESTAMP,
                  "reviews": [],
@@ -2007,7 +2007,6 @@ mod routes {
                  "refs": [
                    "refs/heads/master",
                  ],
-
                  "merges": [],
                  "discussions": [],
                  "timestamp": TIMESTAMP,
                  "reviews": [],
@@ -2058,6 +2057,7 @@ mod routes {
              "state": { "status": "open" },
              "target": "delegates",
              "tags": [],
+
              "merges": [],
              "revisions": [
                {
                  "id": CONTRIBUTOR_PATCH_ID,
@@ -2067,7 +2067,6 @@ mod routes {
                  "refs": [
                    "refs/heads/master",
                  ],
-
                  "merges": [],
                  "discussions": [],
                  "timestamp": TIMESTAMP,
                  "reviews": [],
@@ -2140,6 +2139,7 @@ mod routes {
              "state": { "status": "open" },
              "target": "delegates",
              "tags": [],
+
              "merges": [],
              "revisions": [
                {
                  "id": CONTRIBUTOR_PATCH_ID,
@@ -2149,7 +2149,6 @@ mod routes {
                  "refs": [
                    "refs/heads/master",
                  ],
-
                  "merges": [],
                  "discussions": [
                    {
                      "id": CONTRIBUTOR_COMMENT_1,
@@ -2236,6 +2235,7 @@ mod routes {
              "state": { "status": "open" },
              "target": "delegates",
              "tags": [],
+
              "merges": [],
              "revisions": [
                {
                  "id": CONTRIBUTOR_PATCH_ID,
@@ -2245,7 +2245,6 @@ mod routes {
                  "refs": [
                    "refs/heads/master",
                  ],
-
                  "merges": [],
                  "discussions": [],
                  "timestamp": TIMESTAMP,
                  "reviews": [
@@ -2316,9 +2315,19 @@ mod routes {
              },
              "title": "A new `hello world`",
              "description": "change `hello world` in README to something else",
-
              "state": { "status": "merged" },
+
              "state": {
+
                  "status": "merged",
+
                  "revision": CONTRIBUTOR_PATCH_ID,
+
                  "commit": PARENT,
+
              },
              "target": "delegates",
              "tags": [],
+
              "merges": [{
+
                  "author": CONTRIBUTOR_NID,
+
                  "revision": CONTRIBUTOR_PATCH_ID,
+
                  "commit": PARENT,
+
                  "timestamp": TIMESTAMP,
+
              }],
              "revisions": [
                {
                  "id": CONTRIBUTOR_PATCH_ID,
@@ -2328,13 +2337,6 @@ mod routes {
                  "refs": [
                    "refs/heads/master",
                  ],
-
                  "merges": [
-
                    {
-
                      "node": CONTRIBUTOR_NID,
-
                      "commit": PARENT,
-
                      "timestamp": TIMESTAMP,
-
                    },
-
                  ],
                  "discussions": [],
                  "timestamp": TIMESTAMP,
                  "reviews": [],