Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organization system #258

Closed
riderx opened this issue Jul 27, 2023 · 47 comments
Closed

Organization system #258

riderx opened this issue Jul 27, 2023 · 47 comments

Comments

@riderx
Copy link
Contributor

riderx commented Jul 27, 2023

Instead of link app to user, we want to create org for user and link app to org.
That will allow us to give org right to more than one user.

@riderx
Copy link
Contributor Author

riderx commented Jul 27, 2023

Current status:

@riderx
Copy link
Contributor Author

riderx commented Jul 27, 2023

To do back:

  • update security rules to use new org rights - app
  • update security rules to use new org rights - app stats
  • update security rules to use new org rights - channel
  • update security rules to use new org rights - bundle
  • update security rules to use new org rights - bundle meta
  • transfer billing info from user to org
  • add security rule in new tables, org, and org rights
  • create a Postgres function to check user rights for org
  • create a Postgres function to check user rights for app
  • create a Postgres function to check user rights for channel
  • transfer apps to org
  • transfer notification from app owner to org admin

To do front:

  • Finish Figma design
  • Implement Figma
  • display org
  • allow create, delete or edit your org
  • display org users
  • allow adding delete org users
  • allow update org users right
  • add feature to add user to org
  • display org billing

@YacineMessaadi
Copy link
Contributor

@riderx
Copy link
Contributor Author

riderx commented Jul 28, 2023

@YacineMessaadi thanks for the work.
Some remarks though :

  • the current style of tabs don’t match the one in figma, i would prefer we follow the same as we have already.
  • Org will have logo as well to edit and should have the same design as current setting screen
  • I don’t see the edit user
  • Apikey need to have action: delete recreate, added
  • image in add new member don’t match the current style of the app
  • Org selector miss org logo
  • Org selector is missing the color scheme of the app, should be white on white app dark on dark app

@YacineMessaadi
Copy link
Contributor

@riderx Thanks for the review, I work on it

@YacineMessaadi
Copy link
Contributor

I have worked on the desktop version, you can check it.
The mobile version will be done tomorrow

@YacineMessaadi
Copy link
Contributor

@riderx

DONE: the current style of tabs don’t match the one in figma, i would prefer we follow the same as we have already.
DONE: Org will have logo as well to edit and should have the same design as current setting screen
DONE: I don’t see the edit user (click on three dots on an example member)
DONE: Apikey need to have action: delete recreate, added
DONE: image in add new member don’t match the current style of the app (deleted the image)
MISSING: Org selector miss org logo (I encounter a difficulty in the modification of the plugin I use for the selector but it will be done in the code)
PARTIALLY: Org selector is missing the color scheme of the app, should be white on white app dark on dark app (same reason as before)

@riderx
Copy link
Contributor Author

riderx commented Aug 1, 2023

