From 0cced197baef052aa2dae7ef5acc3bc5ac27a7d0 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Thu, 7 Apr 2022 17:26:12 +0200 Subject: [PATCH] Improve commit history and detail view Signed-off-by: Alexis Sellier --- cypress/fixtures/groupedCommits.json | 54 +++++++------- cypress/fixtures/projectCommits.json | 2 +- cypress/integration/project.spec.ts | 33 ++++----- package-lock.json | 64 +++++++++++++++-- package.json | 5 +- src/base/projects/Commit.svelte | 41 +++++------ .../projects/Commit/CommitAuthorship.svelte | 61 ++++++++++++++++ src/base/projects/Commit/CommitTeaser.svelte | 71 +++++++++++-------- src/base/projects/History.svelte | 30 +++++--- src/commit.ts | 6 +- src/utils.ts | 10 +++ 11 files changed, 265 insertions(+), 112 deletions(-) create mode 100644 src/base/projects/Commit/CommitAuthorship.svelte diff --git a/cypress/fixtures/groupedCommits.json b/cypress/fixtures/groupedCommits.json index f661f4fc6..5720ec046 100644 --- a/cypress/fixtures/groupedCommits.json +++ b/cypress/fixtures/groupedCommits.json @@ -3,14 +3,16 @@ "groupDate": "Thursday, March 3, 2022", "commits": [ { - "sha": "9cd3532", - "summary": "Second commit", - "description": "", - "committer": { - "name": "dabit3", - "mail": "dabit3@gmail.com" - }, - "committerTime": "Thu, 03 Mar 2022 05:51:25 GMT" + "header": { + "sha": "9cd3532", + "summary": "Second commit", + "description": "", + "committer": { + "name": "dabit3", + "mail": "dabit3@gmail.com" + }, + "committerTime": "06:51 GMT+1" + } } ] }, @@ -18,24 +20,28 @@ "groupDate": "Wednesday, March 2, 2022", "commits": [ { - "sha": "e045b92", - "summary": "Update README", - "description": "", - "committer": { - "name": "dabit3", - "mail": "dabit3@gmail.com" - }, - "committerTime": "Wed, 02 Mar 2022 16:14:45 GMT" + "header": { + "sha": "e045b92", + "summary": "Update README", + "description": "", + "committer": { + "name": "dabit3", + "mail": "dabit3@gmail.com" + }, + "committerTime": "17:14 GMT+1" + } }, { - "sha": "cbf5df4", - "summary": "initial commit", - "description": "this is the first commit of many", - "committer": { - "name": "dabit3", - "mail": "dabit3@gmail.com" - }, - "committerTime": "Wed, 02 Mar 2022 15:58:05 GMT" + "header": { + "sha": "cbf5df4", + "summary": "initial commit", + "description": "this is the first commit of many", + "committer": { + "name": "dabit3", + "mail": "dabit3@gmail.com" + }, + "committerTime": "16:58 GMT+1" + } } ] } diff --git a/cypress/fixtures/projectCommits.json b/cypress/fixtures/projectCommits.json index 30c304c5c..663d4cb04 100644 --- a/cypress/fixtures/projectCommits.json +++ b/cypress/fixtures/projectCommits.json @@ -20,7 +20,7 @@ "peer": { "id": "hyyg555wwkkutaysg6yr67qnu5d5ji54iur3n5uzzszndh8dp7ofue", "person": { - "name": "sebastinez" + "name": "dabit3" }, "delegate": true } diff --git a/cypress/integration/project.spec.ts b/cypress/integration/project.spec.ts index 784dc2187..958e58d95 100644 --- a/cypress/integration/project.spec.ts +++ b/cypress/integration/project.spec.ts @@ -43,7 +43,7 @@ describe("Project view", () => { cy.get("div.clone").click(); }); - it("Peer selector ", () => { + it("Peer selector", () => { cy.get("div.selector").click(); cy.get("div.dropdown-item").contains("dabit3 hyndc7nx9keq76p1bkw9831arcndeeu3trwsc7kxt3osmpi6j9oeke delegate").click(); cy.location().should((location) => { @@ -54,7 +54,7 @@ describe("Project view", () => { cy.get("div.stat.peer span.badge").should("have.text", "delegate"); }); - it("Branch selector ", () => { + it("Branch selector", () => { cy.get("div.commit div.stat.branch").click(); cy.get("div.dropdown-item") .first() @@ -69,7 +69,7 @@ describe("Project view", () => { cy.get("div.hash.desktop").should("have.text", "cbf5df4"); }); - it("Commit button ", () => { + it("Commits button", () => { cy.get("div.stat.commit-count") .should("not.have.class", "active") .click(); @@ -79,42 +79,37 @@ describe("Project view", () => { cy.get("div.stat.commit-count").should("have.class", "active"); }); - it("Commit group & commit trailer ", () => { + it("Commit group & commit trailer", () => { cy.fixture("groupedCommits.json").then((commitGroup) => { // This iterates over the commit groups and then over each commit. - cy.get("div.commit-group").should("have.length", 2) + cy.get(".commit-group").should("have.length", 2) .each((item, index) => { expect(Cypress.$(item.children(".commit-date")).text()).to.eq(commitGroup[index].groupDate); - const $el = Cypress.$(item.find(".commit")); + const $el = Cypress.$(item.find(".commit-teaser")); cy.wrap($el).each((commit, commitIndex) => { - expect(Cypress.$(commit).find(".hash").text()).to.eq(commitGroup[index].commits[commitIndex].sha); - expect(Cypress.$(commit).find("span.summary").text()).to.eq(commitGroup[index].commits[commitIndex].summary); - expect(Cypress.$(commit).find(".author").text()).to.eq(commitGroup[index].commits[commitIndex].committer.name); - expect(Cypress.$(commit).find(".time").text()).to.eq(commitGroup[index].commits[commitIndex].committerTime); + expect(Cypress.$(commit).find(".hash").text()).to.eq(commitGroup[index].commits[commitIndex].header.sha); + expect(Cypress.$(commit).find(".summary").text()).to.eq(commitGroup[index].commits[commitIndex].header.summary); + expect(Cypress.$(commit).find(".committer").text()).to.eq(commitGroup[index].commits[commitIndex].header.committer.name); }); }); // Checking that the initial commit has the Verified badge cy.get(".badge").last().should("have.text", "Verified"); - cy.get("div.summary").last().click(); + cy.get(".commit").last().click(); }); }); - it("Commit detail view ", () => { + it("Commit detail view", () => { cy.fixture("groupedCommits.json").then((commitGroup) => { // We get the initial commit from the fixture file to assert here - const { committer, committerTime, summary, description } = commitGroup[1].commits[1]; + const { committer, committerTime, summary, description } = commitGroup[1].commits[1].header; cy.location().should((location) => { expect(location.pathname).to.eq('/seeds/willow.radicle.garden/rad:git:hnrk8mbpirp7ua7sy66o4t9soasbq4y8uwgoy/remotes/hyndc7nx9keq76p1bkw9831arcndeeu3trwsc7kxt3osmpi6j9oeke/commits/cbf5df499ab4f4a908f1756fbe2c236a4530516a'); }); - cy.get("header div.summary h3").should("have.text", summary); + cy.get("header .summary h3").should("have.text", summary); cy.get("header pre.description").should("have.text", description); - cy.get("header div.meta") - .first() - .should("have.text", `Committed by ${committer.name} <${committer.mail}> ${committerTime}`) - .next() - .should("have.text", `Authored by ${committer.name} <${committer.mail}>`); + cy.get("header .committer").should("have.text", `${committer.name}`); cy.get("div.changeset-summary").should("have.text", "1 file(s) changed\n with\n 0 addition(s)\n and\n 0 deletion(s)"); cy.get("header.file-header:nth-child(1) div.file-data > *") .first() diff --git a/package-lock.json b/package-lock.json index d7f29ab33..62cd36835 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@self.id/core": "^0.1.0", "@stardazed/streams": "^3.1.0", "@types/marked": "^4.0.1", + "@types/md5": "^2.3.2", "@walletconnect/client": "^1.6.0", "@walletconnect/signer-connection": "^1.6.0", "@walletconnect/types": "^1.6.0", @@ -27,6 +28,7 @@ "ethers": "^5.0.31", "eventemitter3": "4.0.7", "marked": "^4.0.12", + "md5": "^2.3.0", "multibase": "^4.0.4", "multihashes": "^4.0.2", "pure-svg-code": "^1.0.6", @@ -3515,6 +3517,11 @@ "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.2.tgz", "integrity": "sha512-auNrZ/c0w6wsM9DccwVxWHssrMDezHUAXNesdp2RQrCVCyrQbOiSq7yqdJKrUQQpw9VTm7CGYJH2A/YG7jjrjQ==" }, + "node_modules/@types/md5": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.2.tgz", + "integrity": "sha512-v+JFDu96+UYJ3/UWzB0mEglIS//MZXgRaJ4ubUPwOM0gvLc/kcQ3TWNYwENEK7/EcXGQVrW8h/XqednSjBd/Og==" + }, "node_modules/@types/node": { "version": "14.18.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.10.tgz", @@ -4999,6 +5006,14 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", + "engines": { + "node": "*" + } + }, "node_modules/check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -5444,6 +5459,14 @@ "node": ">= 8" } }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", + "engines": { + "node": "*" + } + }, "node_modules/crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", @@ -7997,8 +8020,7 @@ "node_modules/is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" }, "node_modules/is-callable": { "version": "1.2.4", @@ -8953,6 +8975,16 @@ "node": ">= 12" } }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "node_modules/md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", @@ -14795,6 +14827,11 @@ "resolved": "https://registry.npmjs.org/@types/marked/-/marked-4.0.2.tgz", "integrity": "sha512-auNrZ/c0w6wsM9DccwVxWHssrMDezHUAXNesdp2RQrCVCyrQbOiSq7yqdJKrUQQpw9VTm7CGYJH2A/YG7jjrjQ==" }, + "@types/md5": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.2.tgz", + "integrity": "sha512-v+JFDu96+UYJ3/UWzB0mEglIS//MZXgRaJ4ubUPwOM0gvLc/kcQ3TWNYwENEK7/EcXGQVrW8h/XqednSjBd/Og==" + }, "@types/node": { "version": "14.18.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.10.tgz", @@ -15992,6 +16029,11 @@ "supports-color": "^7.1.0" } }, + "charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=" + }, "check-error": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", @@ -16358,6 +16400,11 @@ "which": "^2.0.1" } }, + "crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=" + }, "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", @@ -18209,8 +18256,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" }, "is-callable": { "version": "1.2.4", @@ -18918,6 +18964,16 @@ "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz", "integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ==" }, + "md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "requires": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "md5.js": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", diff --git a/package.json b/package.json index fbe2b564c..75e543fe6 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "coverage": "npx nyc report", "test:unit": "vitest run", "test:components": "cypress run-ct", - "test:e2e": "cypress run" + "test:e2e": "cypress run", + "test:e2e:open": "cypress open" }, "type": "module", "engines": { @@ -46,6 +47,7 @@ "@self.id/core": "^0.1.0", "@stardazed/streams": "^3.1.0", "@types/marked": "^4.0.1", + "@types/md5": "^2.3.2", "@walletconnect/client": "^1.6.0", "@walletconnect/signer-connection": "^1.6.0", "@walletconnect/types": "^1.6.0", @@ -57,6 +59,7 @@ "ethers": "^5.0.31", "eventemitter3": "4.0.7", "marked": "^4.0.12", + "md5": "^2.3.0", "multibase": "^4.0.4", "multihashes": "^4.0.2", "pure-svg-code": "^1.0.6", diff --git a/src/base/projects/Commit.svelte b/src/base/projects/Commit.svelte index bcc6dd253..f7980852d 100644 --- a/src/base/projects/Commit.svelte +++ b/src/base/projects/Commit.svelte @@ -1,9 +1,10 @@ + + + + + avatar + {#if commit.header.author.email === commit.header.committer.email} + {#if commit.context?.committer} + + {commit.context?.committer.peer.person.name} + +  committed + {:else} + {commit.header.committer.name} +  committed + {/if} + {:else} + {commit.header.author.name} +  authored  + avatar + {#if commit.context?.committer} + + {commit.context?.committer.peer.person.name} + +  committed + {:else} + + {commit.header.committer.name} + +  committed + {/if} + {/if} +  at  + {formatCommitTime(commit.header.committerTime)} + diff --git a/src/base/projects/Commit/CommitTeaser.svelte b/src/base/projects/Commit/CommitTeaser.svelte index 0803d8f7e..4390950b9 100644 --- a/src/base/projects/Commit/CommitTeaser.svelte +++ b/src/base/projects/Commit/CommitTeaser.svelte @@ -1,18 +1,12 @@