Skip to content

Commit

Permalink
improvements to UI/UX
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed May 5, 2024
1 parent 65740b3 commit e6ae7cd
Show file tree
Hide file tree
Showing 49 changed files with 2,056 additions and 1,379 deletions.
1,196 changes: 491 additions & 705 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ members = ["dnas/*/zomes/coordinator/*", "dnas/*/zomes/integrity/*"]
resolver = "2"

[workspace.dependencies]
hdi = "0.3.1"
hdk = "0.2.1"
hdi = "0.4.0-beta-dev.30"
hdk = "0.3.0-beta-dev.34"
serde = "1"

zome_utils = { git = "https://github.com/ddd-mtl/zome-utils", branch = "hdk-3.0" }

[workspace.dependencies.coordinator]
path = "dnas/whosin/zomes/coordinator/coordinator"

Expand All @@ -27,7 +29,7 @@ path = "dnas/whosin/zomes/coordinator/notifications"
path = "dnas/whosin/zomes/integrity/notifications"

[workspace.dependencies.profiles]
path = "dnas/whosin/zomes/coordinator/profiles"
path = "dnas/converge/zomes/coordinator/profiles"

[workspace.dependencies.profiles_integrity]
path = "dnas/whosin/zomes/integrity/profiles"
path = "dnas/converge/zomes/integrity/profiles"
2 changes: 2 additions & 0 deletions dnas/whosin/zomes/coordinator/coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ hdk = { workspace = true }
serde = { workspace = true }

coordinator_integrity = { workspace = true }

zome_utils.workspace = true
14 changes: 12 additions & 2 deletions dnas/whosin/zomes/coordinator/coordinator/src/all_coordinations.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
use hdk::prelude::*;
use coordinator_integrity::*;
use zome_utils::*;

