From 23d1144a28ae8cba9ff0269d515e8175e999f452 Mon Sep 17 00:00:00 2001 From: Eric Harris-Braun Date: Wed, 3 Jan 2024 11:47:51 -0500 Subject: [PATCH] added edit unit and moved reparenting there --- dnas/how/zomes/coordinator/how/src/unit.rs | 100 ++++-- tests/src/index.ts | 4 +- ui/src/elements/how-controller.ts | 90 ++--- ui/src/elements/how-unit-details.ts | 2 +- ui/src/elements/how-unit-dialog-edit.ts | 373 +++++++++++++++++++++ ui/src/elements/how-unit-dialog.ts | 23 +- ui/src/elements/how-unit.ts | 8 +- ui/src/elements/svg-button.ts | 80 +---- ui/src/elements/svg-icons.ts | 79 +++++ ui/src/how.service.ts | 20 +- ui/src/how.store.ts | 10 +- ui/src/initHolochain.ts | 64 ++-- ui/src/initSimple.ts | 26 +- ui/src/types.ts | 6 + 14 files changed, 630 insertions(+), 255 deletions(-) create mode 100644 ui/src/elements/how-unit-dialog-edit.ts create mode 100644 ui/src/elements/svg-icons.ts diff --git a/dnas/how/zomes/coordinator/how/src/unit.rs b/dnas/how/zomes/coordinator/how/src/unit.rs index 671e553..5048485 100644 --- a/dnas/how/zomes/coordinator/how/src/unit.rs +++ b/dnas/how/zomes/coordinator/how/src/unit.rs @@ -9,7 +9,7 @@ use how_integrity::{Unit, EntryTypes, LinkTypes}; use crate::document::{update_document, UpdateDocumentInput, _update_document}; use crate::error::*; //use crate::signals::*; -use crate::tree::{UnitInfo, _get_tree, tree_path, _get_path_tree, tree_path_to_str}; +use crate::tree::{UnitInfo, _get_tree, tree_path, _get_path_tree, tree_path_to_str, PathContent, Node}; pub fn get_units_path() -> Path { Path::from("units") @@ -198,62 +198,96 @@ pub fn advance_state(input: AdvanceStateInput) -> ExternResult { return Ok(new_doc_hash); } +pub fn reparent_node(node: Node, from: String, to: String)-> ExternResult<()> { + let units = node.val.units.clone(); + let current_path = node.val.path;//.clone(); + for unit in units { + let documents: Vec> = node.val.documents.clone(); + + let (new_unit_output, new_unit) = reparent_unit(&unit, from.clone(), to.clone())?; + for doc in documents { + reparent_document(unit.hash.clone(), new_unit_output.info.hash.clone(), &new_unit, doc, current_path.clone(), to.clone())?; + } + } + Ok(()) +} #[derive(Clone, Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] -pub struct ReparentInput { - pub path: String, - pub new_parent: String, +pub struct UpdateUnitInput { + pub hash: EntryHash, + pub state: String, + pub unit: Unit, } #[hdk_extern] -pub fn reparent(input: ReparentInput) -> ExternResult<()> { - if input.new_parent.starts_with(&input.path) { - return Err(wasm_error!(WasmErrorInner::Guest(String::from("Can't reparent to child")))); +pub fn update_unit(input: UpdateUnitInput) -> ExternResult { + let record = get(input.hash.clone(), GetOptions::default())? + .ok_or(wasm_error!(WasmErrorInner::Guest(String::from("Unit not found"))))?; + let old_action_hash = record.action_address().clone(); + let old_unit: Unit = record + .entry() + .to_app_option().map_err(|err| wasm_error!(err))? + .ok_or(wasm_error!(WasmErrorInner::Guest(String::from("Malformed unit"))))?; + + let old_tree_paths = old_unit.tree_paths(); + let new_unit_output = _update_unit(input.hash.clone(), old_action_hash, old_tree_paths.clone(), &input.unit, &input.state)?; + + let old_path = old_unit.path_str()?; + let new_path = input.unit.path_str()?; + let new_parent = input.unit.parents[0].clone(); + let sub_tree = _get_path_tree(old_tree_paths[0].clone())?; + let root = sub_tree.tree[0].clone(); + for doc in root.val.documents { + reparent_document(input.hash.clone(), new_unit_output.info.hash.clone(), &input.unit, doc, old_path.clone(), new_parent.clone())?; } - let sub_tree = _get_path_tree(tree_path(input.path.clone()))?; - let mut parent:Vec<_> = input.path.split(".").into_iter().collect(); - parent.pop(); - let parent = parent.join("."); - for node in sub_tree.tree { - let units = node.val.units.clone(); - let current_path = node.val.path;//.clone(); - for unit in units { - let documents: Vec> = node.val.documents.clone(); - - let (new_unit_hash, new_unit) = reparent_unit(&unit, parent.clone(), input.new_parent.clone())?; - for doc in documents { - reparent_document(unit.hash.clone(), new_unit_hash.clone(), &new_unit, doc, current_path.clone(), input.new_parent.clone())?; - } + let reparenting = new_path != old_path || old_unit.path_abbreviation != input.unit.path_abbreviation; + + if reparenting && sub_tree.tree.len() > 1 { + for node in sub_tree.tree.into_iter().skip(1) { + reparent_node(node, old_path.clone(), new_path.clone())?; } - } - Ok(()) + }; + Ok(new_unit_output) } -pub fn update_unit(hash: ActionHash, unit: &Unit) -> ExternResult { - let _action_hash = update_entry(hash, unit)?; - let hash = hash_entry(unit)?; - Ok(hash) +pub fn _update_unit(hash: EntryHash, action_hash: ActionHash, paths: Vec, new_unit: &Unit, state: &str) -> ExternResult { + delete_unit_links(hash.clone(), paths)?; + let new_action_hash = update_entry(action_hash, new_unit)?; + let new_unit_hash = hash_entry(new_unit)?; + create_unit_links(new_unit_hash.clone(), new_unit.tree_paths(), state, &new_unit.version, new_unit.flags_str())?; + let maybe_record = get(new_action_hash, GetOptions::default())?; + let record = maybe_record.ok_or(wasm_error!(WasmErrorInner::Guest(String::from( + "Could not get the record created just now" + ))))?; + + Ok(UnitOutput { + info: UnitInfo { + hash: new_unit_hash, + state: state.into(), + version: new_unit.version.clone(), + flags: String::from(new_unit.flags_str()), + }, + record, + }) } -pub fn reparent_unit(unit_info: &UnitInfo, from: String, to: String) -> ExternResult<(EntryHash, Unit)> { +pub fn reparent_unit(unit_info: &UnitInfo, from: String, to: String) -> ExternResult<(UnitOutput, Unit)> { let record = get(unit_info.hash.clone(), GetOptions::default())? .ok_or(wasm_error!(WasmErrorInner::Guest(String::from("Unit not found"))))?; let mut unit: Unit = record .entry() .to_app_option().map_err(|err| wasm_error!(err))? .ok_or(wasm_error!(WasmErrorInner::Guest(String::from("Malformed unit"))))?; - delete_unit_links(unit_info.hash.clone(), unit.tree_paths())?; - + let old_paths = unit.tree_paths(); if let Some(idx) = unit.parents.clone().into_iter().position(|p| { p.starts_with(&from)} ) { unit.parents[idx] = unit.parents[idx].replacen(&from, &to,1); } - let new_unit_hash = update_unit(record.action_address().clone(), &unit)?; - create_unit_links(new_unit_hash.clone(), unit.tree_paths(), &unit_info.state, &unit_info.version, unit.flags_str())?; + let unit_output = _update_unit(unit_info.hash.clone(),record.action_address().clone(), old_paths, &unit, &unit_info.state)?; - Ok((new_unit_hash,unit)) + Ok((unit_output,unit)) } pub fn reparent_document(old_unit_hash: EntryHash, new_unit_hash: EntryHash, new_unit: &Unit, hash: EntryHash, old_path:String, new_parent: String) -> ExternResult<()> { diff --git a/tests/src/index.ts b/tests/src/index.ts index 8e828bf..9bf2613 100644 --- a/tests/src/index.ts +++ b/tests/src/index.ts @@ -32,7 +32,7 @@ try { let rootUnit = { parents: [], // full paths to parent nodes (remember it's a DAG) shortName: "Holochain Community Standards", - version: "vidx0", + version: "vidx:0", pathAbbreviation: "", // max 10 char stewards: [], // people who can change this document processes: [["soc_proto.procs.define","petition"]], // state-machine definition @@ -79,7 +79,7 @@ try { let unit1 = { parents: ["hc_system.conductor.api"], // full paths to parent nodes (remember it's a DAG) shortName: "app API", - version: "vidx1", + version: "vidx:1", pathAbbreviation: "app", // max 10 char stewards: [], // people who can change this document processes: [["soc_proto.procs.define","petition"]], // state-machine definition diff --git a/ui/src/elements/how-controller.ts b/ui/src/elements/how-controller.ts index 0e0b914..82fac7a 100644 --- a/ui/src/elements/how-controller.ts +++ b/ui/src/elements/how-controller.ts @@ -11,6 +11,7 @@ import { HowTree } from "./how-tree"; import { initialTreeHolochain } from "../initHolochain"; import { initialTreeSimple } from "../initSimple"; import { HowUnitDialog } from "./how-unit-dialog"; +import { HowUnitDialogEdit } from "./how-unit-dialog-edit"; import { ScopedElementsMixin } from "@open-wc/scoped-elements"; import {HowDocument } from "./how-document"; import { AsyncReadable, AsyncStatus, StoreSubscriber } from '@holochain-open-dev/stores'; @@ -91,6 +92,11 @@ export class HowController extends ScopedElementsMixin(LitElement) { @query('#units-menu') private _unitsMenu!: SlDropdown; + @query('#unit-dialog') + private _unitDialogElem!: HowUnitDialog; + @query('#unit-dialog-edit') + private _editUnitDialogElem!: HowUnitDialogEdit; + @state() _currentUnitEh = ""; @state() _currentDocumentEh = ""; @state() _documentReadOnly = false; @@ -186,14 +192,6 @@ export class HowController extends ScopedElementsMixin(LitElement) { return this.shadowRoot!.getElementById("how-unit") as HowUnit; } - async openUnitDialog(parent?: any) { - this.unitDialogElem.open(parent); - } - - get unitDialogElem() : HowUnitDialog { - return this.shadowRoot!.getElementById("unit-dialog") as HowUnitDialog; - } - private async handleUnitSelect(unitEh: EntryHashB64): Promise { if (this._units.value[unitEh]) { this._currentUnitEh = unitEh; @@ -226,8 +224,13 @@ export class HowController extends ScopedElementsMixin(LitElement) { } handleAddChild(event: any) { + const parentEh = event.detail + this._unitDialogElem.open(parentEh) + } + + handleEditUnit(event: any) { const unitEh = event.detail - this.openUnitDialog(unitEh) + this._editUnitDialogElem.open(unitEh) } private isTreeType() : boolean { @@ -247,6 +250,8 @@ export class HowController extends ScopedElementsMixin(LitElement) { } async handleUnitUpdated(e:any) { await this._store.pullTree() + await this._store.pullUnits() + } selectDocumentVersion(hash: EntryHashB64, readOnly: boolean) { this._currentDocumentEh = hash @@ -350,23 +355,6 @@ export class HowController extends ScopedElementsMixin(LitElement) { } } - async doReparent() { - if (this._reparentingToUnitHash) { - const newParent = this._units.value[this._reparentingToUnitHash].path() - const path = this._units.value[this._currentUnitEh].path() - console.log("Move ", path, "->", newParent) - await this._store.reparent(path, newParent) - } - // cleanup - this._reparentDialog.hide() - this._reparentingToUnitHash = undefined - } - - async handleReparent(event: any) { - await this._store.pullUnits() - this._reparentDialog.show() - } - async doExport() { const rawTree = await this._store.pullTree() await this.pullAllDocs("", rawTree) @@ -538,7 +526,7 @@ export class HowController extends ScopedElementsMixin(LitElement) { @select-document=${(e:any)=>this.selectDocumentVersion(e.detail.hash, e.detail.readOnly)} @select-node=${(e: any)=>{const hash = this._unitsPath.value[e.detail]; this.handleUnitSelect(hash)}} @add-child=${this.handleAddChild} - @reparent=${this.handleReparent} + @edit=${this.handleEditUnit} />` const document = this._currentDocumentEh ? html`{await this.doExport()}}>Export - - ${this._currentUnitEh ? html` - - - { - e.stopPropagation() - this._unitsMenu.show() - }} - > - ${this._reparentingToUnitHash ? this._units.value[this._reparentingToUnitHash].path() : "Select new parent"} - - - this._unitsMenu.hide()} - @click=${(e:any)=>e.stopPropagation()} - @sl-select=${(e:any)=>{ - this._reparentingToUnitHash = e.detail.item.value - this._unitsMenu.hide() - }}> - ${ - Object.entries(this._units.value).filter(([_,unit])=>{ - const currentUnit = this._units.value[this._currentUnitEh] - const currentPath = currentUnit.path() - const unitPath = unit.path() - let current_path_parent = "" - if (currentUnit) { - const p = currentPath.split(".") - p.pop() - current_path_parent = p.join(".") - } - return !unitPath.startsWith(currentPath) && (unitPath != current_path_parent) - }).map(([key, unit]) => html` - - ${unit.path() == "" ? "" : unit.path()} - - `) - } - - - {await this.doReparent()}}>Do it! - - ` : ""}
@@ -618,6 +562,9 @@ export class HowController extends ScopedElementsMixin(LitElement) { {this.handleNodeSelected(e); this.refresh();}}> + +
`; @@ -634,6 +581,7 @@ export class HowController extends ScopedElementsMixin(LitElement) { "mwc-icon-button": IconButton, "mwc-button": Button, "how-unit-dialog" : HowUnitDialog, + "how-unit-dialog-edit" : HowUnitDialogEdit, "how-unit": HowUnit, "how-tree": HowTree, "how-document": HowDocument, diff --git a/ui/src/elements/how-unit-details.ts b/ui/src/elements/how-unit-details.ts index b053d0c..6a49216 100644 --- a/ui/src/elements/how-unit-details.ts +++ b/ui/src/elements/how-unit-details.ts @@ -5,7 +5,7 @@ import {sharedStyles} from "../sharedStyles"; import { consume } from '@lit/context'; import {ScopedElementsMixin} from "@open-wc/scoped-elements"; import {HowStore} from "../how.store"; -import {Unit, howContext, Dictionary, Node} from "../types"; +import {howContext} from "../types"; import { Button, Dialog, diff --git a/ui/src/elements/how-unit-dialog-edit.ts b/ui/src/elements/how-unit-dialog-edit.ts new file mode 100644 index 0000000..a62716e --- /dev/null +++ b/ui/src/elements/how-unit-dialog-edit.ts @@ -0,0 +1,373 @@ +import {css, html, LitElement} from "lit"; +import {property, query, state} from "lit/decorators.js"; + +import {sharedStyles} from "../sharedStyles"; +import {ScopedElementsMixin} from "@open-wc/scoped-elements"; +import {HowStore} from "../how.store"; +import {Unit, howContext, Dictionary, Node, VersioningType, SysState, UnitInfo} from "../types"; +import {AgentPubKeyB64, encodeHashToBase64, EntryHashB64} from "@holochain/client"; +import { + Button, + Dialog, + TextField, + TextArea, + Select, + ListItem, +} from "@scoped-elements/material-web"; +import '@holochain-open-dev/profiles/dist/elements/search-agent.js'; +import { consume } from '@lit/context'; +import { ProfilesStore, profilesStoreContext } from "@holochain-open-dev/profiles"; +import { StoreSubscriber, toPromise } from "@holochain-open-dev/stores"; +import SlDropdown from '@shoelace-style/shoelace/dist/components/dropdown/dropdown.js'; +import '@shoelace-style/shoelace/dist/components/button/button.js'; +import "@shoelace-style/shoelace/dist/components/dropdown/dropdown.js"; +import "@shoelace-style/shoelace/dist/components/menu-item/menu-item.js"; +import "@shoelace-style/shoelace/dist/components/menu/menu.js"; +import {SVG} from "./svg-icons" +import {unsafeHTML} from "lit/directives/unsafe-html.js"; +import { AgentAvatar } from "@holochain-open-dev/profiles/dist/elements/agent-avatar"; + +/** + * @element how-unit-dialog-edit + */ +export class HowUnitDialogEdit extends ScopedElementsMixin(LitElement) { + + /** Dependencies */ + @consume({ context: howContext, subscribe: true }) + _store!: HowStore; + + @consume({ context: profilesStoreContext, subscribe: true }) + _profiles!: ProfilesStore; + + @query('#name-field') + _nameField!: TextField; + + @query('#version-field') + _versionField!: TextField; + + @query('#versioning-type-select') + _versioningTypeSelect!: Select; + + @query('#title-field') + _titleField!: TextField; + + @query('#units-menu') + private _unitsMenu!: SlDropdown; + @state() _reparentingToUnitHash: EntryHashB64 | undefined + + @state() _stewards: Dictionary = {}; + + @state() _currentUnit?: Unit; + @state() _currentUnitInfo?: UnitInfo; + @state() _currentUnitEh?: EntryHashB64; + + _units = new StoreSubscriber(this, () => this._store.units); + + private static readonly NONE = 'none'; // we need a default value for the mwc-selects because if an empty string is provided, the UI gets broken + + private takenNames: Array = [] + + firstUpdated() { + this._nameField.validityTransform = (newValue: string) => { + this.requestUpdate(); + if (this.takenNames.includes(this._nameField.value)) { + this._nameField.setCustomValidity(`Path abbreviation already exists`); + return { + valid: false, + }; + } + + return { + valid: true, + }; + }; + } + + async open(currentUnitEh:EntryHashB64) { + this._currentUnitEh = currentUnitEh + this._currentUnit = this._store.unit(currentUnitEh) + + if (this._currentUnit) { + const parentPath = this.currentParentPath() + + for (const [key,unit] of Object.entries(this._units.value)) { + const unitPath = unit.path() + if (unitPath === parentPath) { + this._reparentingToUnitHash = key + break; + } + } + } + + this._currentUnitInfo = this._store.unitInfo(currentUnitEh) + if (this._currentUnit) { + const [vType,version] = this._currentUnit.version.split(":") + this._nameField.value = this._currentUnit.pathAbbreviation + this._versioningTypeSelect.value = vType + this._versionField.value = version + this._titleField.value = this._currentUnit.shortName + + const profiles = await toPromise(this._profiles.allProfiles) + Array.from(profiles.entries()).forEach(([agent, profile]) => { + this._stewards[encodeHashToBase64(agent)] = profile.entry.nickname + }); + this.requestUpdate() + const dialog = this.shadowRoot!.getElementById("unit-dialog") as Dialog + dialog.open = true + + } else { + console.log("Unit not found") + } + } + + private unitsEqual(u1: Unit, u2:Unit) : boolean { + if (u1.pathAbbreviation != u1.pathAbbreviation) return false + if (u1.path() != u2.path()) return false + if (u1.shortName != u2.shortName) return false + if (u1.version != u2.version) return false + if (u1.stewards.length != u2.stewards.length) return false + for (const s of u1.stewards) { + if (!u2.stewards.includes(s)) return false + } + return true + } + + /** + * + */ + private async handleOk(e: any) { + /** Check validity */ + if (!this._nameField.validity.valid) { + this._nameField.reportValidity() + } + + if (!this._titleField.validity.valid) { + this._titleField.reportValidity() + } + if (!this._versionField.validity.valid) { + this._versionField.reportValidity() + } + + const stewards = Object.keys(this._stewards) + if (stewards.length == 0) { + stewards.push(this._store.myAgentPubKey) + } + const unit = new Unit({ + parents: this._currentUnit?.parents, // full paths to parent nodes (remember it's a DAG) + version: `${this._versioningTypeSelect.value}:${this._versionField.value}`, // max 100 chars + pathAbbreviation: this._nameField.value, + shortName: this._titleField.value, + stewards, // people who can change this document + processes: this._currentUnit?.processes, + }); + + if (this._reparentingToUnitHash) { + const reparentPath = this._units.value[this._reparentingToUnitHash].path() + unit.parents = [reparentPath] + } + // - Add unit to commons + if (this._currentUnitEh && this._currentUnitInfo) { + + // TODO integrate reparent with update Unit. + if (this._currentUnit && !this.unitsEqual(unit, this._currentUnit)) { + const newUnitHash = await this._store.updateUnit(this._currentUnitEh, unit, this._currentUnitInfo.state); + this.dispatchEvent(new CustomEvent('unit-updated', { detail: newUnitHash, bubbles: true, composed: true })); + } + // if (this._reparentingToUnitHash) { + // const reparentPath = this._units.value[this._reparentingToUnitHash].path() + // if (reparentPath != unit.path()) { + // await this._store.reparent(unit.path(),reparentPath) + // } + // } + } + // - Clear all fields + // this.resetAllFields(); + // - Close dialog + const dialog = this.shadowRoot!.getElementById("unit-dialog") as Dialog; + dialog.close() + } + + resetAllFields() { + this._nameField.value = '' + this._titleField.value = '' + this._versionField.value = '' + this._stewards = {} + } + + private async handleDialogOpened(e: any) { + // if (false) { + // const unit = this._store.unit(this._unitToPreload); + // if (unit) { + + // } + // this._unitToPreload = undefined; + // } + // this.requestUpdate() + } + + private async handleDialogClosing(e: any) { + this.resetAllFields(); + } + + private addSteward(nickname: string, pubKey: AgentPubKeyB64) { + this._stewards[pubKey] = nickname + this._stewards = this._stewards + this.requestUpdate() + } + + private currentParentPath() { + if (this._currentUnit) { + const currentPath = this._currentUnit.path() + let curentParentPath ="" + if (currentPath) { + const p = currentPath.split(".") + p.pop() + curentParentPath = p.join(".") + } + return curentParentPath + } else { + return "" + } + } + + private filteredUnits() { + if (this._currentUnit) { + + const currentPath = this._currentUnit.path() + const currentParentPath = this.currentParentPath() + + + return Object.entries(this._units.value).filter(([_,unit])=>{ + const unitPath = unit.path() + if (unitPath === currentParentPath) return true + return !unitPath.startsWith(currentPath) && (unitPath != currentParentPath) + }) + } + return [] + } + + render() { + return html` + + + Parent: + { + e.stopPropagation() + this._unitsMenu.show() + }} + > + ${this._reparentingToUnitHash ? this._units.value[this._reparentingToUnitHash].path() : "Select new parent"} + ${unsafeHTML(SVG["chevron"])} + + + this._unitsMenu.hide()} + @click=${(e:any)=>e.stopPropagation()} + @sl-select=${(e:any)=>{ + this._reparentingToUnitHash = e.detail.item.value + this._unitsMenu.hide() + }}> + ${ + this.filteredUnits().map(([key, unit]) => html` + + ${unit.path() == "" ? "" : unit.path()} + + `) + } + + + this._nameField.reportValidity()} + id="name-field" minlength="3" maxlength="10" label="Path Abbreviation" autoValidate=true required> + + e.stopPropagation()} + > + Semantic + Indexed + + (this.shadowRoot!.getElementById("version-field") as TextField).reportValidity()} + id="version-field" minlength="1" maxlength="100" label="Version" autoValidate=true required> + + + + (this.shadowRoot!.getElementById("title-field") as TextField).reportValidity()} + id="title-field" minlength="3" maxlength="64" label="Title" autoValidate=true required> + + Stewards: ${Object.keys(this._stewards).length} ${Object.entries(this._stewards).map(([agent, nickname])=>html` +
${nickname} + { + delete this._stewards[agent] + this.requestUpdate() + }} + > +
+ `)} + e.stopPropagation()} + @agent-selected="${(e:any)=> { + const nickname = e.detail.profile.nickname + const pubKey = encodeHashToBase64(e.detail.agentPubKey) + this.addSteward(nickname, pubKey) + }}" + clear-on-select + style="margin-bottom: 16px;" + include-myself> + + ok + cancel +
+` + } + + + static get scopedElements() { + return { + "mwc-button": Button, + "mwc-dialog": Dialog, + "mwc-textfield": TextField, + "mwc-textarea": TextArea, + "mwc-select": Select, + "mwc-list-item": ListItem, + "agent-avatar": AgentAvatar, + }; + } + static get styles() { + return [ + sharedStyles, + css` + mwc-dialog div { + display: flex; + } + #unit-dialog { + --mdc-dialog-min-width: 600px; + } + mwc-textfield { + margin-top: 10px; + display: flex; + } + mwc-textarea { + margin-top: 10px; + display: flex; + } + mwc-select { + display: flex; + margin: 10px 0; + } + .ui-item { + position: absolute; + pointer-events: none; + text-align: center; + flex-shrink: 0; + } +`, + ]; + } +} diff --git a/ui/src/elements/how-unit-dialog.ts b/ui/src/elements/how-unit-dialog.ts index bdf2763..5cc4630 100644 --- a/ui/src/elements/how-unit-dialog.ts +++ b/ui/src/elements/how-unit-dialog.ts @@ -5,7 +5,7 @@ import {sharedStyles} from "../sharedStyles"; import {ScopedElementsMixin} from "@open-wc/scoped-elements"; import {HowStore} from "../how.store"; import {Unit, howContext, Dictionary, Node, VersioningType, SysState, UnitInfo} from "../types"; -import {EntryHashB64} from "@holochain/client"; +import {encodeHashToBase64, EntryHashB64} from "@holochain/client"; import { Button, Dialog, @@ -84,9 +84,11 @@ export class HowUnitDialog extends ScopedElementsMixin(LitElement) { }; }; } + open(parentEh: EntryHashB64) { this._parent = this._store.unit(parentEh); this._parentInfo = this._store.unitInfo(parentEh); + const dialog = this.shadowRoot!.getElementById("unit-dialog") as Dialog dialog.open = true } @@ -137,7 +139,7 @@ export class HowUnitDialog extends ScopedElementsMixin(LitElement) { } const unit = new Unit({ parents: [this.parentPath()], // full paths to parent nodes (remember it's a DAG) - version: `${this._versioningTypeSelect.value}${this._versionField.value}`, // max 100 chars + version: `${this._versioningTypeSelect.value}:${this._versionField.value}`, // max 100 chars pathAbbreviation: this._nameField.value, // max 10 char shortName: this._titleField.value, stewards, // people who can change this document @@ -159,9 +161,11 @@ export class HowUnitDialog extends ScopedElementsMixin(LitElement) { this._parent = undefined this._nameField.value = '' this._titleField.value = '' - this._alignProcessSelect.value = HowUnitDialog.NONE - this._defineProcessSelect.value = HowUnitDialog.NONE - this._refineProcessSelect.value = HowUnitDialog.NONE + if (this._parentInfo?.state != SysState.UnderConstruction) { + this._alignProcessSelect.value = HowUnitDialog.NONE + this._defineProcessSelect.value = HowUnitDialog.NONE + this._refineProcessSelect.value = HowUnitDialog.NONE + } this._stewards = {} } @@ -189,8 +193,8 @@ export class HowUnitDialog extends ScopedElementsMixin(LitElement) { } private addSteward(e:any) { - const nickname = e.detail.agent.profile.nickname - const pubKey = e.detail.agent.agent_pub_key + const nickname = e.detail.profile.nickname + const pubKey = encodeHashToBase64(e.detail.agentPubKey) this._stewards[pubKey] = nickname this._stewards = this._stewards this.requestUpdate() @@ -201,8 +205,9 @@ export class HowUnitDialog extends ScopedElementsMixin(LitElement) { Parent: ${this.parentPath()} (this.shadowRoot!.getElementById("name-field") as TextField).reportValidity()} - id="name-field" minlength="3" maxlength="64" label="Path Abbreviation" autoValidate=true required> + @input=${() => (this.shadowRoot!.getElementById("name-field") as TextField).reportValidity()} + id="name-field" minlength="3" maxlength="10" label="Path Abbreviation" autoValidate=true required> + this.dispatchEvent(new CustomEvent('reparent', { detail: this.currentUnitEh, bubbles: true, composed: true }))} - .info=${"reparent"} - .button=${"reparent"}> + .click=${() => this.dispatchEvent(new CustomEvent('edit', { detail: this.currentUnitEh, bubbles: true, composed: true }))} + .info=${"edit"} + .button=${"edit"}> this.confirmAdvance(this.currentUnitEh, SysState.Alive)} @@ -315,7 +315,7 @@ export class HowUnit extends ScopedElementsMixin(LitElement) {
- + - - - - - - - - -`, - plus: ``, - move: ` - - `, - question: ` - - `, - edit: ` - - - `, - close: ` - - - `, - save: ` - - - `, - defunct: ` - - - `, - checked: ` - - `, - unchecked: ` - - `, - send: ` - - `, - trash: ` - - `, - comment_new: ` - - `, - comment_approve:` - - `, - comment_reject:` - - `, - comment_edit:` - - `, - dislike:` - - `, - like: ` - - - `, - collect: `` - -} /** * @element svg-button */ diff --git a/ui/src/elements/svg-icons.ts b/ui/src/elements/svg-icons.ts new file mode 100644 index 0000000..da0f4c4 --- /dev/null +++ b/ui/src/elements/svg-icons.ts @@ -0,0 +1,79 @@ +export const SVG = { + reparent: ` + + + + + + + + + `, + plus: ``, + move: ` + + `, + question: ` + + `, + edit: ` + + + `, + close: ` + + + `, + save: ` + + + `, + defunct: ` + + + `, + checked: ` + + `, + unchecked: ` + + `, + send: ` + + `, + trash: ` + + `, + comment_new: ` + + `, + comment_approve:` + + `, + comment_reject:` + + `, + comment_edit:` + + `, + dislike:` + + `, + like: ` + + + `, + collect: ``, + chevron: `` + + } \ No newline at end of file diff --git a/ui/src/how.service.ts b/ui/src/how.service.ts index 9f6055a..f3083ed 100644 --- a/ui/src/how.service.ts +++ b/ui/src/how.service.ts @@ -1,5 +1,5 @@ -import { AppAgentClient, EntryHashB64, AgentPubKeyB64, AppAgentCallZomeRequest, RoleName, encodeHashToBase64 } from '@holochain/client'; -import { UnitInput, RustNode, RustTree, Initialization, DocumentOutput, DocumentInput, UpdateDocumentInput, AdvanceStateInput, UnitOutput, MarkDocumentInput, HowSignal} from './types'; +import { AppAgentClient, EntryHashB64, AgentPubKeyB64, AppAgentCallZomeRequest, RoleName, encodeHashToBase64, decodeHashFromBase64 } from '@holochain/client'; +import { UnitInput, RustNode, RustTree, Initialization, DocumentOutput, DocumentInput, UpdateDocumentInput, AdvanceStateInput, UnitOutput, MarkDocumentInput, HowSignal, Unit, UpdateUnitInput} from './types'; import { ActionHash } from '@holochain/client'; export class HowService { @@ -21,6 +21,16 @@ export class HowService { return this.callZome('create_unit', unit); } + async updateUnit(unitEh: AgentPubKeyB64, unit: Unit, state: string): Promise { + const input : UpdateUnitInput = { + hash: decodeHashFromBase64(unitEh), + state, + unit + } + console.log("UPDATE UNIT", input, unitEh) + return this.callZome('update_unit', input); + } + async getUnits(): Promise> { return await this.callZome('get_units', null) } @@ -53,11 +63,7 @@ export class HowService { let tree:RustTree = await this.callZome('get_tree', null); return tree.tree } - - async reparent(path: string, newParent: string): Promise { - this.callZome('reparent', {path,newParent}); - } - + async notify(signal: HowSignal, folks: Array): Promise { return this.callZome('notify', {signal, folks}); } diff --git a/ui/src/how.store.ts b/ui/src/how.store.ts index 5639081..71f4572 100644 --- a/ui/src/how.store.ts +++ b/ui/src/how.store.ts @@ -419,6 +419,12 @@ export class HowStore { return encodeHashToBase64(unitOutput.info.hash) } + async updateUnit(unitEh: EntryHashB64, unit: Unit, state: string): Promise { + const unitOutput: UnitOutput = await this.service.updateUnit(unitEh, unit, state); + this.updateUnitFromEntry(unitOutput) + return encodeHashToBase64(unitOutput.info.hash) + } + async initilize(input: Initialization) : Promise { await this.service.initialize(input) } @@ -500,10 +506,6 @@ export class HowStore { } } - async reparent(path: string, newParent: string): Promise { - this.service.reparent(path,newParent); - } - async collectionDefs(documentEh: EntryHashB64) : Promise>{ const defs: Array
= [] const path = this.getDocumentPath(documentEh) diff --git a/ui/src/initHolochain.ts b/ui/src/initHolochain.ts index 5dfc5e4..0131bfd 100644 --- a/ui/src/initHolochain.ts +++ b/ui/src/initHolochain.ts @@ -26,7 +26,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { units: [ [SysState.Alive, new Unit({ parents: [], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "", // max 10 char shortName: "Holochain Standards", // max 25 char stewards: [progenitor], // people who can change this document @@ -34,7 +34,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "social", // max 10 char shortName: "Social Protocols", // max 25 char stewards: [progenitor], // people who can change this document stewards: [progenitor], // people who can change this document @@ -42,7 +42,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "tech", // max 10 char shortName: "Technical", // max 25 char stewards: [progenitor], // people who can change this document stewards: [progenitor], // people who can change this document @@ -50,7 +50,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "hApps", // max 10 char shortName: "hApp Standards", // max 25 char stewards: [progenitor], // people who can change this document @@ -58,7 +58,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], ["define", new Unit({ parents: ["tech.hApps"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "ERC721_interop", // max 10 char shortName: "ERC721 Interoperability Standard", // max 25 char stewards: [progenitor], // people who can change this document @@ -66,7 +66,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["social"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "ops", // max 10 char shortName: "Operations", // max 25 charAgent stewards: [progenitor], // people who can change this document @@ -74,7 +74,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["social"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "biz", // max 10 char shortName: "Business, Legal, Finance, Regulatory", // max 25 charAgent stewards: [progenitor], // people who can change this document @@ -83,7 +83,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["social.biz"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "exec", // max 10 char shortName: "Executive Function/ Council", // max 25 charAgent stewards: [progenitor], // people who can change this document @@ -92,7 +92,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["social"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "dev_support", // max 10 char shortName: "Developer Engagement & Support", // max 25 charAgent stewards: [progenitor], // people who can change this document @@ -101,7 +101,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["social.ops"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "process", // max 10 char shortName: "How Processes", // max 25 charAgent stewards: [progenitor], // people who can change this document @@ -109,7 +109,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [PROCESS_ROOT], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "define", // max 10 char shortName: "Proposal procesess", // max 25 char stewards: [progenitor], // people who can change this document @@ -117,7 +117,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.define`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "declaration", // max 10 char shortName: "Declaration", // max 25 char stewards: [progenitor], // people who can change this document @@ -125,7 +125,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.define`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "petition", // max 10 char shortName: "Petition", // max 25 char stewards: [progenitor], // people who can change this document @@ -133,7 +133,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [PROCESS_ROOT], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "refine", // max 10 char shortName: "Refinement Processes", // max 25 char stewards: [progenitor], // people who can change this document @@ -141,7 +141,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.refine`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "comment_period", // max 10 char shortName: "Comment Period", // max 25 char stewards: [progenitor], // people who can change this document @@ -149,7 +149,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [PROCESS_ROOT], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "align", // max 10 char shortName: "Unit Processes", // max 25 char stewards: [progenitor], // people who can change this document @@ -157,7 +157,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.align`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "vote", // max 10 char shortName: "Voting", // max 25 char stewards: [progenitor], // people who can change this document @@ -165,7 +165,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.align`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "consensus", // max 10 char shortName: "Consensus", // max 25 char stewards: [progenitor], // people who can change this document @@ -173,7 +173,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.align`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "sortition", // max 10 char shortName: "Sortition", // max 25 char stewards: [progenitor], // people who can change this document @@ -181,7 +181,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "hc_framework", // max 10 char shortName: "Holochain Framework", // max 25 char stewards: [progenitor], // people who can change this document @@ -189,7 +189,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech.hc_framework"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "runtime", // max 10 char shortName: "Runtime Environments", // max 25 char stewards: [progenitor], // people who can change this document @@ -197,7 +197,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["tech.hc_framework.runtime"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "conductor", // max 10 char shortName: "Holochain Conductor", // max 25 char stewards: [progenitor], // people who can change this document @@ -206,7 +206,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["tech.hc_framework.runtime.conductor"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "api", // max 10 char shortName: "Holochain Conductor API", // max 25 char stewards: [progenitor], // people who can change this document @@ -215,7 +215,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["tech.hc_framework.runtime.conductor"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "services", // max 10 char shortName: "Holochain Conductor Services", // max 25 char stewards: [progenitor], // people who can change this document @@ -224,7 +224,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech.hc_framework"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "organism", // max 10 char shortName: "Network Organism", // max 25 char stewards: [progenitor], // people who can change this document @@ -232,7 +232,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech.hc_framework.organism"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "organ", // max 10 char shortName: "Network Organ", // max 25 char stewards: [progenitor], // people who can change this document @@ -240,7 +240,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["tech.hc_framework.organism"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "ui", // max 10 char shortName: "User Interface", // max 25 char stewards: [progenitor], // people who can change this document @@ -249,7 +249,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech.hc_framework.organism.organ"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "cell", // max 10 char shortName: "Cell State", // max 25 char stewards: [progenitor], // people who can change this document @@ -257,7 +257,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["tech.hc_framework.organism.organ"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "shared_viz", // max 10 char shortName: "Shared Visibility", // max 25 char stewards: [progenitor], // people who can change this document @@ -266,7 +266,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.UnderConstruction, new Unit({ parents: ["tech.hc_framework.organism.organ"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "dna", // max 10 char shortName: "DNA", // max 25 char stewards: [progenitor], // people who can change this document @@ -275,7 +275,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech.hc_framework.organism.organ.cell"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "ephemeral", // max 10 char shortName: "Ephemeral State", // max 25 char stewards: [progenitor], // people who can change this document @@ -283,7 +283,7 @@ export function initialTreeHolochain(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["tech.hc_framework.organism.organ.cell"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "immutable", // max 10 char shortName: "Immutable State", // max 25 char stewards: [progenitor], // people who can change this document diff --git a/ui/src/initSimple.ts b/ui/src/initSimple.ts index d42d182..8109924 100644 --- a/ui/src/initSimple.ts +++ b/ui/src/initSimple.ts @@ -24,7 +24,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { units: [ [SysState.Alive, new Unit({ parents: [], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "", // max 10 char shortName: "Alignments", // max 25 char stewards: [progenitor], // people who can change this document @@ -32,7 +32,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "soc_proto", // max 10 char shortName: "Social Protocols", // max 25 char stewards: [progenitor], // people who can change this document stewards: [progenitor], // people who can change this document @@ -40,7 +40,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "projects", // max 10 char shortName: "Projects", // max 25 char stewards: [progenitor], // people who can change this document @@ -48,7 +48,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: ["soc_proto"], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "process", // max 10 char shortName: "How Processes", // max 25 charAgent stewards: [progenitor], // people who can change this document @@ -56,7 +56,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [PROCESS_ROOT], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "define", // max 10 char shortName: "Proposal procesess", // max 25 char stewards: [progenitor], // people who can change this document @@ -64,7 +64,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.define`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "declaration", // max 10 char shortName: "Declaration", // max 25 char stewards: [progenitor], // people who can change this document @@ -72,7 +72,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.define`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "petition", // max 10 char shortName: "Petition", // max 25 char stewards: [progenitor], // people who can change this document @@ -80,7 +80,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [PROCESS_ROOT], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "refine", // max 10 char shortName: "Refinement Processes", // max 25 char stewards: [progenitor], // people who can change this document @@ -88,7 +88,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.refine`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "comment_period", // max 10 char shortName: "Comment Period", // max 25 char stewards: [progenitor], // people who can change this document @@ -96,7 +96,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [PROCESS_ROOT], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "align", // max 10 char shortName: "Unit Processes", // max 25 char stewards: [progenitor], // people who can change this document @@ -104,7 +104,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.align`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "vote", // max 10 char shortName: "Voting", // max 25 char stewards: [progenitor], // people who can change this document @@ -112,7 +112,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.align`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "consensus", // max 10 char shortName: "Consensus", // max 25 char stewards: [progenitor], // people who can change this document @@ -120,7 +120,7 @@ export function initialTreeSimple(progenitor: AgentPubKeyB64) { })], [SysState.Alive, new Unit({ parents: [`${PROCESS_ROOT}.align`], // full paths to parent nodes (remember it's a DAG) - version: "vidx1", + version: "vidx:1", pathAbbreviation: "sortition", // max 10 char shortName: "Sortition", // max 25 char stewards: [progenitor], // people who can change this document diff --git a/ui/src/types.ts b/ui/src/types.ts index 1e740a5..3430a13 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -308,6 +308,12 @@ export type UnitOutput = { record: Record, } +export type UpdateUnitInput = { + hash: EntryHash, + state: String, + unit: Unit, +} + export type Content = { name: string, units: Array,