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

feat: adding new "team_settings" table to Hasura #3289

Merged
merged 11 commits into from
Jun 20, 2024
Merged

Conversation

RODO94
Copy link
Contributor

@RODO94 RODO94 commented Jun 18, 2024

What does this PR do?

This PR focuses on the Hasura side of adding a new team_settings table to the database. In future, this will allow users to manage their own settings for their Team, and connect to elements of the API and Editor.

Where to find more info?

I have been documenting some of what I'm doing here: team_settings notion

Notable exclusions

I am yet to add in space for the computed field boundary__bbox but I will look to add this in during the current sprint.

settings and notify_personalisation have no been dropped from the TEAMS table - this will be done in clean up near the end of the sprint.

Copy link

github-actions bot commented Jun 18, 2024

🤖 Hasura Change Summary compared a subset of table metadata including permissions:

Tracked Tables (1)

  • public.team_settings permissions:

    insert select update delete
    api
    platformAdmin
    public
    teamEditor
    68 added column permissions
    insert select update
    api ➕ boundary_json
    ➕ boundary_url
    ➕ email_reply_to_id
    ➕ external_planning_site_name
    ➕ external_planning_site_url
    ➕ has_planning_data
    ➕ help_email
    ➕ help_opening_hours
    ➕ help_phone
    ➕ homepage
    ➕ id
    ➕ reference_code
    ➕ team_id
    platformAdmin ➕ boundary_json
    ➕ boundary_url
    ➕ email_reply_to_id
    ➕ external_planning_site_name
    ➕ external_planning_site_url
    ➕ has_planning_data
    ➕ help_email
    ➕ help_opening_hours
    ➕ help_phone
    ➕ homepage
    ➕ id
    ➕ reference_code
    ➕ team_id
    ➕ boundary_url
    ➕ email_reply_to_id
    ➕ external_planning_site_name
    ➕ external_planning_site_url
    ➕ has_planning_data
    ➕ help_email
    ➕ help_opening_hours
    ➕ help_phone
    ➕ homepage
    ➕ reference_code
    public ➕ boundary_json
    ➕ boundary_url
    ➕ external_planning_site_name
    ➕ external_planning_site_url
    ➕ has_planning_data
    ➕ homepage
    ➕ id
    ➕ reference_code
    ➕ team_id
    teamEditor ➕ boundary_json
    ➕ boundary_url
    ➕ email_reply_to_id
    ➕ external_planning_site_name
    ➕ external_planning_site_url
    ➕ has_planning_data
    ➕ help_email
    ➕ help_opening_hours
    ➕ help_phone
    ➕ homepage
    ➕ id
    ➕ reference_code
    ➕ team_id
    ➕ boundary_url
    ➕ email_reply_to_id
    ➕ external_planning_site_name
    ➕ external_planning_site_url
    ➕ has_planning_data
    ➕ help_email
    ➕ help_opening_hours
    ➕ help_phone
    ➕ homepage
    ➕ reference_code

Copy link

github-actions bot commented Jun 18, 2024

Removed vultr server and associated DNS entries

@RODO94 RODO94 requested a review from a team June 19, 2024 10:16
@RODO94 RODO94 marked this pull request as ready for review June 19, 2024 10:17
Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments to take a look at 👍

It's a good decision not to remove the columns from the team table here - we can come back and tidy this up once the feature is complete.

I think there's a bit of a chicken-egg situation with the sync scripts which is causing CI to fail. Without the team_settings table on production, the sync script can't read from it. What this means is that we'll need to -

  • Deploy the changes creating the table to staging and then to production
  • Then open a PR with the sync script updates which we'll also progress forward

You could just comment out the file in main.sql and we'll just comment it back in later 👍

It's a known issue and not unique to this PR - we're going to need a better solution eventually here. Open to ideas!

@@ -0,0 +1,69 @@
-- insert teams_settings overwriting conflicts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at #3160 which added the sync script for the feedback table. You'll also need to include this file in main.sql.

@@ -1649,6 +1649,115 @@
- role: platformAdmin
permission:
filter: {}
- table:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, it's worth adopting a principle of least-privileged access to any tables. It's always worth being overly-conservative with permissions initially, and then granting access when we hit a requirement to access them.

What I think this means for this PR is that -

  • The public role does not need access to GovNotify fields (email_reply_to_id, help_email, help_opening_hours, help_phone) as these are read by the backend when posting out emails. If this assumption is wrong, we can grant access when we hit features that require them.

  • teamEditors can only update their own team_settings - they cannot update the team_settings of a team which they aren't a member of. Hasura has a neat way of handling this - take a look at how this is handled in team_themes where the same restriction applies. Hasura has good docs on this here, which are useful for context. Happy to talk this through if helpful, just let me know 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type of thing? @DafyddLlyr

hasura snippet showing row permissions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's the one! Looks correct to me - you can check that the filter matches team_themes (and I think there may be even a way of copying directly).

@@ -0,0 +1,15 @@
INSERT INTO team_settings (team_id, reference_code, homepage, help_email, help_phone,help_opening_hours ,email_reply_to_id,has_planning_data , external_planning_site_url,external_planning_site_name,boundary_url,boundary_json)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good and correct to me 👍 Will double check when Pizza is up and test sync script locally also.

@RODO94 RODO94 requested a review from DafyddLlyr June 19, 2024 15:06
Comment on lines +1758 to +1765
filter:
team:
members:
_and:
- user_id:
_eq: x-hasura-user-id
- role:
_eq: teamEditor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@RODO94 RODO94 merged commit 1b2e1e2 into main Jun 20, 2024
12 checks passed
@RODO94 RODO94 deleted the rory/team-settings-hasura branch June 20, 2024 10:58
@RODO94
Copy link
Contributor Author

RODO94 commented Jul 5, 2024

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

Successfully merging this pull request may close these issues.

2 participants