Still missing:

  • add apikey mobile ( big plus button like for apps)
  • tabs mobile design still don't match the current design ( only icon + underline tabs)
  • copy button is not necessary since you can click the key, in apikeys
  • still no UI to edit user rights
  • replace on left panel the api keys button by organisation to access to the new pannel. ( the top selector should keep the page you are (dashboard/org setting apikey etc)

@riderx
Copy link
Contributor Author

riderx commented Aug 1, 2023

Done:

  • create a Postgres function to check user rights for org
  • create a Postgres function to check user rights for app
  • create a Postgres function to check user rights for channel

By this function :

CREATE OR REPLACE FUNCTION check_min_rights(min_right user_min_right, user_id uuid, org_id uuid, app_id varchar, channel_id bigint)
RETURNS boolean AS $$
DECLARE
    user_right_record RECORD;
BEGIN
    FOR user_right_record IN 
        SELECT org_users.user_right, org_users.app_id, org_users.channel_id 
        FROM org_users 
        WHERE org_users.org_id = check_min_rights.org_id AND org_users.user_id = check_min_rights.user_id
    LOOP
        IF (user_right_record.user_right >= min_right AND user_right_record.app_id IS NULL AND user_right_record.channel_id IS NULL) OR
           (user_right_record.user_right >= min_right AND user_right_record.app_id = check_min_rights.app_id AND user_right_record.channel_id IS NULL) OR
           (user_right_record.user_right >= min_right AND user_right_record.app_id = check_min_rights.app_id AND user_right_record.channel_id = check_min_rights.channel_id)
        THEN
            RETURN true;
        END IF;
    END LOOP;

    RETURN false;
END;
$$ LANGUAGE plpgsql;

@riderx
Copy link
Contributor Author

riderx commented Aug 3, 2023

@YacineMessaadi I think we also need views in Figma from different rights.

  • read
  • upload
  • write
  • admin
    And for different level:
  • channel
  • app
  • org

What user with this rights see is important.

@YacineMessaadi
Copy link
Contributor

  • DONE: add apikey mobile ( big plus button like for apps)
  • NEED INFO (The current design is icon + title in Capgo, should I delete the title ?) : tabs mobile design still don't match the current design ( only icon + underline tabs)
  • DONE: copy button is not necessary since you can click the key, in apikeys
  • DONE (click the three dots on the member Ivan Mesaros) : still no UI to edit user rights
  • NEED INFO (The top selector should be clickable to navigate through the pages of the org ? (settings, api keys, members) ?) : replace on left panel the api keys button by organisation to access to the new pannel. ( the top selector should keep the page you are (dashboard/org setting apikey etc)

@YacineMessaadi
Copy link
Contributor

@YacineMessaadi I think we also need views in Figma from different rights.

  • read
  • upload
  • write
  • admin
    And for different level:
  • channel
  • app
  • org

What user with this rights see is important.

@riderx
I agree, but I think it will be a waste of time to go deep in details on the Figma design.
Actually, that would take time that we had not planned on the schedule for the feature delivery

@riderx
Copy link
Contributor Author

riderx commented Aug 9, 2023

/bounty $500

@algora-pbc
Copy link

algora-pbc bot commented Aug 9, 2023

💎 $500 bounty created by riderx
🙋 If you start working on this, comment /attempt #258 to notify everyone
👉 To claim this bounty, submit a pull request that includes the text /claim #258 somewhere in its body
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
ℹ️ If something is not clear ask before working on it, otherwise your chance to rework it is high
🎥 To claim you need to provide in your PR a demo video of the change
👨‍👩‍👧‍👦 Join the Discord to get help
📏 Check all Bounty rules
🙏 Thank you for contributing to Cap-go/capgo!

Attempt Started (GMT+0) Solution
🟢 @pbkompasz Aug 9, 2023, 4:01:39 PM WIP
🔴 @neo773 Aug 28, 2023, 3:33:32 PM WIP
🟡 @WcaleNieWolny Aug 29, 2023, 10:40:27 AM #335

@pbkompasz
Copy link
Contributor

pbkompasz commented Aug 9, 2023

/attempt #258

Options

@pbkompasz
Copy link
Contributor

@riderx
Hi. I have a couple of questions:

  1. Is this the final version of the Figma draft? Will the views with different permissions be created in Figma?
  2. When I try to start the database I get migration errors, should this happen or am I missing something? Please let me know if I am missing some build steps.

@riderx
Copy link
Contributor Author

riderx commented Aug 11, 2023

To start the project have a look at
#263

@riderx
Copy link
Contributor Author

riderx commented Aug 11, 2023

The figma lack of some view as I shared, you are free to design them or propose a design template from any open source tailwind component

@pbkompasz
Copy link
Contributor

Ok, now I have a clearer picture. I will start working tomorrow and let you know if I have any questions.

@riderx
Copy link
Contributor Author

riderx commented Aug 16, 2023

@pbkompasz any updates ?
I updated the seeds sql to make it work in local to help you test

@pbkompasz
Copy link
Contributor

@riderx I saw the commits. I started with the frontend and made some progress but I didn't have much free time this week. I will try to finish it by Saturday.

@pbkompasz
Copy link
Contributor

@riderx The billings menu should redirect to a Stripe dashboard like in the user settings?

@pbkompasz
Copy link
Contributor

@riderx Can you give some more information on the organization rights. And also the security rules e.g. a member with a right what actions can perform.

@riderx
Copy link
Contributor Author

riderx commented Aug 27, 2023

I let you do a proposal of what they can access

@pbkompasz
Copy link
Contributor

Hey. I cannot work on this PR anymore. I finished part of the frontend, written the backend functions but I didn't have time to finish it. I created a draft PR, maybe someone else can take over.

@neo773
Copy link
Contributor

neo773 commented Aug 28, 2023

/attempt #258 @pbkompasz I'll take it over from here

Options

@algora-pbc
Copy link

algora-pbc bot commented Aug 28, 2023

Note: The user @pbkompasz is already attempting to complete issue #258 and claim the bounty. If you attempt to complete the same issue, there is a chance that @pbkompasz will complete the issue first, and be awarded the bounty. We recommend discussing with @pbkompasz and potentially collaborating on the same solution versus creating an alternate solution.

@WcaleNieWolny
Copy link
Contributor

Since neo cancelled his attempt 12 hours ago, I will be taking this. Do we want to replace all user_id to org_id?

If so, how do we go about migration? Do I just write some SQL to migrate from old user_id into org_id and when we merge this system we turn off prod -> migrate -> restart prod?

@WcaleNieWolny
Copy link
Contributor

WcaleNieWolny commented Aug 29, 2023

/attempt #258

Options

@WcaleNieWolny
Copy link
Contributor

I redesigned the members panel as I did not liked how it looked.
@riderx can you please give me some feedback on this?

image

Do you like how this looks or no?

@riderx
Copy link
Contributor Author

riderx commented Aug 30, 2023

Im good with it

@WcaleNieWolny
Copy link
Contributor

Wrote a dialog to insert email of the user that we want to invite. Please give feedback on this @riderx

image

@WcaleNieWolny
Copy link
Contributor

I will probably replace the Invite button with some sort of next button that will trigger another dialog asking of what type of permission do you want to give the user

@WcaleNieWolny
Copy link
Contributor

Here is a demo for the invitation system (Only for organizations for now)
I used a SQL fn and not a new edge fn to implement this
Please let me know if you like it @riderx

2023-08-31.08-20-06.mp4

@WcaleNieWolny
Copy link
Contributor

As for API keys:

I will keep them per user and not per org. It is really pointless to have shared api keys per org and having api keys per org add unnecessary complexity

@riderx
Copy link
Contributor Author

riderx commented Aug 31, 2023

@WcaleNieWolny for the Dialog did you made the same as we have now for channel invite, if user don't exist it invite him, and ask for name as well
Otherwise nice, why 2 modals ?
Nice, there are no edge function !
For APIKEY the point was to have as user a different apikey in each org not shared one.
But that ok for now to have them by users

@WcaleNieWolny
Copy link
Contributor

why 2 modals

I though it looked more "clean" that way, the first modal is strictly for email and the other one if for permissions with a nice explanation. Sure, I could pack that into one but then we would not have a nice explanation for each of the button.

Used 2 modals to make the UX better

@WcaleNieWolny
Copy link
Contributor

WcaleNieWolny commented Aug 31, 2023

for the Dialog did you made the same as we have now for channel invite

If I understand this correctly, then no I still have not implemented channel invites. I am doing only org for now and later I will add both app and channel invitations

, if user don't exist it invite him, and ask for name as well

You want to ask the user about some sort of nickname for the invited user? Like if I invite admin@capgo.app I can name him Tony Cooley from QA then I will see Tony Cooley from QA in the members tab

@riderx
Copy link
Contributor Author

riderx commented Aug 31, 2023

I mean this invite system is not linked to channel, it's more about if the user doesn't exist in Capgo we have a way to create him and send a magic link with Supabase.
So when you set Tony Cooley it means the user will have already Tony Cooley in his account it will just arrive at the step set password.
You can try this in the prod by going to channel of one app and try to invite one of your other email

@WcaleNieWolny
Copy link
Contributor

Wrote some code to accept invitations, please let me know if you like it @riderx

2023-09-01.14-01-06.mp4

@WcaleNieWolny
Copy link
Contributor

WcaleNieWolny commented Sep 3, 2023

transfer billing info from user to org

I do not like this idea. I strongly believe that billing should stay as is and if you are invited to any valid (billed) org then you can use capgo. Transferring billing to org adds extra complexity that could be avoided. Any org admin will not be paying for the org with his own money. That is the job of the owner

@algora-pbc
Copy link

algora-pbc bot commented Sep 4, 2023

@neo773: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@neo773
Copy link
Contributor

neo773 commented Sep 4, 2023

@zcesur
Can you fix this edge case where the bot reminds you of bounty being up for grabs even though you've canceled the attempt a while ago.

@zcesur

This comment was marked as off-topic.

@algora-pbc
Copy link

algora-pbc bot commented Sep 5, 2023

@WcaleNieWolny: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

@algora-pbc
Copy link

algora-pbc bot commented Sep 6, 2023

💡 @WcaleNieWolny submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Dec 2, 2023

🎉🎈 @WcaleNieWolny has been awarded $500! 🎈🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants