NEAR-DevHub / neardevhub-contract

DevHub Portal Product Contract (Hosted on NEAR Blockchain) – Includes other instances (e.g. Infrastructure, Events)
https://neardevhub.org
19 stars 15 forks source link

Feature/253 introduce community add ons #61

Closed Tguntenaar closed 1 year ago

Tguntenaar commented 1 year ago

Resolves #253

The following structs have been added: schema

Acceptence Criteria (not all AC apply to the smart contract side)

I tested the migration with the following transactions: From V7 to V8 V8 to 'done'

Tguntenaar commented 1 year ago

@ailisp , I discussed with elliot that the function to delete available addons were out of scope. Removing an addon from a community tab is possible. Let me know what you think!

Tguntenaar commented 1 year ago

Hi @frol, since @ailisp is OOO. Could you review this PR? It's vital to continue the Community Plugins MVP milestone.

petersalomonsen commented 1 year ago

would it be better to use a LookupMap for the community plugin configuration data? That way it would be possible to look up the config for the plugin in view, and also not make the community config object potentially very large.

elliotBraem commented 1 year ago

@petersalomonsen

Can you demonstrate? Is this is to replace parameters JSON string?

petersalomonsen commented 1 year ago

yeah I was thinking that pub addon_list: Vec<CommunityAddOnConfig> could just be a list of strings, an those strings represent the keys in a LookupMap<String,CommunityAddonConfig> so that each config has a separate entry in the NEAR key/value storage. I believe this will scale better with multiple addons, or addons with larger config objects.

Tguntenaar commented 1 year ago

I updated the contract to use a LookupMap instead. Thanks @petersalomonsen for the review. New contract deployed here: https://explorer.testnet.near.org/transactions/DEu1TwCZM2fBbpqWZxZBL62ik6et7bCC9DeRbaMD4sdh

Tguntenaar commented 1 year ago

@ailisp could you review these contract changes?

elliotBraem commented 1 year ago

@frol, @petersalomonsen, Based on the comments + discussion above, here's a diagram of the contract changes that @Tguntenaar and I have decided on implementing, and the way it is reflected on the UI:

image

Changes

  1. We've renamed "name" to "display_name".
  2. Community Struct now holds "addons" and "configs". @frol
    • Addons is a Vector and largely dictates the tabs themselves (the order, enable/disable, display_name... these can be configured from the Community page since it dictates its interaction with it. It holds a reference to a CommunityConfig via config_id.
    • Configs is a LookupMap<(CommunityHandle, CommunityConfigId), CommunityConfig>, which is accessed when a tab is selected via community.configs[config_id] @petersalomonsen
  3. We pass the addon_id and the config to the "Addon" that renders, which can either be of TemplateType "viewer" or "configurator". The addon only has accessed to the parameters and any information that the Addon itself provides. @ori-near , see diagram for how the order, tab name, icon, etc. of an addon can be modified via Community, but the parameters for something like the Kanban board, would be configured within the tab itself through the Addon's configurator view.

The goal was to keep it as modular as possible and with a separation of duties; This way, I think we could also implement permissions control for individual addon configs? And maybe more, I think this pattern could be generalized and used for more structures similar to communities. @carina-akaia @ailisp @jaswinder6991

Here you can test a dummy example :

Check out the Screams and Whispers of Vlad's Haunted Hack House!

petersalomonsen commented 1 year ago

I think this looks great!

Just wondering when referencing community.configs[addon_id]. Is then addon_id unique for the community? We don't want other communities to get the same config if using the same addon as another community. Or have I missed something?

elliotBraem commented 1 year ago

Lol sorry, there are a lot of moving parts and it's hard to keep the naming straight! You are correct, in the diagram, this should not be addon_id, but rather "config_id", where config_id is unique to the community via the Tuple: LookupMap<(CommunityHandle, CommunityAddOnConfigId), CommunityAddOnConfig> as suggested by @frol

I have updated the original post

Tguntenaar commented 1 year ago

Thank you everyone for the comments and review points. I deployed the latest version on thomaselliot.testnet

Tguntenaar commented 1 year ago

@frol one more try! :)