#[hdk_extern]
pub fn get_all_coordinations(_: ()) -> ExternResult<Vec<Record>> {
let path = Path::from("all_coordinations");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllCoordinations, None)?;
let links = get_links(
link_input(
path.path_entry_hash()?, LinkTypes::AllCoordinations, None
)
)?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -20,7 +26,11 @@ pub fn get_all_coordinations(_: ()) -> ExternResult<Vec<Record>> {
#[hdk_extern]
pub fn search_all_coordinations(query: String) -> ExternResult<Vec<ActionHash>> {
let path = Path::from("all_coordinations");
let links = get_links(path.path_entry_hash()?, LinkTypes::AllCoordinations, None)?;
let links = get_links(
link_input(
path.path_entry_hash()?, LinkTypes::AllCoordinations, None)
)
?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand Down
18 changes: 16 additions & 2 deletions dnas/whosin/zomes/coordinator/coordinator/src/coordination.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hdk::prelude::*;
use coordinator_integrity::*;

#[derive(Serialize, Deserialize, Debug)]
pub struct CreateCoordroleInput {
coordrole: Coordrole,
Expand All @@ -9,7 +10,9 @@ pub struct CreateCoordroleInput {
pub struct CreateCoordinationInput {
title: String,
description: String,
happening_date: Option<Timestamp>,
coordination_type: String,
starts_date: Option<Timestamp>,
ends_date: Option<Timestamp>,
reminder_date: Option<Timestamp>,
signup_deadline: Option<Timestamp>,
coordroles: Vec<Coordrole>,
Expand All @@ -30,10 +33,21 @@ pub fn create_coordination(input: CreateCoordinationInput) -> ExternResult<Recor
let coordrole_hash = create_entry(&EntryTypes::Coordrole(role.clone()))?;
coordrole_hashes.push(coordrole_hash);
}

// coordiation_type_enum is a CoordinationType enum from a input.coordination_type which is a string
let coordination_type_enum: CoordinationType = match input.coordination_type.as_str() {
"event" => CoordinationType::Event,
"project" => CoordinationType::Project,
"agreement" => CoordinationType::Agreement,
_ => CoordinationType::Event,
};

let coordination: Coordination = Coordination {
title: input.title,
description: input.description,
happening_date: input.happening_date,
coordination_type: coordination_type_enum,
starts_date: input.starts_date,
ends_date: input.ends_date,
reminder_date: input.reminder_date,
signup_deadline: input.signup_deadline,
coordroles: coordrole_hashes.clone(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use coordinator_integrity::*;
use zome_utils::*;

#[derive(Serialize, Deserialize, Debug)]
pub struct AddCoordroleForCoordinationInput {
coordination_hash: ActionHash,
Expand Down Expand Up @@ -36,7 +38,11 @@ pub fn get_coordroles_for_coordination(
// _:(),
// ) -> ExternResult<()> {
) -> ExternResult<Vec<CoordrolesOutput>> {
let links = get_links(coordination_hash, LinkTypes::CoordinationToCoordroles, None)?;
let links = get_links(
link_input(
coordination_hash, LinkTypes::CoordinationToCoordroles, None
)
)?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -57,9 +63,11 @@ pub fn get_coordroles_for_coordination(
)
.into();
let user_links = get_links(
coordrole_hash,
LinkTypes::CoordroleToParticipants,
None,
link_input(
coordrole_hash,
LinkTypes::CoordroleToParticipants,
None,
)
)?;
let agents: Vec<AgentPubKey> = user_links
.into_iter()
Expand All @@ -83,7 +91,11 @@ pub fn get_coordroles_for_coordination(
pub fn get_coordinations_for_coordrole(
coordrole_hash: ActionHash,
) -> ExternResult<Vec<Record>> {
let links = get_links(coordrole_hash, LinkTypes::CoordroleToCoordinations, None)?;
let links = get_links(
link_input(
coordrole_hash, LinkTypes::CoordroleToCoordinations, None
)
)?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -102,13 +114,21 @@ pub fn get_coordinations_for_coordrole(
#[hdk_extern]
pub fn get_my_coordinations(_: ()) -> ExternResult<Vec<Record>> {
let my_agent_pub_key = agent_info()?.agent_latest_pubkey;
let links = get_links(my_agent_pub_key, LinkTypes::ParticipantToCoordroles, None)?;
let links = get_links(
link_input(
my_agent_pub_key, LinkTypes::ParticipantToCoordroles, None
)
)?;
let coordinations: Vec<GetInput> = links
.into_iter()
.filter_map(|link| {
// let hash = ActionHash::from(link.target);
let hash = ActionHash::try_from(link.target).map_err(|_| wasm_error!(WasmErrorInner::Guest("Expected actionhash".into()))).unwrap();
let links2 = get_links(hash, LinkTypes::CoordroleToCoordinations, None)
let links2 = get_links(
link_input(
hash, LinkTypes::CoordroleToCoordinations, None
)
)
.ok()?;
let link2 = &links2.get(0)?;
Some(
Expand All @@ -132,14 +152,21 @@ pub fn get_my_coordinations(_: ()) -> ExternResult<Vec<Record>> {
#[hdk_extern]
pub fn get_my_coordination_hashes(_: ()) -> ExternResult<Vec<ActionHash>> {
let my_agent_pub_key = agent_info()?.agent_latest_pubkey;
let links = get_links(my_agent_pub_key, LinkTypes::ParticipantToCoordroles, None)?;
let links = get_links(
link_input(
my_agent_pub_key, LinkTypes::ParticipantToCoordroles, None
)
)?;
let coordinations: Vec<ActionHash> = links
.into_iter()
.filter_map(|link| {
// let hash = ActionHash::from(link.target);
let hash = ActionHash::try_from(link.target).map_err(|_| wasm_error!(WasmErrorInner::Guest("Expected actionhash".into()))).unwrap();
let links2 = get_links(hash, LinkTypes::CoordroleToCoordinations, None)
.ok()?;
let links2 = get_links(
link_input(
hash, LinkTypes::CoordroleToCoordinations, None
)
).ok()?;
let link2 = &links2.get(0)?;
Some(
// ActionHash::from(link2.target.clone())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use hdk::prelude::*;
use coordinator_integrity::*;
use zome_utils::*;
#[hdk_extern]
pub fn add_spam_reporter_for_coordination(
coordination_hash: ActionHash,
Expand All @@ -24,9 +25,11 @@ pub fn get_spam_reporters_for_coordination(
coordination_hash: ActionHash,
) -> ExternResult<Vec<AgentPubKey>> {
let links = get_links(
coordination_hash,
LinkTypes::CoordinationToSpamReporters,
None,
link_input(
coordination_hash,
LinkTypes::CoordinationToSpamReporters,
None,
)
)?;
let agents: Vec<AgentPubKey> = links
.into_iter()
Expand All @@ -44,7 +47,11 @@ pub fn get_spam_reporters_for_coordination(
pub fn get_coordinations_for_spam_reporter(
spam_reporter: AgentPubKey,
) -> ExternResult<Vec<Record>> {
let links = get_links(spam_reporter, LinkTypes::SpamReporterToCoordinations, None)?;
let links = get_links(
link_input(
spam_reporter, LinkTypes::SpamReporterToCoordinations, None
)
)?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -65,19 +72,23 @@ pub fn remove_spam_reporter_for_coordination(
) -> ExternResult<()> {
let spam_reporter: AgentPubKey = agent_info()?.agent_latest_pubkey.into();
let links = get_links(
coordination_hash.clone(),
LinkTypes::CoordinationToSpamReporters,
None,
link_input(
coordination_hash.clone(),
LinkTypes::CoordinationToSpamReporters,
None,
)
)?;
for link in links {
if AgentPubKey::from(EntryHash::try_from(link.target.clone()).map_err(|_| wasm_error!(WasmErrorInner::Guest("Expected entryhash".into()))).unwrap()).eq(&spam_reporter) {
delete_link(link.create_link_hash)?;
}
}
let links = get_links(
spam_reporter.clone(),
LinkTypes::SpamReporterToCoordinations,
None,
link_input(
spam_reporter.clone(),
LinkTypes::SpamReporterToCoordinations,
None,
)
)?;
for link in links {
if ActionHash::try_from(link.target.clone()).map_err(|_| wasm_error!(WasmErrorInner::Guest("Expected actionhash".into()))).unwrap().eq(&coordination_hash) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hdk::prelude::*;
use hdk::{hdi::link, prelude::*};
use coordinator_integrity::*;
use zome_utils::*;

#[hdk_extern]
pub fn add_sponsor_for_coordination(coordination_hash: ActionHash) -> ExternResult<()> {
let sponsor: AgentPubKey = agent_info()?.agent_latest_pubkey.into();
Expand All @@ -21,7 +23,11 @@ pub fn add_sponsor_for_coordination(coordination_hash: ActionHash) -> ExternResu
pub fn get_sponsors_for_coordination(
coordination_hash: ActionHash,
) -> ExternResult<Vec<AgentPubKey>> {
let links = get_links(coordination_hash, LinkTypes::CoordinationToSponsors, None)?;
let links = get_links(
link_input(
coordination_hash, LinkTypes::CoordinationToSponsors, None
)
)?;
let agents: Vec<AgentPubKey> = links
.into_iter()
.map(|link| AgentPubKey::from(EntryHash::try_from(link.target).map_err(|_| wasm_error!(WasmErrorInner::Guest("Expected entryhash".into()))).unwrap()))
Expand All @@ -36,7 +42,11 @@ pub fn get_sponsors_for_coordination(
}
#[hdk_extern]
pub fn get_coordinations_for_sponsor(sponsor: AgentPubKey) -> ExternResult<Vec<Record>> {
let links = get_links(sponsor, LinkTypes::SponsorToCoordinations, None)?;
let links = get_links(
link_input(
sponsor, LinkTypes::SponsorToCoordinations, None
)
)?;
let get_input: Vec<GetInput> = links
.into_iter()
.map(|link| GetInput::new(
Expand All @@ -58,9 +68,11 @@ pub fn remove_sponsor_for_coordination(
) -> ExternResult<()> {
let sponsor: AgentPubKey = agent_info()?.agent_latest_pubkey.into();
let links = get_links(
coordination_hash.clone(),
LinkTypes::CoordinationToSponsors,
None,
link_input(
coordination_hash.clone(),
LinkTypes::CoordinationToSponsors,
None,
)
)?;
for link in links {
if AgentPubKey::from(EntryHash::try_from(link.target).map_err(|_| wasm_error!(WasmErrorInner::Guest("Expected entryhash".into()))).unwrap())
Expand All @@ -69,7 +81,11 @@ pub fn remove_sponsor_for_coordination(
delete_link(link.create_link_hash)?;
}
}
let links = get_links(sponsor.clone(), LinkTypes::SponsorToCoordinations, None)?;
let links = get_links(
link_input(
sponsor.clone(), LinkTypes::SponsorToCoordinations, None
)
)?;
for link in links {
if ActionHash::try_from(link.target.clone()).map_err(|_| wasm_error!(WasmErrorInner::Guest("Expected actionhash".into()))).unwrap().eq(&coordination_hash) {
delete_link(link.create_link_hash)?;
Expand Down
Loading

0 comments on commit e6ae7cd

Please sign in to comment.