From 90376925192b02ac4fac5f7e45ac0d066b0dd6d6 Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 10 Apr 2024 21:38:19 +0200 Subject: [PATCH] update to current weave --- .../zomes/coordinator/converge/src/lib.rs | 20 +- .../integrity/converge/src/deliberation.rs | 10 +- .../zomes/integrity/converge/src/proposal.rs | 8 +- package-lock.json | 380 +++++++++++++++- ui/package.json | 4 +- ui/src/App.svelte | 120 +++-- ui/src/AttachmentsDialog.svelte | 17 +- ui/src/AttachmentsList.svelte | 58 ++- ui/src/app.css | 37 +- .../Deliberations/CreateDeliberation.svelte | 84 ++-- .../Deliberations/DeliberationDetail.svelte | 83 ++-- .../converge/Proposals/AllProposals.svelte | 2 +- .../converge/Proposals/CreateProposal.svelte | 20 +- .../converge/Proposals/ProposalDetail.svelte | 33 +- .../converge/Proposals/RateCriterion.svelte | 2 +- ui/src/converge/converge/types.ts | 2 +- ui/src/svgIcons.ts | 2 + ui/src/util.ts | 2 + ui/src/we.ts | 409 +++++++++++++----- we_dev/config.ts | 98 +++++ 20 files changed, 1065 insertions(+), 326 deletions(-) create mode 100644 we_dev/config.ts diff --git a/dnas/converge/zomes/coordinator/converge/src/lib.rs b/dnas/converge/zomes/coordinator/converge/src/lib.rs index 57f226d..1d42f26 100644 --- a/dnas/converge/zomes/coordinator/converge/src/lib.rs +++ b/dnas/converge/zomes/coordinator/converge/src/lib.rs @@ -48,6 +48,7 @@ pub fn init(_: ()) -> ExternResult { pub struct ActivityPayload { deliberation_hash: ActionHash, message: String, + title: String, } #[hdk_extern] pub fn new_activity_sender(data: ActivityPayload) -> ExternResult { @@ -66,16 +67,17 @@ pub fn new_activity_sender(data: ActivityPayload) -> ExternResult, -} -#[hdk_entry_helper] -#[derive(Clone, PartialEq)] pub struct Deliberation { pub title: String, pub description: String, pub settings: String, - pub attachments: Option>, - pub discussion: Option, + pub attachments: Option>, + pub discussion: Option, } pub fn validate_create_deliberation( _action: EntryCreationAction, diff --git a/dnas/converge/zomes/integrity/converge/src/proposal.rs b/dnas/converge/zomes/integrity/converge/src/proposal.rs index 9f9afc8..d815d15 100644 --- a/dnas/converge/zomes/integrity/converge/src/proposal.rs +++ b/dnas/converge/zomes/integrity/converge/src/proposal.rs @@ -1,16 +1,10 @@ use hdi::prelude::*; #[hdk_entry_helper] #[derive(Clone, PartialEq)] -pub struct HrlB64WithContext { - pub hrl: String, - pub context: Option, -} -#[hdk_entry_helper] -#[derive(Clone, PartialEq)] pub struct Proposal { pub title: String, pub description: String, - pub attachments: Option>, + pub attachments: Option>, } pub fn validate_create_proposal( _action: EntryCreationAction, diff --git a/package-lock.json b/package-lock.json index 14a7b31..3415aa9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -73,6 +73,28 @@ "node": ">=0.1.90" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@ctrl/tinycolor": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-4.0.3.tgz", @@ -952,18 +974,86 @@ "dev": true }, "node_modules/@lightningrodlabs/we-applet": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-applet/-/we-applet-0.14.2.tgz", - "integrity": "sha512-TXXQj8CSCxmDlMKkYBZMlktxeD/wrgPj2mIivTFA0VzEbtz2rVnxr4ZR5q+vP0fs6h82Che/9zaYOHjjaRdx/Q==", + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-applet/-/we-applet-0.16.2.tgz", + "integrity": "sha512-pQYzq02E+x6LOe+AWaebHTE1nPDgACgwlrYwfXe5k6KEsi8ii3CuxgQnjLkk3OInbEOm3tDx/LIK6J7CPbD1sQ==", "dependencies": { - "@holochain/client": "0.16.6" + "@holochain/client": "^0.17.0-dev.7", + "@msgpack/msgpack": "^2.8.0", + "js-base64": "^3.7.2" } }, "node_modules/@lightningrodlabs/we-applet/node_modules/@holochain/client": { - "version": "0.16.6", - "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.16.6.tgz", - "integrity": "sha512-p6Vt8Ka6bLNAgCOXKs+wwgSg9vF9ZLp6iEJaNcmv71wmtf3d8YuqCtQXn6fL7/IW/I/SxPHvlihjo9jstdeC7w==", + "version": "0.17.0-dev.8", + "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.17.0-dev.8.tgz", + "integrity": "sha512-npFoEoQd5Pai1a6B5sB0azbO9fEoZgGTY4k74cHCbtLS31Q0dSIwhrxTO6+XUVt2eyq64l6t4hJljCYIqGZVjQ==", + "dependencies": { + "@bitgo/blake2b": "^3.2.4", + "@holochain/serialization": "^0.1.0-beta-rc.3", + "@msgpack/msgpack": "^2.8.0", + "@tauri-apps/api": "^1.4.0", + "emittery": "^1.0.1", + "isomorphic-ws": "^5.0.0", + "js-base64": "^3.7.5", + "libsodium-wrappers": "^0.7.13", + "lodash-es": "^4.17.21", + "ws": "^8.14.2" + }, + "engines": { + "node": ">=18.0.0 || >=20.0.0" + } + }, + "node_modules/@lightningrodlabs/we-dev-cli": { + "version": "0.11.4", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-dev-cli/-/we-dev-cli-0.11.4.tgz", + "integrity": "sha512-jZgyGHVILXJHnkB8SBjwNBoMLCTzI9pCJ9a9P6aQ42/4NeLLv29ocqVCkXSbgYGVTXZCJjKJeGeyLjExB+sIBQ==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@electron-toolkit/preload": "^2.0.0", + "@electron-toolkit/utils": "^2.0.0", + "@holochain-open-dev/utils": "0.300.0-dev.0", + "@holochain/client": "^0.17.0-dev.7", + "@lightningrodlabs/we-applet": "0.16.0", + "@lightningrodlabs/we-rust-utils": "0.300.1-dev.2", + "bufferutil": "4.0.8", + "commander": "11.1.0", + "electron-context-menu": "3.6.1", + "mime": "4.0.0", + "nanoid": "5.0.4", + "split": "1.0.1", + "ts-node": "10.9.2", + "winston": "3.11.0" + }, + "bin": { + "we-dev-cli": "cli.js" + } + }, + "node_modules/@lightningrodlabs/we-dev-cli/node_modules/@electron-toolkit/preload": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@electron-toolkit/preload/-/preload-2.0.0.tgz", + "integrity": "sha512-zpZDzbqJTZQC5d4LRs2EKruKWnqah+T75s+niBYFemYLtiW5TTZcWi3Q8UxHqnwTudDMuWJb233aaS2yjx3Xiw==", + "dev": true, + "peerDependencies": { + "electron": ">=13.0.0" + } + }, + "node_modules/@lightningrodlabs/we-dev-cli/node_modules/@electron-toolkit/utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@electron-toolkit/utils/-/utils-2.0.1.tgz", + "integrity": "sha512-3nnjd3D1NIjxdzNrvR5fkJ3kbJNbRkpHppv0/pSbMX6I0DaBzpPXeSfDYuJJKzZrAc3CmGcJa0MU4+AjEOlT4g==", + "dev": true, + "peerDependencies": { + "electron": ">=13.0.0" + } + }, + "node_modules/@lightningrodlabs/we-dev-cli/node_modules/@holochain/client": { + "version": "0.17.0-dev.8", + "resolved": "https://registry.npmjs.org/@holochain/client/-/client-0.17.0-dev.8.tgz", + "integrity": "sha512-npFoEoQd5Pai1a6B5sB0azbO9fEoZgGTY4k74cHCbtLS31Q0dSIwhrxTO6+XUVt2eyq64l6t4hJljCYIqGZVjQ==", + "dev": true, "dependencies": { + "@bitgo/blake2b": "^3.2.4", "@holochain/serialization": "^0.1.0-beta-rc.3", "@msgpack/msgpack": "^2.8.0", "@tauri-apps/api": "^1.4.0", @@ -978,6 +1068,114 @@ "node": ">=18.0.0 || >=20.0.0" } }, + "node_modules/@lightningrodlabs/we-dev-cli/node_modules/@lightningrodlabs/we-applet": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-applet/-/we-applet-0.16.0.tgz", + "integrity": "sha512-UYWVpew6ttt9oRxKpzyZ02rBIRemeRqkp64SIaczyxEuTJUhy01U8sCUTh+XCK2aCUBD2Gz1yXw53J5QJ0dRxw==", + "dev": true, + "dependencies": { + "@holochain/client": "^0.17.0-dev.7", + "@msgpack/msgpack": "^2.8.0", + "js-base64": "^3.7.2" + } + }, + "node_modules/@lightningrodlabs/we-dev-cli/node_modules/nanoid": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.4.tgz", + "integrity": "sha512-vAjmBf13gsmhXSgBrtIclinISzFFy22WwCYoyilZlsrRXNIHSwgFQ1bEdjRwMT3aoadeIF6HMuDRlOxzfXV8ig==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.js" + }, + "engines": { + "node": "^18 || >=20" + } + }, + "node_modules/@lightningrodlabs/we-rust-utils": { + "version": "0.300.1-dev.2", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-rust-utils/-/we-rust-utils-0.300.1-dev.2.tgz", + "integrity": "sha512-i6x9DI82FsD0RhF0pRFj3+k2NuQL8YICpc9y4LKg3vIRhEDVygzwpVcA5ZTfpGLIHZtzt8Nqv9exYfVHLOhlPQ==", + "dev": true, + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@lightningrodlabs/we-rust-utils-darwin-arm64": "0.300.1-dev.2", + "@lightningrodlabs/we-rust-utils-darwin-x64": "0.300.1-dev.2", + "@lightningrodlabs/we-rust-utils-linux-x64-gnu": "0.300.1-dev.2", + "@lightningrodlabs/we-rust-utils-win32-x64-msvc": "0.300.1-dev.2" + } + }, + "node_modules/@lightningrodlabs/we-rust-utils-darwin-arm64": { + "version": "0.300.1-dev.2", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-rust-utils-darwin-arm64/-/we-rust-utils-darwin-arm64-0.300.1-dev.2.tgz", + "integrity": "sha512-kSWUf5hsHWpSRUI3+g2CCXQenQ18nOXaBf7chGSnIiG8jgQCLOrXlKe1ZuZU6TzoAyd/A75LlBBxD0dETaYQzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@lightningrodlabs/we-rust-utils-darwin-x64": { + "version": "0.300.1-dev.2", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-rust-utils-darwin-x64/-/we-rust-utils-darwin-x64-0.300.1-dev.2.tgz", + "integrity": "sha512-+X0mO2aOm3vgFYUuFMWbcATNIoxm9i7Gnt3bjtNICaimz2Wr2F/Vm0UJuZCWT8uV31feWEBur2GtMDtbrI08tg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@lightningrodlabs/we-rust-utils-linux-x64-gnu": { + "version": "0.300.1-dev.2", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-rust-utils-linux-x64-gnu/-/we-rust-utils-linux-x64-gnu-0.300.1-dev.2.tgz", + "integrity": "sha512-0G5lADOq+e6dQUToOo5nxBH4lzFS6GWcbDHLLFcSx0XRfLfua3Lefe4U77YzEqU1Lgj1H8sQFxQWtyB1wctB+w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@lightningrodlabs/we-rust-utils-win32-x64-msvc": { + "version": "0.300.1-dev.2", + "resolved": "https://registry.npmjs.org/@lightningrodlabs/we-rust-utils-win32-x64-msvc/-/we-rust-utils-win32-x64-msvc-0.300.1-dev.2.tgz", + "integrity": "sha512-Jrh7IyGNt80GB1hxQIoxubPxFiH1yY26I1tzrVul9AOsepjjna+DnNf0FIgxtFCSWG2X7m2gmjENI1cd+OyvUg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@lit-labs/ssr-dom-shim": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz", @@ -2392,6 +2590,30 @@ "url": "https://opencollective.com/tauri" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@tsconfig/svelte": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-3.0.0.tgz", @@ -2898,6 +3120,12 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -3057,6 +3285,19 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, + "node_modules/bufferutil": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz", + "integrity": "sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw==", + "devOptional": true, + "hasInstallScript": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, "node_modules/cac": { "version": "6.7.14", "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", @@ -3418,6 +3659,12 @@ "node": ">= 10" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/csstype": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", @@ -4776,6 +5023,12 @@ "node": ">=12" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/matcher": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", @@ -4811,6 +5064,21 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.0.tgz", + "integrity": "sha512-pzhgdeqU5pJ9t5WK9m4RT4GgGWqYJylxUf62Yb9datXRwdcw5MjiD1BYI5evF8AgTXN9gtKX3CFLvCUL5fAhEA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa" + ], + "bin": { + "mime": "bin/cli.js" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -4947,6 +5215,17 @@ "port": "bin/port.js" } }, + "node_modules/node-gyp-build": { + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.0.tgz", + "integrity": "sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==", + "devOptional": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -6057,6 +6336,58 @@ "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -6151,6 +6482,12 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/vite": { "version": "4.4.9", "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.9.tgz", @@ -6354,11 +6691,11 @@ } }, "node_modules/winston": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.8.2.tgz", - "integrity": "sha512-MsE1gRx1m5jdTTO9Ld/vND4krP2To+lgDoMEHGGa4HIlAUyXJtfc7CxQcGXVyz2IBpw5hbFkj2b/AtUdQwyRew==", + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.11.0.tgz", + "integrity": "sha512-L3yR6/MzZAOl0DsysUXHVjOwv8mKZ71TrA/41EIduGpOOV5LQVodqN+QdQ6BS6PJ/RdIshZhq84P/fStEZkk7g==", "dependencies": { - "@colors/colors": "1.5.0", + "@colors/colors": "^1.6.0", "@dabh/diagnostics": "^2.0.2", "async": "^3.2.3", "is-stream": "^2.0.0", @@ -6387,6 +6724,14 @@ "node": ">= 6.4.0" } }, + "node_modules/winston/node_modules/@colors/colors": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", + "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -6483,6 +6828,15 @@ "fd-slicer": "~1.1.0" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", @@ -6520,9 +6874,10 @@ "ui": { "version": "0.1.0", "dependencies": { + "@holochain-open-dev/elements": "^0.300.0-dev.0", "@holochain-open-dev/profiles": "^0.300.0-dev.0", "@holochain/client": "^0.17.0-dev.7", - "@lightningrodlabs/we-applet": "^0.14.2", + "@lightningrodlabs/we-applet": "^0.16.2", "@material/mwc-button": "^0.27.0", "@material/mwc-checkbox": "^0.27.0", "@material/mwc-circular-progress": "^0.27.0", @@ -6541,6 +6896,7 @@ "@vaadin/date-time-picker": "^23.2.8" }, "devDependencies": { + "@lightningrodlabs/we-dev-cli": "^0.11.0", "@sveltejs/vite-plugin-svelte": "^2.0.2", "@tsconfig/svelte": "^3.0.0", "bestzip": "^2.2.0", diff --git a/ui/package.json b/ui/package.json index ff27730..3a57c67 100644 --- a/ui/package.json +++ b/ui/package.json @@ -8,9 +8,10 @@ "package": "npm run build && cd dist && bestzip ../dist.zip *" }, "dependencies": { + "@holochain-open-dev/elements": "^0.300.0-dev.0", "@holochain-open-dev/profiles": "^0.300.0-dev.0", "@holochain/client": "^0.17.0-dev.7", - "@lightningrodlabs/we-applet": "^0.14.2", + "@lightningrodlabs/we-applet": "^0.16.2", "@material/mwc-button": "^0.27.0", "@material/mwc-checkbox": "^0.27.0", "@material/mwc-circular-progress": "^0.27.0", @@ -29,6 +30,7 @@ "@vaadin/date-time-picker": "^23.2.8" }, "devDependencies": { + "@lightningrodlabs/we-dev-cli": "^0.11.0", "@sveltejs/vite-plugin-svelte": "^2.0.2", "@tsconfig/svelte": "^3.0.0", "bestzip": "^2.2.0", diff --git a/ui/src/App.svelte b/ui/src/App.svelte index ff8ae38..9531cd3 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -23,8 +23,9 @@ import Header from './converge/converge/Header.svelte'; import DeliberationsForDeliberator from './converge/converge/Deliberations/DeliberationsForDeliberator.svelte'; import { MyProfile } from '@holochain-open-dev/profiles/dist/elements/my-profile.js'; - import { WeClient, isWeContext, initializeHotReload, type HrlWithContext, type Hrl } from '@lightningrodlabs/we-applet'; + import { WeClient, isWeContext, initializeHotReload, type WAL, type Hrl } from '@lightningrodlabs/we-applet'; import Holochain from "./assets/holochain.png"; +import type { Deliberation, ConvergeSignal } from './converge/converge/types'; import { appletServices } from './we'; // import AttachmentsList from './AttachmentsList.svelte'; // import AttachmentsBind from './AttachmentsBind.svelte'; @@ -101,24 +102,34 @@ case "block": switch(weClient.renderInfo.view.block) { case "active_boards": - renderType = RenderType.BlockActiveBoards + currentView = "dashboard" break; default: throw new Error("Unknown applet-view block type:"+weClient.renderInfo.view.block); } break; - case "attachable": + case "creatable": + switch (weClient.renderInfo.view.name) { + case "Deliberation": + currentView = "create-deliberation-mini" + } + break; + case "asset": switch (weClient.renderInfo.view.roleName) { case "converge": switch (weClient.renderInfo.view.integrityZomeName) { case "converge_integrity": switch (weClient.renderInfo.view.entryType) { case "deliberation": - currentView = "deliberation" - currentHash = weClient.renderInfo.view.hrlWithContext.hrl[1] + currentView = "deliberation-asset" + currentHash = weClient.renderInfo.view.wal.hrl[1] // console.log("weClient.renderInfo.view", weClient.renderInfo.view) // hrlWithContext = weClient.renderInfo.view.hrlWithContext break; + case "proposal": + currentView = "proposal-asset" + currentHash = weClient.renderInfo.view.wal.hrl[1] + break; default: throw new Error("Unknown entry type:"+weClient.renderInfo.view.entryType); } @@ -183,6 +194,35 @@ loading = false; + + client.on('signal', signal => { + console.log("signalll", signal) + if (signal.zome_name !== 'converge') return; + const payload = signal.payload as ConvergeSignal; + const urgentMessages = ['criterion-created', 'proposal-created', 'deliberation-created'] + const messagesFull = { + 'criterion-created': "A new criterion has been added to the deliberation " + payload.title, + 'proposal-created': "A new proposal has been added to the deliberation " + payload.title, + 'deliberation-created': "A new deliberation has been created: " + payload.title, + } + const messagesShort = { + 'criterion-created': "New criterion in " + payload.title, + 'proposal-created': "New proposal in " + payload.title, + 'deliberation-created': "New deliberation" + } + if (urgentMessages.includes(payload.message)) { + console.log("activity received", payload) + + weClient.notifyFrame([{ + title: messagesShort[payload.message], + body: messagesFull[payload.message], + notification_type: "change", + icon_src: undefined, + urgency: "high", + timestamp: Date.now() + }]) + } + }); }); setContext(clientContext, { @@ -205,46 +245,46 @@ {#if profilesStore} - {#if !weClient || weClient.renderInfo.view.type != "attachable"} -
-
-
- {#if loading} -
- -
- {:else if currentView == "deliberation"} - - {:else if currentView == "proposal"} - - {:else if currentView == "create-deliberation"} + {#if currentView == "create-deliberation-mini"} + - {:else if currentView == "dashboard"} - - {:else} -
- - -
- {/if} -
-
- {:else} -
- {#if weClient && weClient.renderInfo.view.integrityZomeName == "converge_integrity"} - {#if weClient.renderInfo.view.entryType == "deliberation"} + {:else if currentView == "deliberation-asset"} +
- + +
+
+ {:else if currentView == "proposal-asset"} +
+
+
- {:else} -
Unknown entry type: {weClient.renderInfo.view.entryType}
- {/if} +
{:else} - Unknown zome - +
+
+
+ {#if loading} +
+ +
+ {:else if currentView == "deliberation"} + + {:else if currentView == "proposal"} + + {:else if currentView == "create-deliberation"} + + {:else if currentView == "dashboard"} + + {:else} +
+ + +
+ {/if} +
+
{/if} -
- {/if}
diff --git a/ui/src/AttachmentsDialog.svelte b/ui/src/AttachmentsDialog.svelte index df275e5..3b58b68 100644 --- a/ui/src/AttachmentsDialog.svelte +++ b/ui/src/AttachmentsDialog.svelte @@ -1,5 +1,5 @@ diff --git a/ui/src/AttachmentsList.svelte b/ui/src/AttachmentsList.svelte index be3ff0b..a9a6c4e 100644 --- a/ui/src/AttachmentsList.svelte +++ b/ui/src/AttachmentsList.svelte @@ -1,17 +1,17 @@ +
- {#each attachments as attachment, index} + {#each attachments as wal, index}
- {#await weClient.attachableInfo(hrlB64WithContextToRaw(attachment))} + + {#await weClient.assetInfo(weaveUrlToWAL(wal))} - {:then { attachableInfo }} - { - e.stopPropagation() - const hrlWithContext = hrlB64WithContextToRaw(attachment) - weClient.openHrl(hrlWithContext) - }} - style="display:flex;flex-direction:row;margin-right:5px"> - {attachableInfo.name} - - {#if allowDelete} - { - dispatch("remove-attachment",index) - }} - > - + {:then data} + {#if data} + {@const assetInfo = data.assetInfo} + { + e.stopPropagation() + try { + await weClient.openWal(weaveUrlToWAL(wal)) + } catch(e) { + alert(`Error opening link: ${e}`) + } + }} + style="display:flex;flex-direction:row;margin-right:5px"> + {assetInfo.name} + {:else} +
Bad WAL
{/if} {:catch error} - Oops. something's wrong. +
Error getting asset info: {error}
{/await} + {#if allowDelete} + { + dispatch("remove-attachment",index) + }} + > + + + {/if}
{/each}
diff --git a/ui/src/app.css b/ui/src/app.css index 1cc6c5b..f4cd2b0 100644 --- a/ui/src/app.css +++ b/ui/src/app.css @@ -82,12 +82,17 @@ body { color: #525252; } -/* .add-button { - height: 28px; +.add-button { position: relative; - top: -1px; - border: 1px solid #9200a1; -} */ + width: fit-content; + border-radius: 4px; + color: white; + display: inline-block; + padding: 8.5px 12px; + top: 1px; + background-color: #7b1fa2; + cursor: pointer; +} .sort-dropdown { cursor: pointer; @@ -212,7 +217,7 @@ body { border: 1px solid gray; border-radius: 5px; - margin: 6px 6px 6px 0px; + margin: 0px 6px 6px 0px; box-shadow: 0px 0px 6px #00000019; border: 1px solid #efefef; border-radius: 12px; @@ -244,11 +249,29 @@ body { } .two-sides > div { + margin-top: 4px; width: 100%; display: flex; /* center content */ align-items: center; } + + .two-sides-proposal> div { + align-items: initial; + } + + .star-slider { + width: 40vw; + } + + .vertical-progress-bar-container { + height: 200px !important; + } + + .progress-line { + height: 3px !important; + margin-top: 3px !important; + } } .vertical-progress-bar-container { @@ -345,7 +368,7 @@ mwc-slider[disabled] .mdc-slider__thumb-knob { background-color: white; padding: 25px; padding-top: 0px; - height: 100%; + min-height: 100vh; width: calc(100vw - 65px); } diff --git a/ui/src/converge/converge/Deliberations/CreateDeliberation.svelte b/ui/src/converge/converge/Deliberations/CreateDeliberation.svelte index 0658596..7d36610 100644 --- a/ui/src/converge/converge/Deliberations/CreateDeliberation.svelte +++ b/ui/src/converge/converge/Deliberations/CreateDeliberation.svelte @@ -13,14 +13,13 @@ import '@material/mwc-textarea'; import { view, viewHash, navigate } from '../../../store.js'; import AttachmentsDialog from "../../../AttachmentsDialog.svelte" import SvgIcon from "../../../SvgIcon.svelte"; -import { WeClient, isWeContext, initializeHotReload, type HrlB64WithContext, type Hrl } from '@lightningrodlabs/we-applet'; -import type { AppletInfo, AttachmentType } from "@lightningrodlabs/we-applet"; +import { WeClient, isWeContext, initializeHotReload, type WAL, type Hrl } from '@lightningrodlabs/we-applet'; import AttachmentsBind from '../../../AttachmentsBind.svelte'; import { HoloHashMap, type EntryHashMap } from "@holochain-open-dev/utils"; let client: AppAgentClient = (getContext(clientContext) as any).getClient(); import { weClientStored } from '../../../store.js'; import app from '../../../main'; -import { hrlB64WithContextToRaw, hrlWithContextToB64, getMyDna } from '../../../util'; +import { hrlB64WithContextToRaw, hrlWithContextToB64, getMyDna, type WALUrl } from '../../../util'; const dispatch = createEventDispatcher(); @@ -28,13 +27,12 @@ let attachmentsDialog : AttachmentsDialog let title: string = ''; let description: string = ''; let settings: any = {scoring: 'classic'}; -let attachments: Array = []; +let attachments: Array = []; let errorSnackbar: Snackbar; // let threadsInfos: HoloHashMap = new HoloHashMap let discussionApps = {}; let selectedDiscussionApp: string = "none"; let attachmentTypes = []; -let dna; $: title, description, settings, attachments, discussionApps; $: isDeliberationValid = true && title !== '' && settings !== ''; @@ -45,34 +43,33 @@ weClientStored.subscribe(value => { }); onMount(async() => { - dna = await getMyDna("converge", client) - - attachmentTypes = Array.from(weClient.attachmentTypes.entries()) - console.log(attachmentTypes) - console.log(discussionApps) - for (const [appletHash, record] of attachmentTypes) { - console.log(record) - let appletInfo = await weClient.appletInfo(appletHash) - if (!discussionApps[appletInfo.appletName]) { - console.log(record) - const recordTypeNames = Object.keys(record).map((key) => JSON.stringify({ - app: appletInfo.appletName, - type: key - })) - recordTypeNames.forEach((recordTypeName) => { - const recordType = JSON.parse(recordTypeName).type - console.log(recordTypeName) - if (appletInfo.appletName.includes("threads")) { - console.log("appletInfo", appletInfo) - console.log("record", record) - discussionApps[recordTypeName] = [appletHash, record[recordType]] - selectedDiscussionApp = recordTypeName; - } else { - discussionApps[recordTypeName] = [appletHash, record[recordType]] - } - }) - } - } + + // attachmentTypes = Array.from(weClient.attachmentTypes.entries()) + // console.log(attachmentTypes) + // console.log(discussionApps) + // for (const [appletHash, record] of attachmentTypes) { + // console.log(record) + // let appletInfo = await weClient.appletInfo(appletHash) + // if (!discussionApps[appletInfo.appletName]) { + // console.log(record) + // const recordTypeNames = Object.keys(record).map((key) => JSON.stringify({ + // app: appletInfo.appletName, + // type: key + // })) + // recordTypeNames.forEach((recordTypeName) => { + // const recordType = JSON.parse(recordTypeName).type + // console.log(recordTypeName) + // if (appletInfo.appletName.includes("threads")) { + // console.log("appletInfo", appletInfo) + // console.log("record", record) + // discussionApps[recordTypeName] = [appletHash, record[recordType]] + // selectedDiscussionApp = recordTypeName; + // } else { + // discussionApps[recordTypeName] = [appletHash, record[recordType]] + // } + // }) + // } + // } discussionApps = {...discussionApps} console.log("discussionApps", discussionApps) console.log(selectedDiscussionApp) @@ -83,12 +80,7 @@ async function createDeliberation() { title: title!, description: description!, settings: JSON.stringify(settings!), - attachments: attachments.map(a => { - return { - hrl: JSON.stringify(a.hrl), - context: a.context - } - }), + attachments: attachments // discussionApp: selectedDiscussionApp.appletName }; @@ -153,7 +145,19 @@ async function createDeliberation() { payload: deliberationUpdate, }); } - + + // await client.callZome({ + // cap_secret: null, + // role_name: 'converge', + // zome_name: 'converge', + // fn_name: 'new_activity_sender', + // payload: { + // deliberation_hash: record.signed_action.hashed.hash, + // message: "deliberation-created", + // title: title, + // }, + // }); + navigate("deliberation", record.signed_action.hashed.hash) } catch (e) { console.log(e) diff --git a/ui/src/converge/converge/Deliberations/DeliberationDetail.svelte b/ui/src/converge/converge/Deliberations/DeliberationDetail.svelte index 39f2a1f..b49081d 100644 --- a/ui/src/converge/converge/Deliberations/DeliberationDetail.svelte +++ b/ui/src/converge/converge/Deliberations/DeliberationDetail.svelte @@ -21,11 +21,13 @@ import AllCriteria from '../Criteria/AllCriteria.svelte'; import CreateProposal from '../Proposals/CreateProposal.svelte'; import AllProposals from '../Proposals/AllProposals.svelte'; import AttachmentsList from '../../../AttachmentsList.svelte'; -import { type HrlB64WithContext, isWeContext } from '@lightningrodlabs/we-applet'; +import { isWeContext, type WAL } from '@lightningrodlabs/we-applet'; import Avatar from '../Avatar.svelte'; import SvgIcon from "../../../SvgIcon.svelte"; import { weClientStored } from '../../../store.js'; - import { hrlB64WithContextToRaw, hrlWithContextToB64 } from '../../../util'; +import { getMyDna } from '../../../util'; +import type { WALUrl } from '../../../util'; + // import { hrlB64WithContextToRaw, hrlWithContextToB64 } from '../../../util'; const dispatch = createEventDispatcher(); @@ -53,6 +55,7 @@ let criteriaFilter; let proposalFilter; let proposalCount = 0; let sortedCriteria; +let lastMessage; let detectSort; let sortByOptions = [ @@ -65,8 +68,9 @@ let sortByOptions = [ ]; let criteriaSort = "support"; let proposalSort; -let attachments: HrlB64WithContext[] = []; +let attachments: WALUrl[] = []; let weClient; +let dnaHash; weClientStored.subscribe(value => { weClient = value; }); @@ -74,25 +78,40 @@ weClientStored.subscribe(value => { $: editing, error, loading, record, deliberation, activeTab, criterionFormPopup, proposalFormPopup, criteriaCount, proposalCount, criteriaFilter, proposalFilter, criteriaSort, proposalSort, sortedCriteria; onMount(async () => { + dnaHash = await getMyDna("converge", client) + if (deliberationHash === undefined) { throw new Error(`The deliberationHash input is required for the DeliberationDetail element`); } await fetchDeliberation(); client.on('signal', signal => { + console.log("signalll", signal) if (signal.zome_name !== 'converge') return; const payload = signal.payload as ConvergeSignal; - if (payload.message == 'live_update' && payload.deliberation_hash.join(',') == deliberationHash.join(',')) { - console.log("activity received") + const updateMessages = ['new-join', 'criterion-created', 'proposal-rated', 'proposal-created', 'criterion-rated'] + const urgentMessages = ['criterion-created', 'proposal-created'] + const messagesFull = { + 'new-join': "A new participant has joined the deliberation", + 'criterion-created': "A new criterion has been added to the deliberation " + deliberation.title, + 'proposal-rated': "A proposal has been rated", + 'proposal-created': "A new proposal has been added to the deliberation " + deliberation.title, + 'criterion-rated': "A criterion has been rated" + } + if (updateMessages.includes(payload.message) && (payload.deliberation_hash.join(',') == deliberationHash.join(','))) { + console.log("activity received", payload) outdated = true; - weClient.notifyWe([{ - title: `updated`, - body: "body", - notification_type: "change", - icon_src: undefined, - urgency: "low", - timestamp: Date.now() + + weClient.notifyFrame([{ + title: `New activity in ${deliberation.title}`, + body: messagesFull[payload.message], + notification_type: "change", + icon_src: undefined, + urgency: "low", + timestamp: Date.now() }]) + + lastMessage = messagesFull[payload.message]; } // console.log(payload) }); @@ -121,6 +140,11 @@ onMount(async () => { // }); }); +const copyWalToPocket = () => { + const attachment: WAL = { hrl: [dnaHash, deliberationHash], context: "" } + weClient?.walToPocket(attachment) +} + async function fetchDeliberation() { outdated = false; loading = true; @@ -138,12 +162,7 @@ async function fetchDeliberation() { }); if (record) { deliberation = decode((record.entry as any).Present.entry) as Deliberation; - attachments = deliberation.attachments?.map((attachment) => { - return { - hrl: JSON.parse(attachment.hrl), - context: attachment.context - } - }) + attachments = deliberation.attachments } } catch (e) { error = e; @@ -199,7 +218,7 @@ async function newActivity(event) { console.log("new activity") console.log(event) joinDeliberation() - sendActivityNotice({}) + sendActivityNotice(event) } async function sendActivityNotice(event) { @@ -211,7 +230,8 @@ async function sendActivityNotice(event) { fn_name: 'new_activity_sender', payload: { deliberation_hash: deliberationHash, - message: 'live_update' + message: event, + title: deliberation.title }, }); } catch (e: any) { @@ -289,7 +309,7 @@ async function leaveDeliberation() { {:else if error} -Error fetching the deliberation: {error.data.data} +Error fetching the deliberation: {JSON.stringify(error)} {:else if editing} {:else} -{#if outdated} +{#if outdated && lastMessage}
- This page is outdated. Click to refresh. ↺ + This page is outdated because {lastMessage.toLowerCase()}. Click to refresh. ↺
{:else}
@@ -345,7 +365,7 @@ async function leaveDeliberation() { {#if deliberators.includes(client.myPubKey.join(','))} Leave {:else} - Join + {newActivity("new-join")}}>Join {/if} @@ -357,6 +377,9 @@ async function leaveDeliberation() {
+ {#if isWeContext && deliberation.discussion} {@const conversation = { hrl: JSON.parse(deliberation.discussion.hrl), @@ -416,15 +439,15 @@ async function leaveDeliberation() { - {criterionFormPopup = true; console.log(criterionFormPopup)}} class="add-button">Add a criterion +
{criterionFormPopup = true; console.log(criterionFormPopup)}} class="add-button">{window.innerWidth < 768 ? "+" : "Add a criterion"}
- + {newActivity("criterion-created")}} deliberationHash={deliberationHash} alternativeTo={null} bind:criterionFormPopup />

- + {newActivity("criterion-rated")}} deliberationHash={deliberationHash} filter={criteriaFilter} sort={criteriaSort} bind:sortedCriteria bind:criteriaCount /> @@ -443,13 +466,13 @@ async function leaveDeliberation() {
{/if} - {proposalFormPopup = true; console.log(proposalFormPopup)}} class="add-button">Add proposal +
{proposalFormPopup = true; console.log(proposalFormPopup)}} class="add-button">{window.innerWidth < 768 ? "+" : "Add a proposal"}
- + {newActivity("proposal-created")}} {deliberationHash} {sortedCriteria} bind:proposalFormPopup/>

- + {newActivity("proposal-rated")}} sort={proposalSort} deliberationHash={deliberationHash} filter={proposalFilter} bind:proposalCount/> {/if} {/if} diff --git a/ui/src/converge/converge/Proposals/AllProposals.svelte b/ui/src/converge/converge/Proposals/AllProposals.svelte index e17cf10..72fe4db 100644 --- a/ui/src/converge/converge/Proposals/AllProposals.svelte +++ b/ui/src/converge/converge/Proposals/AllProposals.svelte @@ -134,7 +134,7 @@ async function rateAlert() { {:else if error} Error fetching the proposals: {error.data.data}. {:else if hashes.length === 0} -Add a proposal. +No proposals yet {:else}
{#each sortedProposals as hash} diff --git a/ui/src/converge/converge/Proposals/CreateProposal.svelte b/ui/src/converge/converge/Proposals/CreateProposal.svelte index c16608e..5d330a7 100644 --- a/ui/src/converge/converge/Proposals/CreateProposal.svelte +++ b/ui/src/converge/converge/Proposals/CreateProposal.svelte @@ -10,11 +10,12 @@ import type { Snackbar } from '@material/mwc-snackbar'; import '@material/mwc-textarea'; import '@material/mwc-textfield'; import AttachmentsDialog from "../../../AttachmentsDialog.svelte" - import Criterion from '../Criteria/Criterion.svelte'; +import Criterion from '../Criteria/Criterion.svelte'; +import type { WALUrl } from '../../../util'; let client: AppAgentClient = (getContext(clientContext) as any).getClient(); let attachmentsDialog : AttachmentsDialog -let attachments: Array = []; +let attachments: Array = []; let showCriteria = true; const dispatch = createEventDispatcher(); @@ -56,12 +57,7 @@ async function createProposal() { const proposalEntry: Proposal = { title: title!, description: description!, - attachments: attachments.map(a => { - return { - hrl: JSON.stringify(a.hrl), - context: a.context - } - }), + attachments: attachments }; const createProposalInput: CreateProposalInput = { @@ -118,12 +114,12 @@ async function createProposal() {

Create Proposal

-
- { title = e.target.value;} } required> +
+ { title = e.target.value;} } required>
-
- { description = e.target.value; } } required> +
+ { description = e.target.value; } } required>
{ + weClient = value; +}); let errorSnackbar: Snackbar; @@ -43,6 +51,8 @@ $: if (proposalHash) { } onMount(async () => { + dnaHash = await getMyDna("converge", client) + if (proposalHash === undefined) { throw new Error(`The proposalHash input is required for the ProposalDetail element`); } @@ -66,12 +76,7 @@ async function fetchProposal() { }); if (record) { proposal = decode((record.entry as any).Present.entry) as Proposal; - attachments = proposal.attachments?.map((attachment) => { - return { - hrl: JSON.parse(attachment.hrl), - context: attachment.context - } - }) + attachments = proposal.attachments } } catch (e) { error = e; @@ -80,6 +85,11 @@ async function fetchProposal() { loading = false; } +const copyWalToPocket = () => { + const attachment: WAL = { hrl: [dnaHash, proposalHash], context: "" } + weClient?.walToPocket(attachment) +} + async function rateAlert() { console.log('rate-alert-4') dispatch('proposal-rated'); @@ -132,7 +142,7 @@ async function fetchDeliberation() {
{:else if error} -Error fetching the proposal: {error.data.data} +Error fetching the proposal: {JSON.stringify(error)} {:else} @@ -151,12 +161,15 @@ flex: 1;"> -->
{/if} -
+
-
+
{ proposal.title } +
diff --git a/ui/src/converge/converge/Proposals/RateCriterion.svelte b/ui/src/converge/converge/Proposals/RateCriterion.svelte index 36925b1..a746921 100644 --- a/ui/src/converge/converge/Proposals/RateCriterion.svelte +++ b/ui/src/converge/converge/Proposals/RateCriterion.svelte @@ -157,7 +157,7 @@ async function fetchSupport() { sponsored = supporters.some(item => item["agent"] === client.myPubKey.join(",")); } allSupport[criterionHash.join(',')] = averageSupport; - console.log("all support" + JSON.stringify(allSupport)) + // console.log("all support" + JSON.stringify(allSupport)) } } catch (e) { console.log(e) diff --git a/ui/src/converge/converge/types.ts b/ui/src/converge/converge/types.ts index 380609c..10ac3d9 100644 --- a/ui/src/converge/converge/types.ts +++ b/ui/src/converge/converge/types.ts @@ -87,8 +87,8 @@ export interface CreateCriterionInput { export interface Proposal { title: string; - description: string; + attachments: string[] } export interface CreateProposalInput { diff --git a/ui/src/svgIcons.ts b/ui/src/svgIcons.ts index cc834eb..b4585b5 100644 --- a/ui/src/svgIcons.ts +++ b/ui/src/svgIcons.ts @@ -25,4 +25,6 @@ export const svgIcons = { faPaperclip: ``, link: ``, questionMark: ``, + addToPocket: ``, + searchPlus: `` } \ No newline at end of file diff --git a/ui/src/util.ts b/ui/src/util.ts index 4e304af..f75b280 100644 --- a/ui/src/util.ts +++ b/ui/src/util.ts @@ -32,6 +32,8 @@ export function hrlB64WithContextToRaw(hrlB64: HrlB64WithContext): HrlWithContex }; } +export type WALUrl = string + export const hashEqual = (a:EntryHash, b:EntryHash) : boolean => { if (!a || !b) { return !a && !b diff --git a/ui/src/we.ts b/ui/src/we.ts index f880a10..fb04fdf 100644 --- a/ui/src/we.ts +++ b/ui/src/we.ts @@ -1,10 +1,10 @@ import { asyncDerived, pipe, sliceAndJoin, toPromise } from '@holochain-open-dev/stores'; import { LazyHoloHashMap } from '@holochain-open-dev/utils'; -import type { AppletHash, AppletServices, AttachableInfo, Hrl, HrlWithContext, WeServices } from '@lightningrodlabs/we-applet'; +import type { AppletHash, AppletServices, AssetInfo, WAL, WeServices } from '@lightningrodlabs/we-applet'; import type { AppAgentClient, RoleName, ZomeName } from '@holochain/client'; import { getMyDna, hrlWithContextToB64 } from './util'; import { AppWebsocket, AppAgentWebsocket, AdminWebsocket } from '@holochain/client'; -import type { Deliberation } from './converge/converge/types'; +import type { Deliberation, Proposal } from './converge/converge/types'; import { decode } from '@msgpack/msgpack'; const appPort = import.meta.env.VITE_APP_PORT ? import.meta.env.VITE_APP_PORT : 8888 @@ -16,132 +16,311 @@ const ZOME_NAME = "converge" const appId = import.meta.env.VITE_APP_ID ? import.meta.env.VITE_APP_ID : 'converge' const ICON = '' +const ICON2 = ` + + + + + + + + + + + + + + + +` const CARD_ICON_SRC = `data:image/svg+xml;utf8,` const MINILOGO = '' export const appletServices: AppletServices = { - // Types of attachment that this Applet offers for other Applets to attach - attachmentTypes: async ( - appletClient: AppAgentClient, - appletHash: AppletHash, - weServices: WeServices - ) => ({ - // No way to specify the context so we can't create a board. - deliberation: { - label: "Deliberation", - icon_src: CARD_ICON_SRC, - async create(attachToHrlWithContext: HrlWithContext) { - const hrlB64 = hrlWithContextToB64(attachToHrlWithContext) - const dnaHash = await getMyDna(ROLE_NAME, appletClient) - console.log("context", attachToHrlWithContext) - - // const deliberationEntry: Deliberation = { - // title: attachToHrlWithContext.context.title!, - // description: attachToHrlWithContext.context.description!, - // settings: JSON.stringify(attachToHrlWithContext.context.settings!), - // attachments: [hrlB64] - // }; - - const deliberationEntry: Deliberation = { - title: "Deliberation", - description: "", - settings: "", - attachments: [{ - hrl: JSON.stringify(hrlB64.hrl), - context: JSON.stringify("attachToHrlWithContext.context") - }] - }; - - console.log("createDeliberation", deliberationEntry) - let record; - - try { - record = await appletClient.callZome({ - cap_secret: null, - role_name: 'converge', - zome_name: 'converge', - fn_name: 'create_deliberation', - payload: deliberationEntry, - }); - - // join deliberation - await appletClient.callZome({ - cap_secret: null, - role_name: 'converge', - zome_name: 'converge', - fn_name: 'add_deliberation_for_deliberator', - payload: { - base_deliberator: appletClient.myPubKey, - target_deliberation_hash: record.signed_action.hashed.hash - }, - }); - } catch (e) { - console.log(e) - } - - console.log("hash", record.signed_action.hashed.hash) - - return { - hrl: [dnaHash, record.signed_action.hashed.hash], - }; - }, - }, - }), - // Types of UI widgets/blocks that this Applet supports - blockTypes: {}, - getAttachableInfo: async ( - appletClient: AppAgentClient, - roleName: RoleName, - integrityZomeName: ZomeName, - entryType: string, - hrlWithContext: HrlWithContext - ): Promise => { - let dnaHash = await getMyDna(ROLE_NAME, appletClient) - let deliberation: Deliberation; - let record: any; - - try { - record = await appletClient.callZome({ - cap_secret: null, - role_name: 'converge', - zome_name: 'converge', - fn_name: 'get_deliberation', - payload: hrlWithContext.hrl[1], - }); - if (record) { - deliberation = decode((record.entry as any).Present.entry) as Deliberation; - } - } catch (e) { - console.log(e) - } - - return { - icon_src: `data:image/svg+xml;utf8,${MINILOGO}`, - name: deliberation.title, - }; + // Types of attachment that this Applet offers for other Applets to be created + creatables: { + 'Deliberation': { + label: "Deliberation", + icon_src: MINILOGO, }, - search: async ( - appletClient: AppAgentClient, - appletHash: AppletHash, - weServices: WeServices, - searchFilter: string - ): Promise> => { - let hashes: HrlWithContext[]; + 'Proposal': { + label: "Proposal", + icon_src: MINILOGO, + } + }, + // Types of UI widgets/blocks that this Applet supports + blockTypes: { + 'my_deliberations': { + label: 'My Deliberations', + icon_src: + ``, + view: "applet-view", + }, + }, + bindAsset: async (appletClient: AppAgentClient, + srcWal: WAL, dstWal: WAL): Promise => { + console.log("Bind requested. Src:", srcWal, " Dst:", dstWal) + }, + getAssetInfo: async ( + appletClient: AppAgentClient, + roleName: RoleName, + integrityZomeName: ZomeName, + entryType: string, + wal: WAL + ): Promise => { + if (entryType == "deliberation") { let dnaHash = await getMyDna(ROLE_NAME, appletClient) + let deliberation: Deliberation; + let record: any; + + try { + record = await appletClient.callZome({ + cap_secret: null, + role_name: 'converge', + zome_name: 'converge', + fn_name: 'get_deliberation', + payload: wal.hrl[1], + }); + if (record) { + deliberation = decode((record.entry as any).Present.entry) as Deliberation; + } + } catch (e) { + console.log(e) + } + + return { + icon_src: `data:image/svg+xml;utf8,${ICON2}`, + name: "Deliberation: " + deliberation.title, + }; + } else if (entryType == "proposal") { + let proposal: any; + let record: any; try { - const records = await appletClient.callZome({ + record = await appletClient.callZome({ cap_secret: null, role_name: 'converge', zome_name: 'converge', - fn_name: 'search_all_deliberations', - payload: searchFilter, + fn_name: 'get_proposal', + payload: wal.hrl[1], }); - hashes = records - .map((r) => ({ hrl: [dnaHash, r], context: {} })); + if (record) { + proposal = decode((record.entry as any).Present.entry) as Proposal; + } } catch (e) { console.log(e) } - return hashes - }, + + return { + icon_src: `data:image/svg+xml;utf8,${ICON2}`, + name: "Proposal: " + proposal.title, + }; + } else { + throw new Error("unknown entry type:"+ entryType) + } + }, + search: async ( + appletClient: AppAgentClient, + appletHash: AppletHash, + weServices: WeServices, + searchFilter: string + ): Promise> => { + let hashes: WAL[]; + let dnaHash = await getMyDna(ROLE_NAME, appletClient) + + try { + const records = await appletClient.callZome({ + cap_secret: null, + role_name: 'converge', + zome_name: 'converge', + fn_name: 'search_all_deliberations', + payload: searchFilter, + }); + hashes = records + .map((r) => ({ hrl: [dnaHash, r], context: {} })); + } catch (e) { + console.log(e) + } + return hashes + }, + // attachmentTypes: async ( + // appletClient: AppAgentClient, + // appletHash: AppletHash, + // weServices: WeServices + // ) => ({ + // // No way to specify the context so we can't create a board. + // deliberation: { + // label: "Deliberation", + // icon_src: CARD_ICON_SRC, + // async create(attachToHrlWithContext: HrlWithContext) { + // const hrlB64 = hrlWithContextToB64(attachToHrlWithContext) + // const dnaHash = await getMyDna(ROLE_NAME, appletClient) + // console.log("context", attachToHrlWithContext) + + // // const deliberationEntry: Deliberation = { + // // title: attachToHrlWithContext.context.title!, + // // description: attachToHrlWithContext.context.description!, + // // settings: JSON.stringify(attachToHrlWithContext.context.settings!), + // // attachments: [hrlB64] + // // }; + + // const deliberationEntry: Deliberation = { + // title: "Deliberation", + // description: "", + // settings: "", + // attachments: [{ + // hrl: JSON.stringify(hrlB64.hrl), + // context: JSON.stringify("attachToHrlWithContext.context") + // }] + // }; + + // console.log("createDeliberation", deliberationEntry) + // let record; + + // try { + // record = await appletClient.callZome({ + // cap_secret: null, + // role_name: 'converge', + // zome_name: 'converge', + // fn_name: 'create_deliberation', + // payload: deliberationEntry, + // }); + + // // join deliberation + // await appletClient.callZome({ + // cap_secret: null, + // role_name: 'converge', + // zome_name: 'converge', + // fn_name: 'add_deliberation_for_deliberator', + // payload: { + // base_deliberator: appletClient.myPubKey, + // target_deliberation_hash: record.signed_action.hashed.hash + // }, + // }); + // } catch (e) { + // console.log(e) + // } + + // console.log("hash", record.signed_action.hashed.hash) + + // return { + // hrl: [dnaHash, record.signed_action.hashed.hash], + // }; + // }, + // }, + // }), }; \ No newline at end of file diff --git a/we_dev/config.ts b/we_dev/config.ts new file mode 100644 index 0000000..fe839b2 --- /dev/null +++ b/we_dev/config.ts @@ -0,0 +1,98 @@ +import { defineConfig } from '@lightningrodlabs/we-dev-cli'; + +export default defineConfig({ + groups: [ + { + name: 'Lightning Rod Labs', + networkSeed: '098rc1m-09384u-crm-29384u-cmkj', + icon: { + type: 'filesystem', + path: './we_dev/lrl-icon.png', + }, + creatingAgent: { + agentIdx: 1, + agentProfile: { + nickname: 'Zippy', + avatar: { + type: 'filesystem', + path: './we_dev/zippy.jpg', + }, + }, + }, + joiningAgents: [ + { + agentIdx: 2, + agentProfile: { + nickname: 'Zerbina', + avatar: { + type: 'filesystem', + path: './we_dev/zerbina.jpg', + }, + }, + }, + ], + applets: [ + { + name: 'Converge', + instanceName: 'Converge', + registeringAgent: 1, + joiningAgents: [2], + }, + { + name: 'gamez', + instanceName: 'gamez', + registeringAgent: 1, + joiningAgents: [2], + }, + { + name: 'talking-stickies', + instanceName: 'talking-stickies', + registeringAgent: 1, + joiningAgents: [2], + }, + ], + }, + ], + applets: [ + { + name: 'Converge', + subtitle: 'Converge', + description: '---', + icon: { + type: 'filesystem', + path: './we_dev/converge.svg', + }, + source: { + type: 'localhost', + happPath: './workdir/converge.happ', + uiPort: 8888, + }, + }, + { + name: 'gamez', + subtitle: 'play!', + description: 'Real-time games based on syn', + icon: { + type: "https", + url: "https://raw.githubusercontent.com/holochain-apps/gamez/main/we_dev/gamez_icon.svg" + }, + source: { + type: "https", + url: "https://github.com/holochain-apps/gamez/releases/download/v0.4.2/gamez.webhapp" + }, + }, + { + name: 'talking-stickies', + subtitle: 'talking stickies', + description: 'Real-time stickies based on syn', + icon: { + type: 'https', + url: 'https://raw.githubusercontent.com/holochain-apps/talking-stickies/main/we_dev/talking-stickies_icon.png', + }, + source: { + type: 'https', + url: 'https://github.com/holochain-apps/talking-stickies/releases/download/v0.9.1/talking-stickies.webhapp', + }, + }, + ], +}); \ No newline at end of file