From d56aeeb359b2408f814a7dacfea0d90e767a95db Mon Sep 17 00:00:00 2001 From: Jason Zi Feng Lei Date: Tue, 12 Apr 2022 10:12:07 +0800 Subject: [PATCH] Updated default values for "Default Organization" and "Default Project" to be able to read from a .env file. --- docker/.env.example | 2 ++ docker/docker-compose.yml | 3 +++ studio/.env | 3 +++ studio/README.md | 7 +++++++ studio/pages/api/organizations/index.ts | 5 +++-- studio/pages/api/profile/index.ts | 7 ++++--- studio/pages/api/projects/[ref]/index.ts | 5 +++-- studio/pages/api/props/project/[ref]/api.ts | 3 ++- studio/pages/api/props/project/[ref]/index.ts | 3 ++- studio/pages/api/props/project/[ref]/settings.ts | 3 ++- 10 files changed, 31 insertions(+), 10 deletions(-) diff --git a/docker/.env.example b/docker/.env.example index 37e4b9a21d0..8d1b25b9770 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -41,6 +41,8 @@ KONG_HTTPS_PORT=8443 POSTGRES_PORT=5432 # Studio +STUDIO_ORGANIZATION_NAME=Default Organization +STUDIO_PROJECT_NAME=Default Project ## Public REST endpoint - replace this if you intend to use Studio outside of localhost PUBLIC_REST_URL=http://localhost:8000/rest/v1/ diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index cd965f3457d..be10619c4e0 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -17,6 +17,9 @@ services: STUDIO_PG_META_URL: http://meta:8080 POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + DEFAULT_ORGANIZATION: ${STUDIO_DEFAULT_ORGANIZATION} + DEFAULT_PROJECT: ${STUDIO_DEFAULT_PROJECT} + SUPABASE_URL: http://kong:8000 SUPABASE_REST_URL: ${PUBLIC_REST_URL} SUPABASE_ANON_KEY: ${ANON_KEY} diff --git a/studio/.env b/studio/.env index db284f3411e..478baf5dc20 100644 --- a/studio/.env +++ b/studio/.env @@ -1,6 +1,9 @@ STUDIO_PG_META_URL=http://localhost:8000/pg POSTGRES_PASSWORD=your-super-secret-and-long-postgres-password +DEFAULT_ORGANIZATION_NAME=Default Organization +DEFAULT_PROJECT_NAME=Default Project + SUPABASE_URL=http://localhost:8000 SUPABASE_REST_URL=http://localhost:8000/rest/v1/ SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE diff --git a/studio/README.md b/studio/README.md index df0df945274..e493579522d 100644 --- a/studio/README.md +++ b/studio/README.md @@ -73,6 +73,13 @@ npm install npm run dev ``` +If you would like to configure different defaults for "Default Organization" and "Default Project", you will need to update the `.env` in the studio folder with the corresponding values. + +``` +DEFAULT_ORGANIZATION_NAME= +DEFAULT_PROJECT_NAME= +``` + ## UI Testing Notes ### `` vs `` diff --git a/studio/pages/api/organizations/index.ts b/studio/pages/api/organizations/index.ts index d347ad0c017..c3b41b29bbd 100644 --- a/studio/pages/api/organizations/index.ts +++ b/studio/pages/api/organizations/index.ts @@ -1,6 +1,7 @@ -import apiWrapper from 'lib/api/apiWrapper' import { NextApiRequest, NextApiResponse } from 'next' +import apiWrapper from 'lib/api/apiWrapper' + export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -20,7 +21,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { const response = [ { id: 1, - name: 'Default Organization', + name: 'Default Organization' || process.env.DEFAULT_ORGANIZATION_NAME, slug: 'default-org-slug', billing_email: 'billing@supabase.co', }, diff --git a/studio/pages/api/profile/index.ts b/studio/pages/api/profile/index.ts index c6945b970ef..a985c48479b 100644 --- a/studio/pages/api/profile/index.ts +++ b/studio/pages/api/profile/index.ts @@ -1,7 +1,8 @@ import { NextApiRequest, NextApiResponse } from 'next' + import { IS_PLATFORM } from 'lib/constants' -import { createEncryptedDbConnectionString } from 'lib/api/apiHelpers' import apiWrapper from 'lib/api/apiWrapper' +import { createEncryptedDbConnectionString } from 'lib/api/apiHelpers' export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) @@ -28,14 +29,14 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { organizations: [ { id: 1, - name: 'Default Organization', + name: 'Default Organization' || process.env.DEFAULT_ORGANIZATION_NAME, slug: 'default-org-slug', billing_email: 'billing@supabase.co', projects: [ { id: 1, ref: 'default', - name: 'Default Project', + name: 'Default Project' || process.env.DEFAULT_PROJECT_NAME, organization_id: 1, cloud_provider: 'localhost', status: 'ACTIVE_HEALTHY', diff --git a/studio/pages/api/projects/[ref]/index.ts b/studio/pages/api/projects/[ref]/index.ts index 4c525abd79f..6339dbe5543 100644 --- a/studio/pages/api/projects/[ref]/index.ts +++ b/studio/pages/api/projects/[ref]/index.ts @@ -1,6 +1,7 @@ -import apiWrapper from 'lib/api/apiWrapper' import { NextApiRequest, NextApiResponse } from 'next' +import apiWrapper from 'lib/api/apiWrapper' + export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -20,7 +21,7 @@ const handleGet = async (req: NextApiRequest, res: NextApiResponse) => { const response = { id: 1, ref: 'default', - name: 'Default Project', + name: 'Default Project' || process.env.DEFAULT_PROJECT_NAME, organization_id: 1, cloud_provider: 'localhost', status: 'ACTIVE_HEALTHY', diff --git a/studio/pages/api/props/project/[ref]/api.ts b/studio/pages/api/props/project/[ref]/api.ts index 0f0cd019722..10705a675e0 100644 --- a/studio/pages/api/props/project/[ref]/api.ts +++ b/studio/pages/api/props/project/[ref]/api.ts @@ -1,4 +1,5 @@ import { NextApiRequest, NextApiResponse } from 'next' + import apiWrapper from 'lib/api/apiWrapper' export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) @@ -27,7 +28,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { db_user: 'postgres', id: 1, inserted_at: undefined, - name: 'Default Project', + name: 'Default Project' || process.env.DEFAULT_PROJECT_NAME, ref: 'default', status: 'ACTIVE_HEALTHY', services: [ diff --git a/studio/pages/api/props/project/[ref]/index.ts b/studio/pages/api/props/project/[ref]/index.ts index 27de041115f..1d14d1bf382 100644 --- a/studio/pages/api/props/project/[ref]/index.ts +++ b/studio/pages/api/props/project/[ref]/index.ts @@ -1,4 +1,5 @@ import { NextApiRequest, NextApiResponse } from 'next' + import apiWrapper from 'lib/api/apiWrapper' export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) @@ -21,7 +22,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { project: { id: 1, ref: 'default', - name: 'Default Project', + name: 'Default Project' || process.env.DEFAULT_PROJECT_NAME, status: 'ACTIVE_HEALTHY', organization_id: 1, inserted_at: '2021-08-02T06:40:40.646362', diff --git a/studio/pages/api/props/project/[ref]/settings.ts b/studio/pages/api/props/project/[ref]/settings.ts index a5ed9be25e9..a6132cf3d0a 100644 --- a/studio/pages/api/props/project/[ref]/settings.ts +++ b/studio/pages/api/props/project/[ref]/settings.ts @@ -1,4 +1,5 @@ import { NextApiRequest, NextApiResponse } from 'next' + import apiWrapper from 'lib/api/apiWrapper' export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler) @@ -29,7 +30,7 @@ const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => { id: 1, inserted_at: undefined, jwt_secret: '-', - name: 'Default Project', + name: 'Default Project' || process.env.DEFAULT_PROJECT_NAME, ref: 'default', region: 'ap-southeast-1', status: 'ACTIVE_HEALTHY',