Compare commits
164 Commits
@nhost/rea
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19818e2b59 | ||
|
|
b3eeec82ef | ||
|
|
34ff254696 | ||
|
|
1c4806bf51 | ||
|
|
2fb82ec97d | ||
|
|
0c994a9651 | ||
|
|
4713cecfc2 | ||
|
|
f79eebadbf | ||
|
|
ac174b5e51 | ||
|
|
dc9ddfc9ae | ||
|
|
3bdd9f570c | ||
|
|
94477be998 | ||
|
|
568577e8ca | ||
|
|
e93b06ab8f | ||
|
|
c75bf46ba1 | ||
|
|
63a1fd09b5 | ||
|
|
630d44ad6e | ||
|
|
d7db521974 | ||
|
|
90e4053f0a | ||
|
|
8e9d5d1b38 | ||
|
|
43c86fef14 | ||
|
|
6b97340cf4 | ||
|
|
1605756362 | ||
|
|
6437544384 | ||
|
|
b4dcd1996d | ||
|
|
7fb73dbb1b | ||
|
|
a66b11d245 | ||
|
|
912ed76c64 | ||
|
|
b47c0d1af7 | ||
|
|
b97ab2be2f | ||
|
|
f12cb666ff | ||
|
|
c3b2b1cd02 | ||
|
|
c0b71102d4 | ||
|
|
5f68ae95c4 | ||
|
|
2d1b7bb292 | ||
|
|
ee154d4eca | ||
|
|
58ef9bbe02 | ||
|
|
f3f35beefd | ||
|
|
d31330e6c0 | ||
|
|
c3dda79d95 | ||
|
|
7c1273725d | ||
|
|
70be0e1ab4 | ||
|
|
4f5870cfd7 | ||
|
|
623607476e | ||
|
|
1e232713d9 | ||
|
|
1ed647c4e9 | ||
|
|
b666a173b1 | ||
|
|
caba147b32 | ||
|
|
ca365fc8e7 | ||
|
|
d88cdedb26 | ||
|
|
1de08cecaf | ||
|
|
47bb997036 | ||
|
|
4e4d962f30 | ||
|
|
883fb82c77 | ||
|
|
c9f5634ac2 | ||
|
|
6ee9a589fb | ||
|
|
e2d733cf34 | ||
|
|
a0d7327c8d | ||
|
|
c7c8a20334 | ||
|
|
cca8de5805 | ||
|
|
8c065c42d6 | ||
|
|
210af3a3e8 | ||
|
|
fbb12a8079 | ||
|
|
77692ac40e | ||
|
|
2c2a42a8e8 | ||
|
|
a8466798a3 | ||
|
|
a45c0970bb | ||
|
|
9bf30a1ccc | ||
|
|
99d3d82c72 | ||
|
|
43acb3fb50 | ||
|
|
ba9ef13ba3 | ||
|
|
cea507a271 | ||
|
|
9130ab1230 | ||
|
|
27acdd6f56 | ||
|
|
dcdacd73ec | ||
|
|
9c9966a30f | ||
|
|
5a23e7a0a8 | ||
|
|
47500fac39 | ||
|
|
cbbf53c05b | ||
|
|
11bd011860 | ||
|
|
e3c0c47777 | ||
|
|
d825404b54 | ||
|
|
d46d77ee71 | ||
|
|
a292482705 | ||
|
|
8a4ca41172 | ||
|
|
fd3ce98600 | ||
|
|
04f36a0491 | ||
|
|
5e2ecb4d1e | ||
|
|
eca9e551e8 | ||
|
|
52ebbef762 | ||
|
|
82faa4ca0a | ||
|
|
d06a21764a | ||
|
|
8b54d290a5 | ||
|
|
4cfa6bbe1e | ||
|
|
614f213e26 | ||
|
|
4eebf51821 | ||
|
|
9a52298aa7 | ||
|
|
099eebe602 | ||
|
|
7cce8652e7 | ||
|
|
f2e2323801 | ||
|
|
4e16de6db2 | ||
|
|
798e591b1d | ||
|
|
b48bc034ca | ||
|
|
f57819230b | ||
|
|
3d8067ff7b | ||
|
|
0fa4b428a9 | ||
|
|
8c5864340e | ||
|
|
c131100af9 | ||
|
|
e363fef8cf | ||
|
|
d8072101c8 | ||
|
|
afbba531a1 | ||
|
|
4b6df8b9d6 | ||
|
|
a2af5a674d | ||
|
|
c33c1fd6b9 | ||
|
|
041d9b98e3 | ||
|
|
e4b4940397 | ||
|
|
be91f4ed2a | ||
|
|
ec6ba846cf | ||
|
|
a9e9fc4305 | ||
|
|
d8d8394b3b | ||
|
|
f051a121b2 | ||
|
|
c547b490e5 | ||
|
|
4f4449b855 | ||
|
|
6ed46ce2d4 | ||
|
|
bfb4c1a6cc | ||
|
|
776c8f9237 | ||
|
|
c0773d82e9 | ||
|
|
c46b1383f2 | ||
|
|
beed2eba21 | ||
|
|
70f9610041 | ||
|
|
e91de1088d | ||
|
|
ce1ee40dab | ||
|
|
bd7929f5ed | ||
|
|
2c8559a319 | ||
|
|
bd5ea5ee3a | ||
|
|
3538dbac39 | ||
|
|
03b5cda69a | ||
|
|
4329d04854 | ||
|
|
ca50c5ce0c | ||
|
|
a3271ed014 | ||
|
|
d4fc99a77c | ||
|
|
d90fcf3c24 | ||
|
|
001b3dccec | ||
|
|
cbb1fc5bc8 | ||
|
|
0ec3abf47c | ||
|
|
ae19105302 | ||
|
|
730a482598 | ||
|
|
253dd235ca | ||
|
|
991e8f2d15 | ||
|
|
e500e87022 | ||
|
|
c684d0307b | ||
|
|
2d657b9c29 | ||
|
|
f46d96bafc | ||
|
|
8261743bd3 | ||
|
|
34cf1d79a0 | ||
|
|
9d4542b3db | ||
|
|
bb5dbdf5a3 | ||
|
|
2801b03bf4 | ||
|
|
8298d458d5 | ||
|
|
6e9b941b89 | ||
|
|
5dd25941e5 | ||
|
|
cfcb97b8ee | ||
|
|
a1ffad77eb | ||
|
|
de4d59da99 |
@@ -23,9 +23,7 @@ runs:
|
|||||||
- uses: actions/cache@v3
|
- uses: actions/cache@v3
|
||||||
id: pnpm-cache
|
id: pnpm-cache
|
||||||
with:
|
with:
|
||||||
path: |
|
path: ${{ steps.pnpm-cache-dir.outputs.dir }}
|
||||||
${{ steps.pnpm-cache-dir.outputs.dir }}
|
|
||||||
~/.cache/Cypress
|
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('pnpm-lock.yaml') }}
|
key: ${{ runner.os }}-node-${{ hashFiles('pnpm-lock.yaml') }}
|
||||||
restore-keys: ${{ runner.os }}-node-
|
restore-keys: ${{ runner.os }}-node-
|
||||||
- name: Use Node.js 16
|
- name: Use Node.js 16
|
||||||
|
|||||||
100
.github/workflows/ci.yaml
vendored
100
.github/workflows/ci.yaml
vendored
@@ -19,6 +19,11 @@ env:
|
|||||||
NEXT_PUBLIC_ENV: dev
|
NEXT_PUBLIC_ENV: dev
|
||||||
NEXT_TELEMETRY_DISABLED: 1
|
NEXT_TELEMETRY_DISABLED: 1
|
||||||
NEXT_PUBLIC_NHOST_BACKEND_URL: http://localhost:1337
|
NEXT_PUBLIC_NHOST_BACKEND_URL: http://localhost:1337
|
||||||
|
NHOST_TEST_DASHBOARD_URL: ${{ vars.NHOST_TEST_DASHBOARD_URL }}
|
||||||
|
NHOST_TEST_WORKSPACE_NAME: ${{ vars.NHOST_TEST_WORKSPACE_NAME }}
|
||||||
|
NHOST_TEST_PROJECT_NAME: ${{ vars.NHOST_TEST_PROJECT_NAME }}
|
||||||
|
NHOST_TEST_USER_EMAIL: ${{ secrets.NHOST_TEST_USER_EMAIL }}
|
||||||
|
NHOST_TEST_USER_PASSWORD: ${{ secrets.NHOST_TEST_USER_PASSWORD }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -60,47 +65,6 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
|
|
||||||
e2e:
|
|
||||||
name: 'e2e (${{ matrix.package.path }})'
|
|
||||||
needs: build
|
|
||||||
if: ${{ needs.build.outputs.matrix != '[]' && needs.build.outputs.matrix != '' }}
|
|
||||||
strategy:
|
|
||||||
# * Don't cancel other matrices when one fails
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
package: ${{ fromJson(needs.build.outputs.matrix) }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
# * Install Node and dependencies. Package dependencies won't be downloaded again as they have been cached by the `build` job.
|
|
||||||
- name: Install Node and dependencies
|
|
||||||
uses: ./.github/actions/install-dependencies
|
|
||||||
with:
|
|
||||||
TURBO_TOKEN: ${{ env.TURBO_TOKEN }}
|
|
||||||
TURBO_TEAM: ${{ env.TURBO_TEAM }}
|
|
||||||
# * Install Nhost CLI if a `nhost/config.yaml` file is found
|
|
||||||
- name: Install Nhost CLI
|
|
||||||
if: hashFiles(format('{0}/nhost/config.yaml', matrix.package.path)) != ''
|
|
||||||
uses: ./.github/actions/nhost-cli
|
|
||||||
# * Run the `ci` script of the current package of the matrix. Dependencies build is cached by Turborepo
|
|
||||||
- name: Run e2e test
|
|
||||||
run: pnpm --filter="${{ matrix.package.name }}" run e2e
|
|
||||||
- id: file-name
|
|
||||||
if: ${{ failure() }}
|
|
||||||
name: Tranform package name into a valid file name
|
|
||||||
run: |
|
|
||||||
PACKAGE_FILE_NAME=$(echo "${{ matrix.package.name }}" | sed 's/@//g; s/\//-/g')
|
|
||||||
echo "fileName=$PACKAGE_FILE_NAME" >> $GITHUB_OUTPUT
|
|
||||||
# * Run this step only if the previous step failed, and some Cypress screenshots/videos exist
|
|
||||||
- name: Upload Cypress videos and screenshots
|
|
||||||
if: ${{ failure() && hashFiles(format('{0}/cypress/screenshots/**', matrix.package.path), format('{0}/cypress/videos/**', matrix.package.path)) != ''}}
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: cypress-${{ steps.file-name.outputs.fileName }}
|
|
||||||
path: |
|
|
||||||
${{format('{0}/cypress/screenshots/**', matrix.package.path)}}
|
|
||||||
${{format('{0}/cypress/videos/**', matrix.package.path)}}
|
|
||||||
|
|
||||||
unit:
|
unit:
|
||||||
name: Unit tests
|
name: Unit tests
|
||||||
needs: build
|
needs: build
|
||||||
@@ -141,3 +105,57 @@ jobs:
|
|||||||
# * Run every `lint` script in the workspace . Dependencies build is cached by Turborepo
|
# * Run every `lint` script in the workspace . Dependencies build is cached by Turborepo
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: pnpm run lint:all
|
run: pnpm run lint:all
|
||||||
|
|
||||||
|
e2e:
|
||||||
|
name: 'E2E (Package: ${{ matrix.package.path }})'
|
||||||
|
needs: build
|
||||||
|
if: ${{ needs.build.outputs.matrix != '[]' && needs.build.outputs.matrix != '' }}
|
||||||
|
strategy:
|
||||||
|
# * Don't cancel other matrices when one fails
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
package: ${{ fromJson(needs.build.outputs.matrix) }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
# * Install Node and dependencies. Package dependencies won't be downloaded again as they have been cached by the `build` job.
|
||||||
|
- name: Install Node and dependencies
|
||||||
|
uses: ./.github/actions/install-dependencies
|
||||||
|
with:
|
||||||
|
TURBO_TOKEN: ${{ env.TURBO_TOKEN }}
|
||||||
|
TURBO_TEAM: ${{ env.TURBO_TEAM }}
|
||||||
|
# * Install Nhost CLI if a `nhost/config.yaml` file is found
|
||||||
|
- name: Install Nhost CLI
|
||||||
|
if: hashFiles(format('{0}/nhost/config.yaml', matrix.package.path)) != ''
|
||||||
|
uses: ./.github/actions/nhost-cli
|
||||||
|
- name: Fetch Dashboard Preview URL
|
||||||
|
id: fetch-dashboard-preview-url
|
||||||
|
uses: zentered/vercel-preview-url@v1.1.9
|
||||||
|
if: github.ref_name != 'main'
|
||||||
|
env:
|
||||||
|
VERCEL_TOKEN: ${{ secrets.DASHBOARD_VERCEL_DEPLOY_TOKEN }}
|
||||||
|
GITHUB_REF: ${{ github.ref_name }}
|
||||||
|
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||||
|
with:
|
||||||
|
vercel_team_id: ${{ secrets.DASHBOARD_VERCEL_TEAM_ID }}
|
||||||
|
vercel_project_id: ${{ secrets.DASHBOARD_STAGING_VERCEL_PROJECT_ID }}
|
||||||
|
vercel_state: BUILDING,READY,INITIALIZING
|
||||||
|
- name: Set Dashboard Preview URL
|
||||||
|
if: steps.fetch-dashboard-preview-url.outputs.preview_url != ''
|
||||||
|
run: echo "NHOST_TEST_DASHBOARD_URL=https://${{ steps.fetch-dashboard-preview-url.outputs.preview_url }}" >> $GITHUB_ENV
|
||||||
|
# * Run the `ci` script of the current package of the matrix. Dependencies build is cached by Turborepo
|
||||||
|
- name: Run e2e tests
|
||||||
|
run: pnpm --filter="${{ matrix.package.name }}" run e2e
|
||||||
|
- id: file-name
|
||||||
|
if: ${{ failure() }}
|
||||||
|
name: Transform package name into a valid file name
|
||||||
|
run: |
|
||||||
|
PACKAGE_FILE_NAME=$(echo "${{ matrix.package.name }}" | sed 's/@//g; s/\//-/g')
|
||||||
|
echo "fileName=$PACKAGE_FILE_NAME" >> $GITHUB_OUTPUT
|
||||||
|
# * Run this step only if the previous step failed, and Playwright generated a report
|
||||||
|
- name: Upload Playwright Report
|
||||||
|
if: ${{ failure() && hashFiles(format('{0}/playwright-report/**', matrix.package.path)) != ''}}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: playwright-${{ steps.file-name.outputs.fileName }}
|
||||||
|
path: ${{format('{0}/playwright-report/**', matrix.package.path)}}
|
||||||
|
|||||||
1
.github/workflows/dashboard.yaml
vendored
1
.github/workflows/dashboard.yaml
vendored
@@ -9,6 +9,7 @@ env:
|
|||||||
NEXT_PUBLIC_ENV: dev
|
NEXT_PUBLIC_ENV: dev
|
||||||
NEXT_TELEMETRY_DISABLED: 1
|
NEXT_TELEMETRY_DISABLED: 1
|
||||||
NEXT_PUBLIC_NHOST_BACKEND_URL: http://localhost:1337
|
NEXT_PUBLIC_NHOST_BACKEND_URL: http://localhost:1337
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
|
|||||||
89
.github/workflows/renovate.yaml
vendored
89
.github/workflows/renovate.yaml
vendored
@@ -1,89 +0,0 @@
|
|||||||
name: Renovate
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
types: [closed]
|
|
||||||
paths-ignore:
|
|
||||||
- 'assets/**'
|
|
||||||
- '**.md'
|
|
||||||
- 'LICENSE'
|
|
||||||
env:
|
|
||||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
||||||
TURBO_TEAM: nhost
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
renovate-changeset:
|
|
||||||
name: Add changeset
|
|
||||||
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'renovate/')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
token: ${{ secrets.GH_PAT }}
|
|
||||||
# * Install Node and dependencies. Package downloads will be cached for the next jobs.
|
|
||||||
- name: Install Node and dependencies
|
|
||||||
uses: ./.github/actions/install-dependencies
|
|
||||||
with:
|
|
||||||
TURBO_TOKEN: ${{ env.TURBO_TOKEN }}
|
|
||||||
TURBO_TEAM: ${{ env.TURBO_TEAM }}
|
|
||||||
BUILD: 'none'
|
|
||||||
- name: Determine bumps
|
|
||||||
id: bumps
|
|
||||||
run: |
|
|
||||||
LAST_NON_PR_SHA=$(git log --no-merges main origin/${{ github.head_ref }} --format=format:%h -- | head -2 | tail -1)
|
|
||||||
echo "result<<EOF" >> $GITHUB_OUTPUT
|
|
||||||
pnpm recursive list --depth -1 --parseable \
|
|
||||||
--filter='!nhost-root' \
|
|
||||||
--filter=[$LAST_NON_PR_SHA] \
|
|
||||||
| xargs -I@ jq ".name" @/package.json \
|
|
||||||
| sort \
|
|
||||||
| uniq -u \
|
|
||||||
| awk '$0=$0": patch"' \
|
|
||||||
>> $GITHUB_OUTPUT
|
|
||||||
echo 'EOF' >> $GITHUB_OUTPUT
|
|
||||||
- name: Install dictionary
|
|
||||||
if: steps.bumps.outputs.result != ''
|
|
||||||
run: sudo apt-get install wbritish
|
|
||||||
- name: Generate changeset file name
|
|
||||||
id: file_name
|
|
||||||
if: steps.bumps.outputs.result != ''
|
|
||||||
run: |
|
|
||||||
FILE_NAME=$(shuf -n 3 /usr/share/dict/words | tr '\n' '-' | sed 's/-$//' | sed 's/'"'"'s//g' | tr '[:upper:]' '[:lower:]')
|
|
||||||
echo "result=./.changeset/${FILE_NAME}.md" >> $GITHUB_OUTPUT
|
|
||||||
- name: Create changeset file
|
|
||||||
if: steps.bumps.outputs.result != ''
|
|
||||||
run: |
|
|
||||||
cat <<EOF > ${{ steps.file_name.outputs.result }}
|
|
||||||
---
|
|
||||||
${{ steps.bumps.outputs.result }}
|
|
||||||
---
|
|
||||||
|
|
||||||
${{ github.event.pull_request.title }}
|
|
||||||
EOF
|
|
||||||
- name: Create Pull Request
|
|
||||||
id: cpr
|
|
||||||
uses: peter-evans/create-pull-request@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GH_PAT }}
|
|
||||||
commit-message: ${{ github.event.pull_request.title }}
|
|
||||||
branch: renovate-changesets
|
|
||||||
delete-branch: true
|
|
||||||
title: 'chore: create changesest from Renovate bumps'
|
|
||||||
labels: |
|
|
||||||
dependencies
|
|
||||||
body: |
|
|
||||||
This PR creates the changesets from the Renovate dependencies that have been merged to main.
|
|
||||||
- name: Enable Pull Request Automerge
|
|
||||||
if: steps.cpr.outputs.pull-request-operation == 'created'
|
|
||||||
uses: peter-evans/enable-pull-request-automerge@v2
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GH_PAT }}
|
|
||||||
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
|
|
||||||
- name: Auto approve
|
|
||||||
if: steps.cpr.outputs.pull-request-operation == 'created'
|
|
||||||
uses: juliangruber/approve-pull-request-action@v2
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GH_PAT }}
|
|
||||||
number: ${{ steps.cpr.outputs.pull-request-number }}
|
|
||||||
@@ -23,8 +23,8 @@ module.exports = {
|
|||||||
'e2e/**/*.ts',
|
'e2e/**/*.ts',
|
||||||
'e2e/**/*.d.ts'
|
'e2e/**/*.d.ts'
|
||||||
],
|
],
|
||||||
plugins: ['@typescript-eslint', 'cypress'],
|
plugins: ['@typescript-eslint'],
|
||||||
extends: ['plugin:cypress/recommended'],
|
extends: [],
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
ecmaVersion: 2020,
|
ecmaVersion: 2020,
|
||||||
sourceType: 'module'
|
sourceType: 'module'
|
||||||
|
|||||||
6
dashboard/.gitignore
vendored
6
dashboard/.gitignore
vendored
@@ -49,4 +49,8 @@ tailwind.json
|
|||||||
.idea
|
.idea
|
||||||
|
|
||||||
# Do not ignore Logs page
|
# Do not ignore Logs page
|
||||||
!src/**/logs*
|
!src/**/logs*
|
||||||
|
/test-results/
|
||||||
|
/playwright-report/
|
||||||
|
/playwright/.cache/
|
||||||
|
storageState.json
|
||||||
@@ -51,7 +51,7 @@ export const decorators = [
|
|||||||
(Story) => (
|
(Story) => (
|
||||||
<NhostApolloProvider
|
<NhostApolloProvider
|
||||||
fetchPolicy="cache-first"
|
fetchPolicy="cache-first"
|
||||||
graphqlUrl="http://localhost:1337/v1/graphql"
|
graphqlUrl="https://local.graphql.nhost.run/v1"
|
||||||
>
|
>
|
||||||
<Story />
|
<Story />
|
||||||
</NhostApolloProvider>
|
</NhostApolloProvider>
|
||||||
|
|||||||
@@ -1,5 +1,78 @@
|
|||||||
# @nhost/dashboard
|
# @nhost/dashboard
|
||||||
|
|
||||||
|
## 0.13.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- e93b06ab: fix(dashboard): remove left margin from workspace list on mobile
|
||||||
|
- 1c4806bf: chore(deps): bump `sharp` to 0.32.0
|
||||||
|
- @nhost/react-apollo@5.0.14
|
||||||
|
- @nhost/nextjs@1.13.18
|
||||||
|
|
||||||
|
## 0.13.9
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 912ed76c: chore(dashboard): bump `@apollo/client` to 3.7.10
|
||||||
|
- Updated dependencies [912ed76c]
|
||||||
|
- @nhost/react-apollo@5.0.13
|
||||||
|
|
||||||
|
## 0.13.8
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 7c127372: chore(dashboard): bump `react-error-boundary` to v4
|
||||||
|
|
||||||
|
## 0.13.7
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 9130ab12: chore(dashboard): bump `yup` to v1 and `@hookform/resolvers` to v3
|
||||||
|
|
||||||
|
## 0.13.6
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 253dd235: using new mutation to create projects + refactor Create Project page.
|
||||||
|
|
||||||
|
## 0.13.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/react-apollo@5.0.12
|
||||||
|
- @nhost/nextjs@1.13.17
|
||||||
|
|
||||||
|
## 0.13.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- b48bc034: fix(dashboard): disable new users
|
||||||
|
- 798e591b: fix(dashboard): show correct date in data grid
|
||||||
|
|
||||||
|
## 0.13.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- bfb4c1a6: chore(dashboard): remove `useAxios` property
|
||||||
|
- d8d8394b: Dashboard: allow to override hasura admin secret in docker
|
||||||
|
- Updated dependencies [ce1ee40d]
|
||||||
|
- @nhost/nextjs@1.13.16
|
||||||
|
- @nhost/react-apollo@5.0.11
|
||||||
|
|
||||||
|
## 0.13.2
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- beed2eba: Fix docker entrypoint for dashboard
|
||||||
|
- 2c8559a3: fix(dashboard): refresh project list after deleting a project
|
||||||
|
- 4329d048: chore(dashboard): bump `graphiql` dependencies
|
||||||
|
|
||||||
|
## 0.13.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- cbb1fc5b: chore(dashboard): cleanup GraphQL operations
|
||||||
|
|
||||||
## 0.13.0
|
## 0.13.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ ENV NEXT_PUBLIC_ENV dev
|
|||||||
ENV NEXT_PUBLIC_NHOST_PLATFORM false
|
ENV NEXT_PUBLIC_NHOST_PLATFORM false
|
||||||
|
|
||||||
# placeholders for URLs, will be replaced on runtime by entrypoint script
|
# placeholders for URLs, will be replaced on runtime by entrypoint script
|
||||||
|
ENV NEXT_PUBLIC_NHOST_ADMIN_SECRET __NEXT_PUBLIC_NHOST_ADMIN_SECRET__
|
||||||
ENV NEXT_PUBLIC_NHOST_AUTH_URL __NEXT_PUBLIC_NHOST_AUTH_URL__
|
ENV NEXT_PUBLIC_NHOST_AUTH_URL __NEXT_PUBLIC_NHOST_AUTH_URL__
|
||||||
ENV NEXT_PUBLIC_NHOST_FUNCTIONS_URL __NEXT_PUBLIC_NHOST_FUNCTIONS_URL__
|
ENV NEXT_PUBLIC_NHOST_FUNCTIONS_URL __NEXT_PUBLIC_NHOST_FUNCTIONS_URL__
|
||||||
ENV NEXT_PUBLIC_NHOST_GRAPHQL_URL __NEXT_PUBLIC_NHOST_GRAPHQL_URL__
|
ENV NEXT_PUBLIC_NHOST_GRAPHQL_URL __NEXT_PUBLIC_NHOST_GRAPHQL_URL__
|
||||||
|
|||||||
@@ -111,3 +111,21 @@ pnpm storybook
|
|||||||
| `@typescript-eslint/consistent-type-imports` | Enforces `import type { Type } from 'module'` syntax. It prevents false positive circular dependency errors. |
|
| `@typescript-eslint/consistent-type-imports` | Enforces `import type { Type } from 'module'` syntax. It prevents false positive circular dependency errors. |
|
||||||
| `@typescript-eslint/naming-convention` | Enforces a consistent naming convention. |
|
| `@typescript-eslint/naming-convention` | Enforces a consistent naming convention. |
|
||||||
| `no-restricted-imports` | Enforces absolute imports and consistent import paths for components from `src/components/ui` folder. |
|
| `no-restricted-imports` | Enforces absolute imports and consistent import paths for components from `src/components/ui` folder. |
|
||||||
|
|
||||||
|
### End-to-End Tests
|
||||||
|
|
||||||
|
End-to-end tests are written using [Playwright](https://playwright.dev/). To run the tests, run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm e2e
|
||||||
|
```
|
||||||
|
|
||||||
|
Most of the tests require access to the Nhost test user. To run these tests, you need to set the following environment variables in `.env.test`:
|
||||||
|
|
||||||
|
```
|
||||||
|
NHOST_TEST_DASHBOARD_URL=<test_dashboard_url>
|
||||||
|
NHOST_TEST_USER_EMAIL=<test_user_email>
|
||||||
|
NHOST_TEST_USER_PASSWORD=<test_user_password>
|
||||||
|
NHOST_TEST_WORKSPACE_NAME=<test_workspace_name>
|
||||||
|
NHOST_TEST_PROJECT_NAME=<test_project_name>
|
||||||
|
```
|
||||||
|
|||||||
@@ -3,15 +3,17 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# read URLs from env variables (with defaults)
|
# read URLs from env variables (with defaults)
|
||||||
NEXT_PUBLIC_NHOST_AUTH_URL="${NEXT_PUBLIC_NHOST_AUTH_URL:-"http://localhost:1337/v1/auth"}"
|
NEXT_PUBLIC_NHOST_ADMIN_SECRET="${NEXT_PUBLIC_NHOST_ADMIN_SECRET:-nhost-admin-secret}"
|
||||||
NEXT_PUBLIC_NHOST_FUNCTIONS_URL="${NEXT_PUBLIC_NHOST_FUNCTIONS_URL:-"http://localhost:1337/v1/functions"}"
|
NEXT_PUBLIC_NHOST_AUTH_URL="${NEXT_PUBLIC_NHOST_AUTH_URL:-http://localhost:1337/v1/auth}"
|
||||||
NEXT_PUBLIC_NHOST_GRAPHQL_URL="${NEXT_PUBLIC_NHOST_GRAPHQL_URL:-"http://localhost:1337/v1/graphql"}"
|
NEXT_PUBLIC_NHOST_FUNCTIONS_URL="${NEXT_PUBLIC_NHOST_FUNCTIONS_URL:-http://localhost:1337/v1/functions}"
|
||||||
NEXT_PUBLIC_NHOST_STORAGE_URL="${NEXT_PUBLIC_NHOST_STORAGE_URL:-"http://localhost:1337/v1/storage"}"
|
NEXT_PUBLIC_NHOST_GRAPHQL_URL="${NEXT_PUBLIC_NHOST_GRAPHQL_URL:-http://localhost:1337/v1/graphql}"
|
||||||
NEXT_PUBLIC_NHOST_HASURA_CONSOLE_URL="${NEXT_PUBLIC_NHOST_HASURA_CONSOLE_URL:-"http://localhost:9695"}"
|
NEXT_PUBLIC_NHOST_STORAGE_URL="${NEXT_PUBLIC_NHOST_STORAGE_URL:-http://localhost:1337/v1/storage}"
|
||||||
NEXT_PUBLIC_NHOST_HASURA_MIGRATIONS_API_URL="${NEXT_PUBLIC_NHOST_HASURA_MIGRATIONS_API_URL:-"http://localhost:9693"}"
|
NEXT_PUBLIC_NHOST_HASURA_CONSOLE_URL="${NEXT_PUBLIC_NHOST_HASURA_CONSOLE_URL:-http://localhost:9695}"
|
||||||
NEXT_PUBLIC_NHOST_HASURA_API_URL="${NEXT_PUBLIC_NHOST_HASURA_API_URL:-"http://localhost:8080"}"
|
NEXT_PUBLIC_NHOST_HASURA_MIGRATIONS_API_URL="${NEXT_PUBLIC_NHOST_HASURA_MIGRATIONS_API_URL:-http://localhost:9693}"
|
||||||
|
NEXT_PUBLIC_NHOST_HASURA_API_URL="${NEXT_PUBLIC_NHOST_HASURA_API_URL:-http://localhost:8080}"
|
||||||
|
|
||||||
# replace placeholders
|
# replace placeholders
|
||||||
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_ADMIN_SECRET__~${NEXT_PUBLIC_NHOST_ADMIN_SECRET}~g" {} +
|
||||||
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_AUTH_URL__~${NEXT_PUBLIC_NHOST_AUTH_URL}~g" {} +
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_AUTH_URL__~${NEXT_PUBLIC_NHOST_AUTH_URL}~g" {} +
|
||||||
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_FUNCTIONS_URL__~${NEXT_PUBLIC_NHOST_FUNCTIONS_URL}~g" {} +
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_FUNCTIONS_URL__~${NEXT_PUBLIC_NHOST_FUNCTIONS_URL}~g" {} +
|
||||||
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_GRAPHQL_URL__~${NEXT_PUBLIC_NHOST_GRAPHQL_URL}~g" {} +
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_GRAPHQL_URL__~${NEXT_PUBLIC_NHOST_GRAPHQL_URL}~g" {} +
|
||||||
|
|||||||
93
dashboard/e2e/auth/user-management.test.ts
Normal file
93
dashboard/e2e/auth/user-management.test.ts
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import {
|
||||||
|
TEST_PROJECT_NAME,
|
||||||
|
TEST_PROJECT_SLUG,
|
||||||
|
TEST_WORKSPACE_SLUG,
|
||||||
|
} from '@/e2e/env';
|
||||||
|
import { openProject } from '@/e2e/utils';
|
||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
let page: Page;
|
||||||
|
|
||||||
|
test.describe.configure({ mode: 'serial' });
|
||||||
|
|
||||||
|
test.beforeAll(async ({ browser }) => {
|
||||||
|
page = await browser.newPage();
|
||||||
|
|
||||||
|
await page.goto('/');
|
||||||
|
|
||||||
|
await openProject({
|
||||||
|
page,
|
||||||
|
projectName: TEST_PROJECT_NAME,
|
||||||
|
workspaceSlug: TEST_WORKSPACE_SLUG,
|
||||||
|
projectSlug: TEST_PROJECT_SLUG,
|
||||||
|
});
|
||||||
|
|
||||||
|
await page
|
||||||
|
.getByRole('navigation', { name: /main navigation/i })
|
||||||
|
.getByRole('link', { name: /auth/i })
|
||||||
|
.click();
|
||||||
|
|
||||||
|
await page.waitForURL(`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/users`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll(async () => {
|
||||||
|
await page.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should create a user', async () => {
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: /there are no users yet/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: /create user/i })
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
|
||||||
|
await expect(page.getByRole('dialog')).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: /create user/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await page
|
||||||
|
.getByRole('textbox', { name: /email/i })
|
||||||
|
.fill('testuser@example.com');
|
||||||
|
await page.getByRole('textbox', { name: /password/i }).fill('test.password');
|
||||||
|
await page.getByRole('button', { name: /create/i, exact: true }).click();
|
||||||
|
|
||||||
|
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('button', { name: /view testuser@example.com/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should delete a user', async () => {
|
||||||
|
await expect(
|
||||||
|
page.getByRole('button', { name: /view testuser@example.com/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: /more options for testuser@example.com/i })
|
||||||
|
.click();
|
||||||
|
await page.getByRole('menuitem', { name: /delete user/i }).click();
|
||||||
|
|
||||||
|
await expect(page.getByRole('dialog')).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: /delete user/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
page.getByText(
|
||||||
|
/are you sure you want to delete the "testuser@example.com" user?/i,
|
||||||
|
),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /delete/i, exact: true }).click();
|
||||||
|
|
||||||
|
await expect(page.getByRole('dialog')).not.toBeVisible();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: /there are no users yet/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
276
dashboard/e2e/database/create-table.test.ts
Normal file
276
dashboard/e2e/database/create-table.test.ts
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
import {
|
||||||
|
TEST_PROJECT_NAME,
|
||||||
|
TEST_PROJECT_SLUG,
|
||||||
|
TEST_WORKSPACE_SLUG,
|
||||||
|
} from '@/e2e/env';
|
||||||
|
import { openProject, prepareTable } from '@/e2e/utils';
|
||||||
|
import { faker } from '@faker-js/faker';
|
||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
let page: Page;
|
||||||
|
|
||||||
|
test.beforeAll(async ({ browser }) => {
|
||||||
|
page = await browser.newPage();
|
||||||
|
await page.goto('/');
|
||||||
|
|
||||||
|
await openProject({
|
||||||
|
page,
|
||||||
|
projectName: TEST_PROJECT_NAME,
|
||||||
|
workspaceSlug: TEST_WORKSPACE_SLUG,
|
||||||
|
projectSlug: TEST_PROJECT_SLUG,
|
||||||
|
});
|
||||||
|
|
||||||
|
await page
|
||||||
|
.getByRole('navigation', { name: /main navigation/i })
|
||||||
|
.getByRole('link', { name: /database/i })
|
||||||
|
.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll(async () => {
|
||||||
|
await page.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should create a simple table', async () => {
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const tableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'title', type: 'text' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${tableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('link', { name: tableName, exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should create a table with unique constraints', async () => {
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const tableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'title', type: 'text', unique: true },
|
||||||
|
{ name: 'isbn', type: 'text', unique: true },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${tableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('link', { name: tableName, exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should create a table with nullable columns', async () => {
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const tableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'title', type: 'text', nullable: true },
|
||||||
|
{ name: 'description', type: 'text', nullable: true },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${tableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('link', { name: tableName, exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should create a table with an identity column', async () => {
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const tableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'int4' },
|
||||||
|
{ name: 'title', type: 'text', nullable: true },
|
||||||
|
{ name: 'description', type: 'text', nullable: true },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /identity/i }).click();
|
||||||
|
await page.getByRole('option', { name: /id/i }).click();
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${tableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('link', { name: tableName, exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should create table with foreign key constraint', async () => {
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const firstTableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: firstTableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'name', type: 'text' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${firstTableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const secondTableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: secondTableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'title', type: 'text' },
|
||||||
|
{ name: 'author_id', type: 'uuid' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /add foreign key/i }).click();
|
||||||
|
|
||||||
|
// select column in current table
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: /column/i })
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
await page.getByRole('option', { name: /author_id/i }).click();
|
||||||
|
|
||||||
|
// select reference schema
|
||||||
|
await page.getByRole('button', { name: /schema/i }).click();
|
||||||
|
await page.getByRole('option', { name: /public/i }).click();
|
||||||
|
|
||||||
|
// select reference table
|
||||||
|
await page.getByRole('button', { name: /table/i }).click();
|
||||||
|
await page.getByRole('option', { name: firstTableName, exact: true }).click();
|
||||||
|
|
||||||
|
// select reference column
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: /column/i })
|
||||||
|
.nth(1)
|
||||||
|
.click();
|
||||||
|
await page.getByRole('option', { name: /id/i }).click();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /add/i }).click();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByText(`public.${firstTableName}.id`, { exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${secondTableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('link', { name: secondTableName, exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not be able to create a table with a name that already exists', async () => {
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const tableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'name', type: 'text' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${tableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'title', type: 'text' },
|
||||||
|
{ name: 'author_id', type: 'uuid' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByText(/error: a table with this name already exists/i),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
191
dashboard/e2e/database/delete-table.test.ts
Normal file
191
dashboard/e2e/database/delete-table.test.ts
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
import {
|
||||||
|
TEST_PROJECT_NAME,
|
||||||
|
TEST_PROJECT_SLUG,
|
||||||
|
TEST_WORKSPACE_SLUG,
|
||||||
|
} from '@/e2e/env';
|
||||||
|
import { openProject, prepareTable } from '@/e2e/utils';
|
||||||
|
import { faker } from '@faker-js/faker';
|
||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
let page: Page;
|
||||||
|
|
||||||
|
test.beforeAll(async ({ browser }) => {
|
||||||
|
page = await browser.newPage();
|
||||||
|
await page.goto('/');
|
||||||
|
|
||||||
|
await openProject({
|
||||||
|
page,
|
||||||
|
projectName: TEST_PROJECT_NAME,
|
||||||
|
workspaceSlug: TEST_WORKSPACE_SLUG,
|
||||||
|
projectSlug: TEST_PROJECT_SLUG,
|
||||||
|
});
|
||||||
|
|
||||||
|
await page
|
||||||
|
.getByRole('navigation', { name: /main navigation/i })
|
||||||
|
.getByRole('link', { name: /database/i })
|
||||||
|
.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll(async () => {
|
||||||
|
await page.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should delete a table', async () => {
|
||||||
|
const tableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'title', type: 'text' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${tableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const tableLink = page.getByRole('link', {
|
||||||
|
name: tableName,
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await tableLink.hover();
|
||||||
|
await page
|
||||||
|
.getByRole('listitem')
|
||||||
|
.filter({ hasText: tableName })
|
||||||
|
.getByRole('button')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
await page.getByRole('menuitem', { name: /delete table/i }).click();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: /delete table/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /delete/i }).click();
|
||||||
|
|
||||||
|
// navigate to next URL
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/**`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('link', { name: tableName, exact: true }),
|
||||||
|
).not.toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not be able to delete a table if other tables have foreign keys referencing it', async () => {
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const firstTableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: firstTableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'name', type: 'text' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${firstTableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /new table/i }).click();
|
||||||
|
await expect(page.getByText(/create a new table/i)).toBeVisible();
|
||||||
|
|
||||||
|
const secondTableName = faker.random.word().toLowerCase();
|
||||||
|
|
||||||
|
await prepareTable({
|
||||||
|
page,
|
||||||
|
name: secondTableName,
|
||||||
|
primaryKey: 'id',
|
||||||
|
columns: [
|
||||||
|
{ name: 'id', type: 'uuid', defaultValue: 'gen_random_uuid()' },
|
||||||
|
{ name: 'title', type: 'text' },
|
||||||
|
{ name: 'author_id', type: 'uuid' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /add foreign key/i }).click();
|
||||||
|
|
||||||
|
// select column in current table
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: /column/i })
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
await page.getByRole('option', { name: /author_id/i }).click();
|
||||||
|
|
||||||
|
// select reference schema
|
||||||
|
await page.getByRole('button', { name: /schema/i }).click();
|
||||||
|
await page.getByRole('option', { name: /public/i }).click();
|
||||||
|
|
||||||
|
// select reference table
|
||||||
|
await page.getByRole('button', { name: /table/i }).click();
|
||||||
|
await page.getByRole('option', { name: firstTableName, exact: true }).click();
|
||||||
|
|
||||||
|
// select reference column
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: /column/i })
|
||||||
|
.nth(1)
|
||||||
|
.click();
|
||||||
|
await page.getByRole('option', { name: /id/i }).click();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /add/i }).click();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByText(`public.${firstTableName}.id`, { exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
// create table
|
||||||
|
await page.getByRole('button', { name: /create/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(
|
||||||
|
`/${TEST_WORKSPACE_SLUG}/${TEST_PROJECT_SLUG}/database/browser/default/public/${secondTableName}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('link', { name: secondTableName, exact: true }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
// try to delete the first table that is referenced by the second table
|
||||||
|
const tableLink = page.getByRole('link', {
|
||||||
|
name: firstTableName,
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await tableLink.hover();
|
||||||
|
await page
|
||||||
|
.getByRole('listitem')
|
||||||
|
.filter({ hasText: firstTableName })
|
||||||
|
.getByRole('button')
|
||||||
|
.click();
|
||||||
|
|
||||||
|
await page.getByRole('menuitem', { name: /delete table/i }).click();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: /delete table/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: /delete/i }).click();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByText(
|
||||||
|
/constraint [a-zA-Z_]+ on table [a-zA-Z_]+ depends on table [a-zA-Z_]+/i,
|
||||||
|
),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
42
dashboard/e2e/env.ts
Normal file
42
dashboard/e2e/env.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import slugify from 'slugify';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL of the dashboard to test against.
|
||||||
|
*/
|
||||||
|
export const TEST_DASHBOARD_URL = process.env.NHOST_TEST_DASHBOARD_URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the workspace to test against.
|
||||||
|
*/
|
||||||
|
export const TEST_WORKSPACE_NAME = process.env.NHOST_TEST_WORKSPACE_NAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slugified name of the workspace to test against.
|
||||||
|
*/
|
||||||
|
export const TEST_WORKSPACE_SLUG = slugify(TEST_WORKSPACE_NAME, {
|
||||||
|
lower: true,
|
||||||
|
strict: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the project to test against.
|
||||||
|
*/
|
||||||
|
export const TEST_PROJECT_NAME = process.env.NHOST_TEST_PROJECT_NAME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slugified name of the project to test against.
|
||||||
|
*/
|
||||||
|
export const TEST_PROJECT_SLUG = slugify(TEST_PROJECT_NAME, {
|
||||||
|
lower: true,
|
||||||
|
strict: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Email of the test account to use.
|
||||||
|
*/
|
||||||
|
export const TEST_USER_EMAIL = process.env.NHOST_TEST_USER_EMAIL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Password of the test account to use.
|
||||||
|
*/
|
||||||
|
export const TEST_USER_PASSWORD = process.env.NHOST_TEST_USER_PASSWORD;
|
||||||
109
dashboard/e2e/overview/overview.test.ts
Normal file
109
dashboard/e2e/overview/overview.test.ts
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import {
|
||||||
|
TEST_PROJECT_NAME,
|
||||||
|
TEST_PROJECT_SLUG,
|
||||||
|
TEST_WORKSPACE_NAME,
|
||||||
|
TEST_WORKSPACE_SLUG,
|
||||||
|
} from '@/e2e/env';
|
||||||
|
import { openProject } from '@/e2e/utils';
|
||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
let page: Page;
|
||||||
|
|
||||||
|
test.beforeAll(async ({ browser }) => {
|
||||||
|
page = await browser.newPage();
|
||||||
|
|
||||||
|
await page.goto('/');
|
||||||
|
await openProject({
|
||||||
|
page,
|
||||||
|
projectName: TEST_PROJECT_NAME,
|
||||||
|
workspaceSlug: TEST_WORKSPACE_SLUG,
|
||||||
|
projectSlug: TEST_PROJECT_SLUG,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.afterAll(async () => {
|
||||||
|
await page.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should show a sidebar with menu items', async () => {
|
||||||
|
const navLocator = page.getByRole('navigation', { name: /main navigation/i });
|
||||||
|
await expect(navLocator).toBeVisible();
|
||||||
|
await expect(navLocator.getByRole('list').getByRole('listitem')).toHaveCount(
|
||||||
|
10,
|
||||||
|
);
|
||||||
|
await expect(
|
||||||
|
navLocator.getByRole('link', { name: /overview/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
navLocator.getByRole('link', { name: /database/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
navLocator.getByRole('link', { name: /graphql/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(navLocator.getByRole('link', { name: /hasura/i })).toBeVisible();
|
||||||
|
await expect(navLocator.getByRole('link', { name: /auth/i })).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
navLocator.getByRole('link', { name: /storage/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
navLocator.getByRole('link', { name: /deployments/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
navLocator.getByRole('link', { name: /backups/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(navLocator.getByRole('link', { name: /logs/i })).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
navLocator.getByRole('link', { name: /settings/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should show a header with a logo, the workspace name, and the project name', async () => {
|
||||||
|
await expect(
|
||||||
|
page.getByRole('banner').getByRole('link', { name: TEST_WORKSPACE_NAME }),
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.getByRole('banner').getByRole('link', { name: TEST_PROJECT_NAME }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should show the project's name, the Upgrade button and the Settings button", async () => {
|
||||||
|
await expect(
|
||||||
|
page.getByRole('heading', { name: TEST_PROJECT_NAME }),
|
||||||
|
).toBeVisible();
|
||||||
|
await expect(page.getByText(/free plan/i)).toBeVisible();
|
||||||
|
await expect(page.getByRole('button', { name: /upgrade/i })).toBeVisible();
|
||||||
|
await expect(
|
||||||
|
page.getByRole('main').getByRole('link', { name: /settings/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("should show the project's region and subdomain", async () => {
|
||||||
|
await expect(page.locator('p:has-text("Region") + div p').nth(0)).toHaveText(
|
||||||
|
/frankfurt \(eu-central-1\)/i,
|
||||||
|
);
|
||||||
|
await expect(
|
||||||
|
page.locator('p:has-text("Subdomain") + div p').nth(0),
|
||||||
|
).toHaveText(/[a-z]{20}/i);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not have a GitHub repository connected', async () => {
|
||||||
|
await expect(
|
||||||
|
page.getByRole('button', { name: /connect to github/i }),
|
||||||
|
).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should show proper limits for the free project', async () => {
|
||||||
|
// Limit for Database
|
||||||
|
await expect(page.getByText(/of 500 MB/i)).toBeVisible();
|
||||||
|
|
||||||
|
// Limit for Storage
|
||||||
|
await expect(page.getByText(/of 1 GB/i)).toBeVisible();
|
||||||
|
|
||||||
|
// Limit for Users
|
||||||
|
await expect(page.getByText(/of 10000/i)).toBeVisible();
|
||||||
|
|
||||||
|
// Limit for Functions
|
||||||
|
await expect(page.getByText(/of 10$/i, { exact: true })).toBeVisible();
|
||||||
|
});
|
||||||
113
dashboard/e2e/utils.ts
Normal file
113
dashboard/e2e/utils.ts
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
import type { Page } from '@playwright/test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a project by navigating to the project's overview page.
|
||||||
|
*
|
||||||
|
* @param page - The Playwright page object.
|
||||||
|
* @param workspaceSlug - The slug of the workspace that contains the project.
|
||||||
|
* @param projectSlug - The slug of the project to open.
|
||||||
|
* @param projectName - The name of the project to open.
|
||||||
|
* @returns A promise that resolves when the project is opened.
|
||||||
|
*/
|
||||||
|
export async function openProject({
|
||||||
|
page,
|
||||||
|
projectName,
|
||||||
|
workspaceSlug,
|
||||||
|
projectSlug,
|
||||||
|
}: {
|
||||||
|
page: Page;
|
||||||
|
workspaceSlug: string;
|
||||||
|
projectSlug: string;
|
||||||
|
projectName: string;
|
||||||
|
}) {
|
||||||
|
await page.getByRole('link', { name: projectName }).click();
|
||||||
|
await page.waitForURL(`/${workspaceSlug}/${projectSlug}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares a table by filling out the form.
|
||||||
|
*
|
||||||
|
* @param page - The Playwright page object.
|
||||||
|
* @param name - The name of the table to create.
|
||||||
|
* @param columns - The columns to create in the table.
|
||||||
|
* @returns A promise that resolves when the table is prepared.
|
||||||
|
*/
|
||||||
|
export async function prepareTable({
|
||||||
|
page,
|
||||||
|
name: tableName,
|
||||||
|
primaryKey,
|
||||||
|
columns,
|
||||||
|
}: {
|
||||||
|
page: Page;
|
||||||
|
name: string;
|
||||||
|
primaryKey: string;
|
||||||
|
columns: Array<{
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
nullable?: boolean;
|
||||||
|
unique?: boolean;
|
||||||
|
defaultValue?: string;
|
||||||
|
}>;
|
||||||
|
}) {
|
||||||
|
if (!columns.some(({ name }) => name === primaryKey)) {
|
||||||
|
throw new Error('Primary key must be one of the columns.');
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.getByRole('textbox', { name: /name/i }).first().fill(tableName);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
columns.map(
|
||||||
|
async (
|
||||||
|
{ name: columnName, type, nullable, unique, defaultValue },
|
||||||
|
index,
|
||||||
|
) => {
|
||||||
|
// set name
|
||||||
|
await page.getByPlaceholder(/name/i).nth(index).fill(columnName);
|
||||||
|
|
||||||
|
// set type
|
||||||
|
await page
|
||||||
|
.getByRole('combobox', { name: /type/i })
|
||||||
|
.nth(index)
|
||||||
|
.fill(type);
|
||||||
|
await page.getByRole('option', { name: type }).first().click();
|
||||||
|
|
||||||
|
// optionally set default value
|
||||||
|
if (defaultValue) {
|
||||||
|
await page
|
||||||
|
.getByRole('combobox', { name: /default value/i })
|
||||||
|
.first()
|
||||||
|
.fill(defaultValue);
|
||||||
|
await page
|
||||||
|
.getByRole('option', { name: defaultValue })
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// optionally check unique
|
||||||
|
if (unique) {
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: /unique/i })
|
||||||
|
.nth(index)
|
||||||
|
.check();
|
||||||
|
}
|
||||||
|
|
||||||
|
// optionally check nullable
|
||||||
|
if (nullable) {
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: /nullable/i })
|
||||||
|
.nth(index)
|
||||||
|
.check();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add new column if not last
|
||||||
|
if (index < columns.length - 1) {
|
||||||
|
await page.getByRole('button', { name: /add column/i }).click();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
// select the first column as primary key
|
||||||
|
await page.getByRole('button', { name: /primary key/i }).click();
|
||||||
|
await page.getByRole('option', { name: primaryKey, exact: true }).click();
|
||||||
|
}
|
||||||
27
dashboard/global-setup.ts
Normal file
27
dashboard/global-setup.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { chromium } from '@playwright/test';
|
||||||
|
import {
|
||||||
|
TEST_DASHBOARD_URL,
|
||||||
|
TEST_USER_EMAIL,
|
||||||
|
TEST_USER_PASSWORD,
|
||||||
|
} from './e2e/env';
|
||||||
|
|
||||||
|
async function globalSetup() {
|
||||||
|
const browser = await chromium.launch();
|
||||||
|
const page = await browser.newPage();
|
||||||
|
|
||||||
|
await page.goto(TEST_DASHBOARD_URL);
|
||||||
|
await page.waitForURL(`${TEST_DASHBOARD_URL}/signin`);
|
||||||
|
await page.getByRole('link', { name: /continue with email/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(`${TEST_DASHBOARD_URL}/signin/email`);
|
||||||
|
await page.getByLabel('Email').fill(TEST_USER_EMAIL);
|
||||||
|
await page.getByLabel('Password').fill(TEST_USER_PASSWORD);
|
||||||
|
await page.getByRole('button', { name: /sign in/i }).click();
|
||||||
|
|
||||||
|
await page.waitForURL(TEST_DASHBOARD_URL);
|
||||||
|
await page.context().storageState({ path: 'storageState.json' });
|
||||||
|
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default globalSetup;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
schema:
|
schema:
|
||||||
- http://localhost:1337/v1/graphql:
|
- https://local.graphql.nhost.run/v1:
|
||||||
headers:
|
headers:
|
||||||
x-hasura-admin-secret: nhost-admin-secret
|
x-hasura-admin-secret: nhost-admin-secret
|
||||||
generates:
|
generates:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/dashboard",
|
"name": "@nhost/dashboard",
|
||||||
"version": "0.13.0",
|
"version": "0.13.10",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
@@ -14,10 +14,11 @@
|
|||||||
"nhost:dev": "nhost dev -d",
|
"nhost:dev": "nhost dev -d",
|
||||||
"format": "prettier --write \"src/**/*.{js,ts,tsx,jsx,json,md}\" --plugin-search-dir=.",
|
"format": "prettier --write \"src/**/*.{js,ts,tsx,jsx,json,md}\" --plugin-search-dir=.",
|
||||||
"storybook": "start-storybook -p 6006 -s public",
|
"storybook": "start-storybook -p 6006 -s public",
|
||||||
"build-storybook": "build-storybook"
|
"build-storybook": "build-storybook",
|
||||||
|
"e2e": "npx playwright@1.31.2 install --with-deps && playwright test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.7.3",
|
"@apollo/client": "^3.7.10",
|
||||||
"@codemirror/language": "^6.3.0",
|
"@codemirror/language": "^6.3.0",
|
||||||
"@emotion/cache": "^11.10.5",
|
"@emotion/cache": "^11.10.5",
|
||||||
"@emotion/react": "^11.10.5",
|
"@emotion/react": "^11.10.5",
|
||||||
@@ -25,11 +26,11 @@
|
|||||||
"@emotion/styled": "^11.10.5",
|
"@emotion/styled": "^11.10.5",
|
||||||
"@fontsource/inter": "^4.5.14",
|
"@fontsource/inter": "^4.5.14",
|
||||||
"@fontsource/roboto-mono": "^4.5.8",
|
"@fontsource/roboto-mono": "^4.5.8",
|
||||||
"@graphiql/react": "^0.15.0",
|
"@graphiql/react": "^0.17.0",
|
||||||
"@graphiql/toolkit": "^0.8.0",
|
"@graphiql/toolkit": "^0.8.2",
|
||||||
"@headlessui/react": "^1.6.5",
|
"@headlessui/react": "^1.6.5",
|
||||||
"@heroicons/react": "^1.0.6",
|
"@heroicons/react": "^1.0.6",
|
||||||
"@hookform/resolvers": "^2.9.10",
|
"@hookform/resolvers": "^3.0.0",
|
||||||
"@mui/base": "^5.0.0-alpha.106",
|
"@mui/base": "^5.0.0-alpha.106",
|
||||||
"@mui/material": "^5.10.14",
|
"@mui/material": "^5.10.14",
|
||||||
"@mui/system": "^5.10.14",
|
"@mui/system": "^5.10.14",
|
||||||
@@ -37,7 +38,7 @@
|
|||||||
"@nhost/nextjs": "workspace:*",
|
"@nhost/nextjs": "workspace:*",
|
||||||
"@nhost/react-apollo": "workspace:*",
|
"@nhost/react-apollo": "workspace:*",
|
||||||
"@segment/snippet": "^4.15.3",
|
"@segment/snippet": "^4.15.3",
|
||||||
"@stripe/react-stripe-js": "^1.10.0",
|
"@stripe/react-stripe-js": "^2.0.0",
|
||||||
"@stripe/stripe-js": "^1.35.0",
|
"@stripe/stripe-js": "^1.35.0",
|
||||||
"@tailwindcss/forms": "^0.5.3",
|
"@tailwindcss/forms": "^0.5.3",
|
||||||
"@tanstack/react-query": "^4.16.1",
|
"@tanstack/react-query": "^4.16.1",
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
"clsx": "^1.2.1",
|
"clsx": "^1.2.1",
|
||||||
"date-fns": "^2.29.3",
|
"date-fns": "^2.29.3",
|
||||||
"generate-password": "^1.7.0",
|
"generate-password": "^1.7.0",
|
||||||
"graphiql": "^2.2.0",
|
"graphiql": "^2.4.0",
|
||||||
"graphql": "^16.6.0",
|
"graphql": "^16.6.0",
|
||||||
"graphql-request": "^4.3.0",
|
"graphql-request": "^4.3.0",
|
||||||
"graphql-tag": "^2.12.6",
|
"graphql-tag": "^2.12.6",
|
||||||
@@ -62,7 +63,7 @@
|
|||||||
"prettysize": "^2.0.0",
|
"prettysize": "^2.0.0",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-error-boundary": "^3.1.4",
|
"react-error-boundary": "^4.0.0",
|
||||||
"react-hook-form": "^7.42.1",
|
"react-hook-form": "^7.42.1",
|
||||||
"react-hot-toast": "^2.4.0",
|
"react-hot-toast": "^2.4.0",
|
||||||
"react-is": "18.2.0",
|
"react-is": "18.2.0",
|
||||||
@@ -70,23 +71,25 @@
|
|||||||
"react-merge-refs": "^1.1.0",
|
"react-merge-refs": "^1.1.0",
|
||||||
"react-syntax-highlighter": "^15.4.5",
|
"react-syntax-highlighter": "^15.4.5",
|
||||||
"react-table": "^7.8.0",
|
"react-table": "^7.8.0",
|
||||||
"sharp": "^0.31.2",
|
"sharp": "^0.32.0",
|
||||||
"slugify": "^1.6.5",
|
"slugify": "^1.6.5",
|
||||||
"stripe": "^10.17.0",
|
"stripe": "^10.17.0",
|
||||||
"tailwind-merge": "^1.8.0",
|
"tailwind-merge": "^1.8.0",
|
||||||
"utility-types": "^3.10.0",
|
"utility-types": "^3.10.0",
|
||||||
"validator": "^13.7.0",
|
"validator": "^13.7.0",
|
||||||
"yup": "^0.32.11",
|
"yup": "^1.0.2",
|
||||||
"yup-password": "^0.2.2"
|
"yup-password": "^0.2.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.20.2",
|
"@babel/core": "^7.20.2",
|
||||||
|
"@faker-js/faker": "^7.6.0",
|
||||||
"@graphql-codegen/cli": "^3.0.0",
|
"@graphql-codegen/cli": "^3.0.0",
|
||||||
"@graphql-codegen/typescript": "^3.0.0",
|
"@graphql-codegen/typescript": "^3.0.0",
|
||||||
"@graphql-codegen/typescript-graphql-request": "^4.5.1",
|
"@graphql-codegen/typescript-graphql-request": "^4.5.1",
|
||||||
"@graphql-codegen/typescript-operations": "^3.0.0",
|
"@graphql-codegen/typescript-operations": "^3.0.0",
|
||||||
"@graphql-codegen/typescript-react-apollo": "^3.3.1",
|
"@graphql-codegen/typescript-react-apollo": "^3.3.1",
|
||||||
"@next/bundle-analyzer": "^12.3.1",
|
"@next/bundle-analyzer": "^12.3.1",
|
||||||
|
"@playwright/test": "^1.31.2",
|
||||||
"@storybook/addon-actions": "^6.5.14",
|
"@storybook/addon-actions": "^6.5.14",
|
||||||
"@storybook/addon-essentials": "^6.5.14",
|
"@storybook/addon-essentials": "^6.5.14",
|
||||||
"@storybook/addon-interactions": "^6.5.14",
|
"@storybook/addon-interactions": "^6.5.14",
|
||||||
@@ -116,6 +119,7 @@
|
|||||||
"babel-loader": "^8.3.0",
|
"babel-loader": "^8.3.0",
|
||||||
"babel-plugin-transform-remove-console": "^6.9.4",
|
"babel-plugin-transform-remove-console": "^6.9.4",
|
||||||
"csstype": "^3.0.10",
|
"csstype": "^3.0.10",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
"encoding": "^0.1.13",
|
"encoding": "^0.1.13",
|
||||||
"eslint": "^8.28.0",
|
"eslint": "^8.28.0",
|
||||||
"eslint-config-airbnb": "19.0.4",
|
"eslint-config-airbnb": "19.0.4",
|
||||||
@@ -161,4 +165,4 @@
|
|||||||
"msw": {
|
"msw": {
|
||||||
"workerDirectory": "public"
|
"workerDirectory": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
dashboard/playwright.config.ts
Normal file
32
dashboard/playwright.config.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
|
import dotenv from 'dotenv';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
dotenv.config({ path: path.resolve(__dirname, '.env.test') });
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './e2e',
|
||||||
|
timeout: 30 * 1000,
|
||||||
|
expect: {
|
||||||
|
timeout: 5000,
|
||||||
|
},
|
||||||
|
fullyParallel: true,
|
||||||
|
forbidOnly: !!process.env.CI,
|
||||||
|
retries: process.env.CI ? 2 : 0,
|
||||||
|
workers: process.env.CI ? 1 : undefined,
|
||||||
|
reporter: 'html',
|
||||||
|
globalSetup: require.resolve('./global-setup'),
|
||||||
|
use: {
|
||||||
|
actionTimeout: 0,
|
||||||
|
trace: 'on-first-retry',
|
||||||
|
storageState: 'storageState.json',
|
||||||
|
baseURL: process.env.NHOST_TEST_DASHBOARD_URL,
|
||||||
|
},
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'chromium',
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
@@ -9,28 +9,39 @@ import Link from '@/ui/v2/Link';
|
|||||||
import Text from '@/ui/v2/Text';
|
import Text from '@/ui/v2/Text';
|
||||||
import { copy } from '@/utils/copy';
|
import { copy } from '@/utils/copy';
|
||||||
import { getApplicationStatusString } from '@/utils/helpers';
|
import { getApplicationStatusString } from '@/utils/helpers';
|
||||||
import { triggerToast } from '@/utils/toast';
|
import getServerError from '@/utils/settings/getServerError';
|
||||||
import { formatDistance } from 'date-fns';
|
import { formatDistance } from 'date-fns';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
|
import { toast } from 'react-hot-toast';
|
||||||
|
|
||||||
export default function ApplicationInfo() {
|
export default function ApplicationInfo() {
|
||||||
const { currentApplication } = useCurrentWorkspaceAndApplication();
|
const { currentApplication } = useCurrentWorkspaceAndApplication();
|
||||||
const [deleteApplication, { client }] = useDeleteApplicationMutation({
|
const [deleteApplication] = useDeleteApplicationMutation({
|
||||||
refetchQueries: [GetOneUserDocument],
|
refetchQueries: [GetOneUserDocument],
|
||||||
});
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
async function handleClickRemove() {
|
async function handleClickRemove() {
|
||||||
await deleteApplication({
|
try {
|
||||||
variables: {
|
await toast.promise(
|
||||||
appId: currentApplication.id,
|
deleteApplication({
|
||||||
},
|
variables: {
|
||||||
});
|
appId: currentApplication.id,
|
||||||
await router.push('/');
|
},
|
||||||
await client.refetchQueries({
|
}),
|
||||||
include: ['getOneUser'],
|
{
|
||||||
});
|
loading: 'Deleting project...',
|
||||||
triggerToast(`${currentApplication.name} deleted`);
|
success: 'The project has been deleted successfully.',
|
||||||
|
error: getServerError(
|
||||||
|
'An error occurred while deleting the project. Please try again.',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await router.push('/');
|
||||||
|
} catch {
|
||||||
|
// Note: The toast will handle the error.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -3,54 +3,81 @@ import { ChangePlanModal } from '@/components/applications/ChangePlanModal';
|
|||||||
import { StagingMetadata } from '@/components/applications/StagingMetadata';
|
import { StagingMetadata } from '@/components/applications/StagingMetadata';
|
||||||
import { useDialog } from '@/components/common/DialogProvider';
|
import { useDialog } from '@/components/common/DialogProvider';
|
||||||
import Container from '@/components/layout/Container';
|
import Container from '@/components/layout/Container';
|
||||||
import { useUpdateApplicationMutation } from '@/generated/graphql';
|
import {
|
||||||
|
GetOneUserDocument,
|
||||||
|
useGetFreeAndActiveProjectsQuery,
|
||||||
|
useUnpauseApplicationMutation,
|
||||||
|
} from '@/generated/graphql';
|
||||||
import { useCurrentWorkspaceAndApplication } from '@/hooks/useCurrentWorkspaceAndApplication';
|
import { useCurrentWorkspaceAndApplication } from '@/hooks/useCurrentWorkspaceAndApplication';
|
||||||
import { ApplicationStatus } from '@/types/application';
|
|
||||||
import { Modal } from '@/ui';
|
import { Modal } from '@/ui';
|
||||||
|
import { Alert } from '@/ui/Alert';
|
||||||
|
import ActivityIndicator from '@/ui/v2/ActivityIndicator';
|
||||||
|
import Box from '@/ui/v2/Box';
|
||||||
import Button from '@/ui/v2/Button';
|
import Button from '@/ui/v2/Button';
|
||||||
import Text from '@/ui/v2/Text';
|
import Text from '@/ui/v2/Text';
|
||||||
import { discordAnnounce } from '@/utils/discordAnnounce';
|
import { MAX_FREE_PROJECTS } from '@/utils/CONSTANTS';
|
||||||
import { triggerToast } from '@/utils/toast';
|
import { getToastStyleProps } from '@/utils/settings/settingsConstants';
|
||||||
import { updateOwnCache } from '@/utils/updateOwnCache';
|
import type { ApolloError } from '@apollo/client';
|
||||||
import { useUserData } from '@nhost/nextjs';
|
import { useUserData } from '@nhost/nextjs';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { toast } from 'react-hot-toast';
|
||||||
import { RemoveApplicationModal } from './RemoveApplicationModal';
|
import { RemoveApplicationModal } from './RemoveApplicationModal';
|
||||||
|
|
||||||
export default function ApplicationPaused() {
|
export default function ApplicationPaused() {
|
||||||
const { openAlertDialog } = useDialog();
|
const { openAlertDialog } = useDialog();
|
||||||
const { currentWorkspace, currentApplication } =
|
const { currentWorkspace, currentApplication } =
|
||||||
useCurrentWorkspaceAndApplication();
|
useCurrentWorkspaceAndApplication();
|
||||||
const [changingApplicationStateLoading, setChangingApplicationStateLoading] =
|
const { id } = useUserData();
|
||||||
useState(false);
|
|
||||||
const [updateApplication, { client }] = useUpdateApplicationMutation();
|
|
||||||
const { id, email } = useUserData();
|
|
||||||
const isOwner = currentWorkspace.members.some(
|
const isOwner = currentWorkspace.members.some(
|
||||||
({ userId, type }) => userId === id && type === 'owner',
|
({ userId, type }) => userId === id && type === 'owner',
|
||||||
);
|
);
|
||||||
const isPro = currentApplication.plan.name === 'Pro';
|
|
||||||
const [showDeletingModal, setShowDeletingModal] = useState(false);
|
const [showDeletingModal, setShowDeletingModal] = useState(false);
|
||||||
|
const [unpauseApplication, { loading: changingApplicationStateLoading }] =
|
||||||
|
useUnpauseApplicationMutation({
|
||||||
|
refetchQueries: [GetOneUserDocument],
|
||||||
|
});
|
||||||
|
|
||||||
|
const { data, loading } = useGetFreeAndActiveProjectsQuery({
|
||||||
|
variables: { userId: id },
|
||||||
|
fetchPolicy: 'cache-and-network',
|
||||||
|
});
|
||||||
|
|
||||||
|
const numberOfFreeAndLiveProjects = data?.freeAndActiveProjects.length || 0;
|
||||||
|
const wakeUpDisabled = numberOfFreeAndLiveProjects >= MAX_FREE_PROJECTS;
|
||||||
|
|
||||||
async function handleTriggerUnpausing() {
|
async function handleTriggerUnpausing() {
|
||||||
setChangingApplicationStateLoading(true);
|
|
||||||
try {
|
try {
|
||||||
await updateApplication({
|
await toast.promise(
|
||||||
variables: {
|
unpauseApplication({ variables: { appId: currentApplication.id } }),
|
||||||
appId: currentApplication.id,
|
{
|
||||||
app: {
|
loading: 'Starting the project...',
|
||||||
desiredState: ApplicationStatus.Live,
|
success: `The project has been started successfully.`,
|
||||||
|
error: (arg: ApolloError) => {
|
||||||
|
// we need to get the internal error message from the GraphQL error
|
||||||
|
const { internal } = arg.graphQLErrors[0]?.extensions || {};
|
||||||
|
const { message } = (internal as Record<string, any>)?.error || {};
|
||||||
|
|
||||||
|
// we use the default Apollo error message if we can't find the
|
||||||
|
// internal error message
|
||||||
|
return (
|
||||||
|
message ||
|
||||||
|
arg.message ||
|
||||||
|
'An error occurred while waking up the project. Please try again.'
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
getToastStyleProps(),
|
||||||
await updateOwnCache(client);
|
|
||||||
discordAnnounce(
|
|
||||||
`App ${currentApplication.name} (${email}) set to awake.`,
|
|
||||||
);
|
);
|
||||||
triggerToast(`${currentApplication.name} set to awake.`);
|
} catch {
|
||||||
} catch (e) {
|
// Note: The toast will handle the error.
|
||||||
triggerToast(`Error trying to awake ${currentApplication.name}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <ActivityIndicator label="Loading user data..." delay={1000} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Modal
|
<Modal
|
||||||
@@ -65,7 +92,7 @@ export default function ApplicationPaused() {
|
|||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Container className="mx-auto mt-20 grid max-w-sm grid-flow-row gap-2 text-center">
|
<Container className="mx-auto mt-20 grid max-w-lg grid-flow-row gap-4 text-center">
|
||||||
<div className="mx-auto flex w-centImage flex-col text-center">
|
<div className="mx-auto flex w-centImage flex-col text-center">
|
||||||
<Image
|
<Image
|
||||||
src="/assets/PausedApp.svg"
|
src="/assets/PausedApp.svg"
|
||||||
@@ -75,16 +102,18 @@ export default function ApplicationPaused() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Text variant="h3" component="h1" className="mt-4">
|
<Box className="grid grid-flow-row gap-1">
|
||||||
{currentApplication.name} is sleeping
|
<Text variant="h3" component="h1">
|
||||||
</Text>
|
{currentApplication.name} is sleeping
|
||||||
|
</Text>
|
||||||
|
|
||||||
<Text className="mt-1">
|
<Text>
|
||||||
Projects on the free plan stop responding to API calls after 7 days of
|
Starter projects stop responding to API calls after 7 days of
|
||||||
no traffic.
|
inactivity. Upgrade to Pro to avoid autosleep.
|
||||||
</Text>
|
</Text>
|
||||||
|
</Box>
|
||||||
|
|
||||||
{!isPro && (
|
<Box className="grid grid-flow-row gap-2">
|
||||||
<Button
|
<Button
|
||||||
className="mx-auto w-full max-w-[280px]"
|
className="mx-auto w-full max-w-[280px]"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -101,32 +130,41 @@ export default function ApplicationPaused() {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Upgrade to Pro to avoid autosleep
|
Upgrade to Pro
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="grid grid-flow-row gap-2">
|
|
||||||
<Button
|
|
||||||
variant="borderless"
|
|
||||||
className="mx-auto w-full max-w-[280px]"
|
|
||||||
loading={changingApplicationStateLoading}
|
|
||||||
disabled={changingApplicationStateLoading}
|
|
||||||
onClick={handleTriggerUnpausing}
|
|
||||||
>
|
|
||||||
Wake Up
|
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{isOwner && (
|
<div className="grid grid-flow-row gap-2">
|
||||||
<Button
|
<Button
|
||||||
color="error"
|
|
||||||
variant="borderless"
|
variant="borderless"
|
||||||
className="mx-auto w-full max-w-[280px]"
|
className="mx-auto w-full max-w-[280px]"
|
||||||
onClick={() => setShowDeletingModal(true)}
|
loading={changingApplicationStateLoading}
|
||||||
|
disabled={changingApplicationStateLoading || wakeUpDisabled}
|
||||||
|
onClick={handleTriggerUnpausing}
|
||||||
>
|
>
|
||||||
Delete Project
|
Wake Up
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
|
||||||
</div>
|
{wakeUpDisabled && (
|
||||||
|
<Alert severity="warning" className="mx-auto max-w-xs text-left">
|
||||||
|
Note: Only one free project can be active at any given time.
|
||||||
|
Please pause your active free project before unpausing{' '}
|
||||||
|
{currentApplication.name}.
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isOwner && (
|
||||||
|
<Button
|
||||||
|
color="error"
|
||||||
|
variant="borderless"
|
||||||
|
className="mx-auto w-full max-w-[280px]"
|
||||||
|
onClick={() => setShowDeletingModal(true)}
|
||||||
|
>
|
||||||
|
Delete Project
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
|
||||||
<StagingMetadata>
|
<StagingMetadata>
|
||||||
<ApplicationInfo />
|
<ApplicationInfo />
|
||||||
</StagingMetadata>
|
</StagingMetadata>
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import Divider from '@/ui/v2/Divider';
|
|||||||
import Text from '@/ui/v2/Text';
|
import Text from '@/ui/v2/Text';
|
||||||
import { discordAnnounce } from '@/utils/discordAnnounce';
|
import { discordAnnounce } from '@/utils/discordAnnounce';
|
||||||
import { triggerToast } from '@/utils/toast';
|
import { triggerToast } from '@/utils/toast';
|
||||||
import { useDeleteApplicationMutation } from '@/utils/__generated__/graphql';
|
import {
|
||||||
|
GetOneUserDocument,
|
||||||
|
useDeleteApplicationMutation,
|
||||||
|
} from '@/utils/__generated__/graphql';
|
||||||
import router from 'next/router';
|
import router from 'next/router';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
@@ -42,7 +45,9 @@ export function RemoveApplicationModal({
|
|||||||
description,
|
description,
|
||||||
className,
|
className,
|
||||||
}: RemoveApplicationModalProps) {
|
}: RemoveApplicationModalProps) {
|
||||||
const [deleteApplication, { client }] = useDeleteApplicationMutation();
|
const [deleteApplication] = useDeleteApplicationMutation({
|
||||||
|
refetchQueries: [GetOneUserDocument],
|
||||||
|
});
|
||||||
const [loadingRemove, setLoadingRemove] = useState(false);
|
const [loadingRemove, setLoadingRemove] = useState(false);
|
||||||
const { currentApplication } = useCurrentWorkspaceAndApplication();
|
const { currentApplication } = useCurrentWorkspaceAndApplication();
|
||||||
|
|
||||||
@@ -73,9 +78,6 @@ export function RemoveApplicationModal({
|
|||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
await router.push('/');
|
await router.push('/');
|
||||||
await client.refetchQueries({
|
|
||||||
include: ['getOneUser'],
|
|
||||||
});
|
|
||||||
triggerToast(`${currentApplication.name} deleted`);
|
triggerToast(`${currentApplication.name} deleted`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,9 +111,8 @@ export function RenderWorkspacesWithApps({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<StateBadge
|
<StateBadge
|
||||||
status={checkStatusOfTheApplication(
|
state={checkStatusOfTheApplication(app.appStates)}
|
||||||
app.appStates,
|
desiredState={app.desiredState}
|
||||||
)}
|
|
||||||
title={getApplicationStatusString(
|
title={getApplicationStatusString(
|
||||||
checkStatusOfTheApplication(app.appStates),
|
checkStatusOfTheApplication(app.appStates),
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { PropsWithChildren } from 'react';
|
|||||||
export function StagingMetadata({ children }: PropsWithChildren<unknown>) {
|
export function StagingMetadata({ children }: PropsWithChildren<unknown>) {
|
||||||
return (
|
return (
|
||||||
isDevOrStaging() && (
|
isDevOrStaging() && (
|
||||||
<div className="mt-10">
|
<div className="mx-auto mt-10 max-w-sm">
|
||||||
<Box className="mx-auto flex flex-col rounded-md border p-5 text-center">
|
<Box className="mx-auto flex flex-col rounded-md border p-5 text-center">
|
||||||
<Status status={StatusEnum.Deploying}>Internal info</Status>
|
<Status status={StatusEnum.Deploying}>Internal info</Status>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ function AddPaymentMethodForm({
|
|||||||
|
|
||||||
if (createPaymentMethodError) {
|
if (createPaymentMethodError) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
createPaymentMethodError.message || 'Unknown error occurred.',
|
createPaymentMethodError.message ||
|
||||||
|
'An unknown error occurred. Please try again.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +91,10 @@ function AddPaymentMethodForm({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (attachPaymentMethodError) {
|
if (attachPaymentMethodError) {
|
||||||
throw Error((attachPaymentMethodError as any).response.data);
|
throw new Error(
|
||||||
|
(attachPaymentMethodError as any)?.response?.data ||
|
||||||
|
'An unknown error occurred. Please try again.',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update workspace with new country code in database
|
// update workspace with new country code in database
|
||||||
@@ -151,7 +155,7 @@ function AddPaymentMethodForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="w-modal2 px-6 pt-6 pb-6 text-left rounded-lg">
|
<Box className="w-modal2 rounded-lg px-6 pt-6 pb-6 text-left">
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<Text className="text-center text-lg font-medium">
|
<Text className="text-center text-lg font-medium">
|
||||||
@@ -203,7 +207,7 @@ function AddPaymentMethodForm({
|
|||||||
|
|
||||||
type BillingPaymentMethodFormProps = {
|
type BillingPaymentMethodFormProps = {
|
||||||
close: () => void;
|
close: () => void;
|
||||||
onPaymentMethodAdded?: () => Promise<void>;
|
onPaymentMethodAdded?: (e?: any) => Promise<void>;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default function DataGridDateCell<TData extends object>({
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const { year, month, day, hour, minute, second } = getDateComponents(date, {
|
const { year, month, day, hour, minute, second } = getDateComponents(date, {
|
||||||
adjustTimezone: specificType === 'timetz' || specificType === 'timestamptz',
|
adjustTimezone: ['date', 'timetz', 'timestamptz'].includes(specificType),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { inputRef, focusCell, isEditing, cancelEditCell } =
|
const { inputRef, focusCell, isEditing, cancelEditCell } =
|
||||||
|
|||||||
@@ -39,17 +39,17 @@ const ruleGroupSchema = Yup.object().shape({
|
|||||||
|
|
||||||
const baseValidationSchema = Yup.object().shape({
|
const baseValidationSchema = Yup.object().shape({
|
||||||
filter: ruleGroupSchema.nullable().required('Please select a filter type.'),
|
filter: ruleGroupSchema.nullable().required('Please select a filter type.'),
|
||||||
columns: Yup.array().of(Yup.string()).nullable(true),
|
columns: Yup.array().of(Yup.string()).nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectValidationSchema = baseValidationSchema.shape({
|
const selectValidationSchema = baseValidationSchema.shape({
|
||||||
limit: Yup.number()
|
limit: Yup.number()
|
||||||
.label('Limit')
|
.label('Limit')
|
||||||
.min(0, 'Limit must not be negative.')
|
.min(0, 'Limit must not be negative.')
|
||||||
.nullable(true),
|
.nullable(),
|
||||||
allowAggregations: Yup.boolean().nullable(true),
|
allowAggregations: Yup.boolean().nullable(),
|
||||||
queryRootFields: Yup.array().of(Yup.string()).nullable(true),
|
queryRootFields: Yup.array().of(Yup.string()).nullable(),
|
||||||
subscriptionRootFields: Yup.array().of(Yup.string()).nullable(true),
|
subscriptionRootFields: Yup.array().of(Yup.string()).nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnPresetSchema = Yup.object().shape({
|
const columnPresetSchema = Yup.object().shape({
|
||||||
@@ -88,17 +88,17 @@ const columnPresetSchema = Yup.object().shape({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const insertValidationSchema = baseValidationSchema.shape({
|
const insertValidationSchema = baseValidationSchema.shape({
|
||||||
backendOnly: Yup.boolean().nullable(true),
|
backendOnly: Yup.boolean().nullable(),
|
||||||
columnPresets: Yup.array().of(columnPresetSchema).nullable(true),
|
columnPresets: Yup.array().of(columnPresetSchema).nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateValidationSchema = baseValidationSchema.shape({
|
const updateValidationSchema = baseValidationSchema.shape({
|
||||||
backendOnly: Yup.boolean().nullable(true),
|
backendOnly: Yup.boolean().nullable(),
|
||||||
columnPresets: Yup.array().of(columnPresetSchema).nullable(true),
|
columnPresets: Yup.array().of(columnPresetSchema).nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteValidationSchema = baseValidationSchema.shape({
|
const deleteValidationSchema = baseValidationSchema.shape({
|
||||||
columnPresets: Yup.array().of(columnPresetSchema).nullable(true),
|
columnPresets: Yup.array().of(columnPresetSchema).nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const validationSchemas: Record<DatabaseAction, Yup.ObjectSchema<any>> = {
|
const validationSchemas: Record<DatabaseAction, Yup.ObjectSchema<any>> = {
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ export function InviteAnnounce() {
|
|||||||
workspaceMemberInviteId: inviteId,
|
workspaceMemberInviteId: inviteId,
|
||||||
isAccepted: false,
|
isAccepted: false,
|
||||||
},
|
},
|
||||||
{ useAxios: false },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ignoreError) {
|
if (ignoreError) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import Link from 'next/link';
|
|||||||
|
|
||||||
export default function Sidebar() {
|
export default function Sidebar() {
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-flow-row gap-8 mt-2 ml-10 w-full md:grid md:w-workspaceSidebar content-start">
|
<div className="mt-2 grid w-full grid-flow-row content-start gap-8 md:ml-10 md:grid md:w-workspaceSidebar">
|
||||||
<WorkspaceSection />
|
<WorkspaceSection />
|
||||||
<Resources />
|
<Resources />
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import { UserDataProvider } from '@/context/workspace1-context';
|
|||||||
import type { Project } from '@/types/application';
|
import type { Project } from '@/types/application';
|
||||||
import { ApplicationStatus } from '@/types/application';
|
import { ApplicationStatus } from '@/types/application';
|
||||||
import type { Workspace } from '@/types/workspace';
|
import type { Workspace } from '@/types/workspace';
|
||||||
|
import nhostGraphQLLink from '@/utils/msw/mocks/graphql/nhostGraphQLLink';
|
||||||
import { render, screen, waitForElementToBeRemoved } from '@/utils/testUtils';
|
import { render, screen, waitForElementToBeRemoved } from '@/utils/testUtils';
|
||||||
import { graphql, rest } from 'msw';
|
import { rest } from 'msw';
|
||||||
import { setupServer } from 'msw/node';
|
import { setupServer } from 'msw/node';
|
||||||
import { afterAll, beforeAll, vi } from 'vitest';
|
import { afterAll, beforeAll, vi } from 'vitest';
|
||||||
import OverviewDeployments from '.';
|
import OverviewDeployments from '.';
|
||||||
@@ -73,13 +74,11 @@ const mockWorkspace: Workspace = {
|
|||||||
applications: [mockApplication],
|
applications: [mockApplication],
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockGraphqlLink = graphql.link('http://localhost:1337/v1/graphql');
|
|
||||||
|
|
||||||
const server = setupServer(
|
const server = setupServer(
|
||||||
rest.get('http://localhost:1337/v1/graphql', (req, res, ctx) =>
|
rest.get('https://local.graphql.nhost.run/v1', (_req, res, ctx) =>
|
||||||
res(ctx.status(200)),
|
res(ctx.status(200)),
|
||||||
),
|
),
|
||||||
mockGraphqlLink.operation(async (req, res, ctx) =>
|
nhostGraphQLLink.operation(async (_req, res, ctx) =>
|
||||||
res(
|
res(
|
||||||
ctx.data({
|
ctx.data({
|
||||||
deployments: [],
|
deployments: [],
|
||||||
@@ -143,7 +142,7 @@ test('should render an empty state when GitHub is connected, but there are no de
|
|||||||
|
|
||||||
test('should render a list of deployments', async () => {
|
test('should render a list of deployments', async () => {
|
||||||
server.use(
|
server.use(
|
||||||
mockGraphqlLink.operation(async (req, res, ctx) => {
|
nhostGraphQLLink.operation(async (req, res, ctx) => {
|
||||||
const requestPayload = await req.json();
|
const requestPayload = await req.json();
|
||||||
|
|
||||||
if (requestPayload.operationName === 'ScheduledOrPendingDeploymentsSub') {
|
if (requestPayload.operationName === 'ScheduledOrPendingDeploymentsSub') {
|
||||||
@@ -193,7 +192,7 @@ test('should render a list of deployments', async () => {
|
|||||||
|
|
||||||
test('should disable redeployments if a deployment is already in progress', async () => {
|
test('should disable redeployments if a deployment is already in progress', async () => {
|
||||||
server.use(
|
server.use(
|
||||||
mockGraphqlLink.operation(async (req, res, ctx) => {
|
nhostGraphQLLink.operation(async (req, res, ctx) => {
|
||||||
const requestPayload = await req.json();
|
const requestPayload = await req.json();
|
||||||
|
|
||||||
if (requestPayload.operationName === 'ScheduledOrPendingDeploymentsSub') {
|
if (requestPayload.operationName === 'ScheduledOrPendingDeploymentsSub') {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export default function DisableNewUsersSettings() {
|
|||||||
const form = useForm<DisableNewUsersFormValues>({
|
const form = useForm<DisableNewUsersFormValues>({
|
||||||
reValidateMode: 'onSubmit',
|
reValidateMode: 'onSubmit',
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
disabled: !!data?.config?.auth?.signUp?.enabled,
|
disabled: !data?.config?.auth?.signUp?.enabled,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -24,22 +24,30 @@ import { twMerge } from 'tailwind-merge';
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
teamId: Yup.string().label('Team ID').when('enabled', {
|
teamId: Yup.string()
|
||||||
is: true,
|
.label('Team ID')
|
||||||
then: Yup.string().required(),
|
.when('enabled', {
|
||||||
}),
|
is: true,
|
||||||
keyId: Yup.string().label('Key ID').when('enabled', {
|
then: (schema) => schema.required(),
|
||||||
is: true,
|
}),
|
||||||
then: Yup.string().required(),
|
keyId: Yup.string()
|
||||||
}),
|
.label('Key ID')
|
||||||
clientId: Yup.string().label('Client ID').when('enabled', {
|
.when('enabled', {
|
||||||
is: true,
|
is: true,
|
||||||
then: Yup.string().required(),
|
then: (schema) => schema.required(),
|
||||||
}),
|
}),
|
||||||
privateKey: Yup.string().label('Private Key').when('enabled', {
|
clientId: Yup.string()
|
||||||
is: true,
|
.label('Client ID')
|
||||||
then: Yup.string().required(),
|
.when('enabled', {
|
||||||
}),
|
is: true,
|
||||||
|
then: (schema) => schema.required(),
|
||||||
|
}),
|
||||||
|
privateKey: Yup.string()
|
||||||
|
.label('Private Key')
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (schema) => schema.required(),
|
||||||
|
}),
|
||||||
enabled: Yup.boolean(),
|
enabled: Yup.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,18 @@ import { useFormContext } from 'react-hook-form';
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
export const baseProviderValidationSchema = Yup.object({
|
export const baseProviderValidationSchema = Yup.object({
|
||||||
clientId: Yup.string().label('Client ID').when('enabled', {
|
clientId: Yup.string()
|
||||||
is: true,
|
.label('Client ID')
|
||||||
then: Yup.string().required(),
|
.when('enabled', {
|
||||||
}),
|
is: true,
|
||||||
clientSecret: Yup.string().label('Client Secret').when('enabled', {
|
then: (schema) => schema.required(),
|
||||||
is: true,
|
}),
|
||||||
then: Yup.string().required(),
|
clientSecret: Yup.string()
|
||||||
}),
|
.label('Client Secret')
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (schema) => schema.required(),
|
||||||
|
}),
|
||||||
enabled: Yup.bool(),
|
enabled: Yup.bool(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,19 +22,23 @@ import { twMerge } from 'tailwind-merge';
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
accountSid: Yup.string().label('Account SID').when('enabled', {
|
accountSid: Yup.string()
|
||||||
is: true,
|
.label('Account SID')
|
||||||
then: Yup.string().required(),
|
.when('enabled', {
|
||||||
}),
|
is: true,
|
||||||
authToken: Yup.string().label('Auth Token').when('enabled', {
|
then: (schema) => schema.required(),
|
||||||
is: true,
|
}),
|
||||||
then: Yup.string().required(),
|
authToken: Yup.string()
|
||||||
}),
|
.label('Auth Token')
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (schema) => schema.required(),
|
||||||
|
}),
|
||||||
messagingServiceId: Yup.string()
|
messagingServiceId: Yup.string()
|
||||||
.label('Messaging Service ID')
|
.label('Messaging Service ID')
|
||||||
.when('enabled', {
|
.when('enabled', {
|
||||||
is: true,
|
is: true,
|
||||||
then: Yup.string().required(),
|
then: (schema) => schema.required(),
|
||||||
}),
|
}),
|
||||||
enabled: Yup.boolean().label('Enabled'),
|
enabled: Yup.boolean().label('Enabled'),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,14 +23,18 @@ import { twMerge } from 'tailwind-merge';
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
consumerSecret: Yup.string().label('Consumer Secret').when('enabled', {
|
consumerSecret: Yup.string()
|
||||||
is: true,
|
.label('Consumer Secret')
|
||||||
then: Yup.string().required(),
|
.when('enabled', {
|
||||||
}),
|
is: true,
|
||||||
consumerKey: Yup.string().label('Consumer Key').when('enabled', {
|
then: (schema) => schema.required(),
|
||||||
is: true,
|
}),
|
||||||
then: Yup.string().required(),
|
consumerKey: Yup.string()
|
||||||
}),
|
.label('Consumer Key')
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (schema) => schema.required(),
|
||||||
|
}),
|
||||||
enabled: Yup.boolean(),
|
enabled: Yup.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -24,22 +24,30 @@ import { twMerge } from 'tailwind-merge';
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
clientId: Yup.string().label('Client ID').when('enabled', {
|
clientId: Yup.string()
|
||||||
is: true,
|
.label('Client ID')
|
||||||
then: Yup.string().required(),
|
.when('enabled', {
|
||||||
}),
|
is: true,
|
||||||
clientSecret: Yup.string().label('Client Secret').when('enabled', {
|
then: (schema) => schema.required(),
|
||||||
is: true,
|
}),
|
||||||
then: Yup.string().required(),
|
clientSecret: Yup.string()
|
||||||
}),
|
.label('Client Secret')
|
||||||
organization: Yup.string().label('Organization').when('enabled', {
|
.when('enabled', {
|
||||||
is: true,
|
is: true,
|
||||||
then: Yup.string().required(),
|
then: (schema) => schema.required(),
|
||||||
}),
|
}),
|
||||||
connection: Yup.string().label('Connection').when('enabled', {
|
organization: Yup.string()
|
||||||
is: true,
|
.label('Organization')
|
||||||
then: Yup.string().required(),
|
.when('enabled', {
|
||||||
}),
|
is: true,
|
||||||
|
then: (schema) => schema.required(),
|
||||||
|
}),
|
||||||
|
connection: Yup.string()
|
||||||
|
.label('Connection')
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (schema) => schema.required(),
|
||||||
|
}),
|
||||||
enabled: Yup.boolean(),
|
enabled: Yup.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ export interface StateBadgeProps {
|
|||||||
/**
|
/**
|
||||||
* This is the current state of the application.
|
* This is the current state of the application.
|
||||||
*/
|
*/
|
||||||
status: ApplicationStatus;
|
state: ApplicationStatus;
|
||||||
|
/**
|
||||||
|
* This is the desired state of the application.
|
||||||
|
*/
|
||||||
|
desiredState: ApplicationStatus;
|
||||||
/**
|
/**
|
||||||
* The title to show on the application state badge.
|
* The title to show on the application state badge.
|
||||||
*/
|
*/
|
||||||
@@ -24,20 +28,28 @@ function getNormalizedTitle(title: string) {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function StateBadge({ title, status }: StateBadgeProps) {
|
export default function StateBadge({
|
||||||
|
title,
|
||||||
|
state,
|
||||||
|
desiredState,
|
||||||
|
}: StateBadgeProps) {
|
||||||
|
if (
|
||||||
|
desiredState === ApplicationStatus.Paused &&
|
||||||
|
state === ApplicationStatus.Live
|
||||||
|
) {
|
||||||
|
return <Chip size="small" color="default" label="Pausing" />;
|
||||||
|
}
|
||||||
|
|
||||||
const normalizedTitle = getNormalizedTitle(title);
|
const normalizedTitle = getNormalizedTitle(title);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
status === ApplicationStatus.Empty ||
|
state === ApplicationStatus.Empty ||
|
||||||
status === ApplicationStatus.Unpausing
|
state === ApplicationStatus.Unpausing
|
||||||
) {
|
) {
|
||||||
return <Chip size="small" label={normalizedTitle} color="warning" />;
|
return <Chip size="small" label={normalizedTitle} color="warning" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (state === ApplicationStatus.Errored || state === ApplicationStatus.Live) {
|
||||||
status === ApplicationStatus.Errored ||
|
|
||||||
status === ApplicationStatus.Live
|
|
||||||
) {
|
|
||||||
return <Chip size="small" label={normalizedTitle} color="success" />;
|
return <Chip size="small" label={normalizedTitle} color="success" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import SvgIcon from '@/ui/v2/icons/SvgIcon';
|
|||||||
import { styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
import type { RadioProps as MaterialRadioProps } from '@mui/material/Radio';
|
import type { RadioProps as MaterialRadioProps } from '@mui/material/Radio';
|
||||||
import MaterialRadio from '@mui/material/Radio';
|
import MaterialRadio from '@mui/material/Radio';
|
||||||
import type { ForwardedRef, PropsWithoutRef } from 'react';
|
import type { ForwardedRef, PropsWithoutRef, ReactNode } from 'react';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
|
|
||||||
export interface RadioProps extends MaterialRadioProps {
|
export interface RadioProps extends MaterialRadioProps {
|
||||||
@@ -17,7 +17,7 @@ export interface RadioProps extends MaterialRadioProps {
|
|||||||
/**
|
/**
|
||||||
* Label to be displayed next to the radio button.
|
* Label to be displayed next to the radio button.
|
||||||
*/
|
*/
|
||||||
label?: string;
|
label?: ReactNode;
|
||||||
/**
|
/**
|
||||||
* Props to be passed to individual component slots.
|
* Props to be passed to individual component slots.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { styled } from '@mui/material';
|
import { styled } from '@mui/material';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import type { TooltipProps as MaterialTooltipProps } from '@mui/material/Tooltip';
|
import type { TooltipProps as MaterialTooltipProps } from '@mui/material/Tooltip';
|
||||||
import MaterialTooltip, { tooltipClasses } from '@mui/material/Tooltip';
|
import MaterialTooltip, {
|
||||||
|
tooltipClasses as materialTooltipClasses,
|
||||||
|
} from '@mui/material/Tooltip';
|
||||||
import type { ForwardedRef } from 'react';
|
import type { ForwardedRef } from 'react';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
|
|
||||||
@@ -21,7 +23,7 @@ export interface TooltipProps extends MaterialTooltipProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const StyledTooltip = styled(Box)(({ theme }) => ({
|
const StyledTooltip = styled(Box)(({ theme }) => ({
|
||||||
[`&.${tooltipClasses.tooltip}`]: {
|
[`&.${materialTooltipClasses.tooltip}`]: {
|
||||||
fontSize: '0.9375rem',
|
fontSize: '0.9375rem',
|
||||||
lineHeight: '1.375rem',
|
lineHeight: '1.375rem',
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
@@ -36,9 +38,23 @@ const StyledTooltip = styled(Box)(({ theme }) => ({
|
|||||||
'0px 1px 4px rgba(14, 24, 39, 0.1), 0px 8px 24px rgba(14, 24, 39, 0.1)',
|
'0px 1px 4px rgba(14, 24, 39, 0.1), 0px 8px 24px rgba(14, 24, 39, 0.1)',
|
||||||
maxWidth: '17.5rem',
|
maxWidth: '17.5rem',
|
||||||
},
|
},
|
||||||
[`&.${tooltipClasses.tooltipPlacementBottom}`]: {
|
[`& .${materialTooltipClasses.arrow}`]: {
|
||||||
|
color:
|
||||||
|
theme.palette.mode === 'dark'
|
||||||
|
? theme.palette.grey[300]
|
||||||
|
: theme.palette.grey[700],
|
||||||
|
},
|
||||||
|
[`&.${materialTooltipClasses.tooltipPlacementBottom}`]: {
|
||||||
marginTop: `${theme.spacing(0.75)} !important`,
|
marginTop: `${theme.spacing(0.75)} !important`,
|
||||||
},
|
},
|
||||||
|
[`&.${materialTooltipClasses.tooltipPlacementBottom} .${materialTooltipClasses.arrow}`]:
|
||||||
|
{
|
||||||
|
marginTop: `${theme.spacing(-0.5)} !important`,
|
||||||
|
color:
|
||||||
|
theme.palette.mode === 'dark'
|
||||||
|
? theme.palette.grey[300]
|
||||||
|
: theme.palette.grey[700],
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function Tooltip(
|
function Tooltip(
|
||||||
@@ -69,6 +85,8 @@ function Tooltip(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { materialTooltipClasses as tooltipClasses };
|
||||||
|
|
||||||
Tooltip.displayName = 'NhostTooltip';
|
Tooltip.displayName = 'NhostTooltip';
|
||||||
|
|
||||||
export default forwardRef(Tooltip);
|
export default forwardRef(Tooltip);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ export default function CreateUserForm({
|
|||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
<div className="grid grid-flow-row gap-2">
|
<div className="grid grid-flow-row gap-2">
|
||||||
<Button type="submit" loading={isSubmitting} disabled={isSubmitting}>
|
<Button type="submit" disabled={isSubmitting}>
|
||||||
Create
|
Create
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,11 @@ export default function UsersBody({ users, onSubmit }: UsersBodyProps) {
|
|||||||
secondaryAction={
|
secondaryAction={
|
||||||
<Dropdown.Root>
|
<Dropdown.Root>
|
||||||
<Dropdown.Trigger asChild hideChevron>
|
<Dropdown.Trigger asChild hideChevron>
|
||||||
<IconButton variant="borderless" color="secondary">
|
<IconButton
|
||||||
|
variant="borderless"
|
||||||
|
color="secondary"
|
||||||
|
aria-label={`More options for ${user.displayName}`}
|
||||||
|
>
|
||||||
<DotsHorizontalIcon />
|
<DotsHorizontalIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Dropdown.Trigger>
|
</Dropdown.Trigger>
|
||||||
@@ -282,6 +286,7 @@ export default function UsersBody({ users, onSubmit }: UsersBodyProps) {
|
|||||||
<ListItem.Button
|
<ListItem.Button
|
||||||
className="grid h-full w-full grid-cols-1 py-2.5 lg:grid-cols-6"
|
className="grid h-full w-full grid-cols-1 py-2.5 lg:grid-cols-6"
|
||||||
onClick={() => handleViewUser(user)}
|
onClick={() => handleViewUser(user)}
|
||||||
|
aria-label={`View ${user.displayName}`}
|
||||||
>
|
>
|
||||||
<div className="col-span-2 grid grid-flow-col place-content-start gap-4">
|
<div className="col-span-2 grid grid-flow-col place-content-start gap-4">
|
||||||
<Avatar
|
<Avatar
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ export function WorkspaceInvoices() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-18">
|
<div className="mt-18">
|
||||||
<div className="mx-auto max-w-3xl font-display grid grid-flow-row gap-2 justify-start">
|
<div className="mx-auto grid max-w-3xl grid-flow-row justify-start gap-2 font-display">
|
||||||
<Text className="font-medium text-lg">Invoices</Text>
|
<Text className="text-lg font-medium">Invoices</Text>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -23,7 +23,6 @@ export function WorkspaceInvoices() {
|
|||||||
const { res, error } = await nhost.functions.call(
|
const { res, error } = await nhost.functions.call(
|
||||||
'/stripe-create-portal',
|
'/stripe-create-portal',
|
||||||
{ workspaceId: currentWorkspace.id },
|
{ workspaceId: currentWorkspace.id },
|
||||||
{ useAxios: false },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
fragment GetAppRoles on apps {
|
|
||||||
id
|
|
||||||
slug
|
|
||||||
subdomain
|
|
||||||
name
|
|
||||||
authUserDefaultAllowedRoles
|
|
||||||
authUserDefaultRole
|
|
||||||
}
|
|
||||||
|
|
||||||
query getAppRolesAndPermissions($id: uuid!) {
|
|
||||||
app(id: $id) {
|
|
||||||
...GetAppRoles
|
|
||||||
}
|
|
||||||
}
|
|
||||||
5
dashboard/src/gql/app/pauseApplication.graphql
Normal file
5
dashboard/src/gql/app/pauseApplication.graphql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
mutation PauseApplication($appId: uuid!) {
|
||||||
|
updateApp(pk_columns: { id: $appId }, _set: { desiredState: 6 }) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
5
dashboard/src/gql/app/unpauseApplication.graphql
Normal file
5
dashboard/src/gql/app/unpauseApplication.graphql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
mutation UnpauseApplication($appId: uuid!) {
|
||||||
|
updateApp(pk_columns: { id: $appId }, _set: { desiredState: 5 }) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
query getFunctionsLogs($subdomain: String!) {
|
|
||||||
getFunctionLogs(subdomain: $subdomain) {
|
|
||||||
functionPath
|
|
||||||
createdAt
|
|
||||||
message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query getFunctionLog($subdomain: String!, $functionPaths: [String!]) {
|
|
||||||
getFunctionLogs(subdomain: $subdomain, functionPaths: $functionPaths) {
|
|
||||||
functionPath
|
|
||||||
createdAt
|
|
||||||
message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
query getGravatarSettings($id: uuid!) {
|
|
||||||
app(id: $id) {
|
|
||||||
authGravatarEnabled
|
|
||||||
authGravatarDefault
|
|
||||||
authGravatarRating
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
mutation restoreDatabaseBackup($appId: uuid!, $backupId: uuid!) {
|
|
||||||
restoreDatabaseBackup(appId: $appId, backupId: $backupId)
|
|
||||||
}
|
|
||||||
|
|
||||||
mutation scheduleRestoreDatabaseBackup($appId: uuid!, $backupId: uuid!) {
|
|
||||||
scheduleRestoreDatabaseBackup(appId: $appId, backupId: $backupId)
|
|
||||||
}
|
|
||||||
11
dashboard/src/gql/user/getFreeAndActiveProjects.graphql
Normal file
11
dashboard/src/gql/user/getFreeAndActiveProjects.graphql
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
query GetFreeAndActiveProjects($userId: uuid!) {
|
||||||
|
freeAndActiveProjects: apps(
|
||||||
|
where: {
|
||||||
|
creatorUserId: { _eq: $userId }
|
||||||
|
plan: { isFree: { _eq: true } }
|
||||||
|
desiredState: { _eq: 5 }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
import { useGetApplicationStateQuery } from '@/generated/graphql';
|
import {
|
||||||
|
GetOneUserDocument,
|
||||||
|
useGetApplicationStateQuery,
|
||||||
|
} from '@/generated/graphql';
|
||||||
import { ApplicationStatus } from '@/types/application';
|
import { ApplicationStatus } from '@/types/application';
|
||||||
import { discordAnnounce } from '@/utils/discordAnnounce';
|
import { discordAnnounce } from '@/utils/discordAnnounce';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
@@ -30,7 +33,7 @@ export function useCheckProvisioning() {
|
|||||||
|
|
||||||
async function updateOwnCache() {
|
async function updateOwnCache() {
|
||||||
await client.refetchQueries({
|
await client.refetchQueries({
|
||||||
include: ['getOneUser'],
|
include: [GetOneUserDocument],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function useNotFoundRedirect() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const {
|
const {
|
||||||
query: { workspaceSlug, appSlug, updating },
|
query: { workspaceSlug, appSlug, updating },
|
||||||
} = useRouter();
|
} = router;
|
||||||
|
|
||||||
const notIn404Already = router.pathname !== '/404';
|
const notIn404Already = router.pathname !== '/404';
|
||||||
const noResolvedWorkspace = workspaceSlug && currentWorkspace === undefined;
|
const noResolvedWorkspace = workspaceSlug && currentWorkspace === undefined;
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import SettingsContainer from '@/components/settings/SettingsContainer';
|
|||||||
import SettingsLayout from '@/components/settings/SettingsLayout';
|
import SettingsLayout from '@/components/settings/SettingsLayout';
|
||||||
import { useUI } from '@/context/UIContext';
|
import { useUI } from '@/context/UIContext';
|
||||||
import {
|
import {
|
||||||
|
GetOneUserDocument,
|
||||||
useDeleteApplicationMutation,
|
useDeleteApplicationMutation,
|
||||||
useUpdateAppMutation,
|
usePauseApplicationMutation,
|
||||||
|
useUpdateApplicationMutation,
|
||||||
} from '@/generated/graphql';
|
} from '@/generated/graphql';
|
||||||
import { useCurrentWorkspaceAndApplication } from '@/hooks/useCurrentWorkspaceAndApplication';
|
import { useCurrentWorkspaceAndApplication } from '@/hooks/useCurrentWorkspaceAndApplication';
|
||||||
import Input from '@/ui/v2/Input';
|
import Input from '@/ui/v2/Input';
|
||||||
@@ -15,7 +17,6 @@ import { discordAnnounce } from '@/utils/discordAnnounce';
|
|||||||
import { slugifyString } from '@/utils/helpers';
|
import { slugifyString } from '@/utils/helpers';
|
||||||
import getServerError from '@/utils/settings/getServerError';
|
import getServerError from '@/utils/settings/getServerError';
|
||||||
import { getToastStyleProps } from '@/utils/settings/settingsConstants';
|
import { getToastStyleProps } from '@/utils/settings/settingsConstants';
|
||||||
import { updateOwnCache } from '@/utils/updateOwnCache';
|
|
||||||
import { useApolloClient } from '@apollo/client';
|
import { useApolloClient } from '@apollo/client';
|
||||||
import { yupResolver } from '@hookform/resolvers/yup';
|
import { yupResolver } from '@hookform/resolvers/yup';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
@@ -37,11 +38,16 @@ export type ProjectNameValidationSchema = Yup.InferType<
|
|||||||
|
|
||||||
export default function SettingsGeneralPage() {
|
export default function SettingsGeneralPage() {
|
||||||
const { currentApplication } = useCurrentWorkspaceAndApplication();
|
const { currentApplication } = useCurrentWorkspaceAndApplication();
|
||||||
const { openDialog, closeDialog } = useDialog();
|
const { openDialog, openAlertDialog, closeDialog } = useDialog();
|
||||||
const [updateApp] = useUpdateAppMutation();
|
const [updateApp] = useUpdateApplicationMutation();
|
||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
|
const [pauseApplication] = usePauseApplicationMutation({
|
||||||
|
variables: { appId: currentApplication?.id },
|
||||||
|
refetchQueries: [GetOneUserDocument],
|
||||||
|
});
|
||||||
const [deleteApplication] = useDeleteApplicationMutation({
|
const [deleteApplication] = useDeleteApplicationMutation({
|
||||||
variables: { appId: currentApplication?.id },
|
variables: { appId: currentApplication?.id },
|
||||||
|
refetchQueries: [GetOneUserDocument],
|
||||||
});
|
});
|
||||||
const { currentWorkspace } = useCurrentWorkspaceAndApplication();
|
const { currentWorkspace } = useCurrentWorkspaceAndApplication();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -60,7 +66,7 @@ export default function SettingsGeneralPage() {
|
|||||||
|
|
||||||
const { register, formState } = form;
|
const { register, formState } = form;
|
||||||
|
|
||||||
const handleProjectNameChange = async (data: ProjectNameValidationSchema) => {
|
async function handleProjectNameChange(data: ProjectNameValidationSchema) {
|
||||||
// In this bit of code we spread the props of the current path (e.g. /workspace/...) and add one key-value pair: `updating: true`.
|
// In this bit of code we spread the props of the current path (e.g. /workspace/...) and add one key-value pair: `updating: true`.
|
||||||
// We want to indicate that the currently we're in the process of running a mutation state that will affect the routing behaviour of the website
|
// We want to indicate that the currently we're in the process of running a mutation state that will affect the routing behaviour of the website
|
||||||
// i.e. redirecting to 404 if there's no workspace/project with that slug.
|
// i.e. redirecting to 404 if there's no workspace/project with that slug.
|
||||||
@@ -82,7 +88,7 @@ export default function SettingsGeneralPage() {
|
|||||||
|
|
||||||
const updateAppMutation = updateApp({
|
const updateAppMutation = updateApp({
|
||||||
variables: {
|
variables: {
|
||||||
id: currentApplication.id,
|
appId: currentApplication.id,
|
||||||
app: {
|
app: {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
slug: newProjectSlug,
|
slug: newProjectSlug,
|
||||||
@@ -107,35 +113,50 @@ export default function SettingsGeneralPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.refetchQueries({
|
|
||||||
include: ['getOneUser'],
|
|
||||||
});
|
|
||||||
form.reset(undefined, { keepValues: true, keepDirty: false });
|
form.reset(undefined, { keepValues: true, keepDirty: false });
|
||||||
await router.push(
|
await router.push(
|
||||||
`/${currentWorkspace.slug}/${newProjectSlug}/settings/general`,
|
`/${currentWorkspace.slug}/${newProjectSlug}/settings/general`,
|
||||||
);
|
);
|
||||||
|
await client.refetchQueries({ include: [GetOneUserDocument] });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await discordAnnounce(
|
await discordAnnounce(
|
||||||
error.message || 'Error while trying to update application cache',
|
error.message ||
|
||||||
|
'An error occurred while trying to update application cache.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleDeleteApplication = async () => {
|
async function handleDeleteApplication() {
|
||||||
await toast.promise(
|
await toast.promise(
|
||||||
deleteApplication(),
|
deleteApplication(),
|
||||||
{
|
{
|
||||||
loading: `Deleting ${currentApplication.name}...`,
|
loading: `Deleting ${currentApplication.name}...`,
|
||||||
success: `${currentApplication.name} deleted`,
|
success: `${currentApplication.name} has been deleted successfully.`,
|
||||||
error: getServerError(
|
error: getServerError(
|
||||||
`Error while trying to ${currentApplication.name} project name`,
|
`An error occurred while trying to delete the project "${currentApplication.name}". Please try again.`,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
getToastStyleProps(),
|
getToastStyleProps(),
|
||||||
);
|
);
|
||||||
|
|
||||||
await router.push('/');
|
await router.push('/');
|
||||||
await updateOwnCache(client);
|
}
|
||||||
};
|
|
||||||
|
async function handlePauseApplication() {
|
||||||
|
await toast.promise(
|
||||||
|
pauseApplication(),
|
||||||
|
{
|
||||||
|
loading: `Pausing ${currentApplication.name}...`,
|
||||||
|
success: `${currentApplication.name} will be paused, but please note that it may take some time to complete the process.`,
|
||||||
|
error: getServerError(
|
||||||
|
`An error occurred while trying to pause the project "${currentApplication.name}". Please try again.`,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
getToastStyleProps(),
|
||||||
|
);
|
||||||
|
|
||||||
|
await router.push('/');
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container
|
<Container
|
||||||
@@ -171,6 +192,32 @@ export default function SettingsGeneralPage() {
|
|||||||
</Form>
|
</Form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|
||||||
|
{currentApplication.plan.isFree && (
|
||||||
|
<SettingsContainer
|
||||||
|
title="Pause Project"
|
||||||
|
description="While your project is paused, it will not be accessible. You can wake it up anytime after."
|
||||||
|
submitButtonText="Pause"
|
||||||
|
slotProps={{
|
||||||
|
submitButton: {
|
||||||
|
type: 'button',
|
||||||
|
color: 'primary',
|
||||||
|
variant: 'contained',
|
||||||
|
disabled: maintenanceActive,
|
||||||
|
onClick: () => {
|
||||||
|
openAlertDialog({
|
||||||
|
title: 'Pause Project?',
|
||||||
|
payload:
|
||||||
|
'Are you sure you want to pause this project? It will not be accessible until you unpause it.',
|
||||||
|
props: {
|
||||||
|
onPrimaryAction: handlePauseApplication,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<SettingsContainer
|
<SettingsContainer
|
||||||
title="Delete Project"
|
title="Delete Project"
|
||||||
description="The project will be permanently deleted, including its database, metadata, files, etc. This action is irreversible and can not be undone."
|
description="The project will be permanently deleted, including its database, metadata, files, etc. This action is irreversible and can not be undone."
|
||||||
|
|||||||
@@ -11,23 +11,25 @@ import { Modal } from '@/ui/Modal';
|
|||||||
import ActivityIndicator from '@/ui/v2/ActivityIndicator';
|
import ActivityIndicator from '@/ui/v2/ActivityIndicator';
|
||||||
import Box from '@/ui/v2/Box';
|
import Box from '@/ui/v2/Box';
|
||||||
import Button from '@/ui/v2/Button';
|
import Button from '@/ui/v2/Button';
|
||||||
import Checkbox from '@/ui/v2/Checkbox';
|
|
||||||
import IconButton from '@/ui/v2/IconButton';
|
import IconButton from '@/ui/v2/IconButton';
|
||||||
import CopyIcon from '@/ui/v2/icons/CopyIcon';
|
import CopyIcon from '@/ui/v2/icons/CopyIcon';
|
||||||
import Input from '@/ui/v2/Input';
|
import Input from '@/ui/v2/Input';
|
||||||
import InputAdornment from '@/ui/v2/InputAdornment';
|
import InputAdornment from '@/ui/v2/InputAdornment';
|
||||||
import Option from '@/ui/v2/Option';
|
import Option from '@/ui/v2/Option';
|
||||||
|
import Radio from '@/ui/v2/Radio';
|
||||||
|
import RadioGroup from '@/ui/v2/RadioGroup';
|
||||||
import Select from '@/ui/v2/Select';
|
import Select from '@/ui/v2/Select';
|
||||||
import type { TextProps } from '@/ui/v2/Text';
|
import type { TextProps } from '@/ui/v2/Text';
|
||||||
import Text from '@/ui/v2/Text';
|
import Text from '@/ui/v2/Text';
|
||||||
|
import Tooltip from '@/ui/v2/Tooltip';
|
||||||
|
import { MAX_FREE_PROJECTS } from '@/utils/CONSTANTS';
|
||||||
import { copy } from '@/utils/copy';
|
import { copy } from '@/utils/copy';
|
||||||
import { discordAnnounce } from '@/utils/discordAnnounce';
|
|
||||||
import { getErrorMessage } from '@/utils/getErrorMessage';
|
import { getErrorMessage } from '@/utils/getErrorMessage';
|
||||||
import { getCurrentEnvironment, slugifyString } from '@/utils/helpers';
|
import { getCurrentEnvironment } from '@/utils/helpers';
|
||||||
import { nhost } from '@/utils/nhost';
|
|
||||||
import { planDescriptions } from '@/utils/planDescriptions';
|
import { planDescriptions } from '@/utils/planDescriptions';
|
||||||
import generateRandomDatabasePassword from '@/utils/settings/generateRandomDatabasePassword';
|
import generateRandomDatabasePassword from '@/utils/settings/generateRandomDatabasePassword';
|
||||||
import { resetDatabasePasswordValidationSchema } from '@/utils/settings/resetDatabasePasswordValidationSchema';
|
import { resetDatabasePasswordValidationSchema } from '@/utils/settings/resetDatabasePasswordValidationSchema';
|
||||||
|
import { getToastStyleProps } from '@/utils/settings/settingsConstants';
|
||||||
import { triggerToast } from '@/utils/toast';
|
import { triggerToast } from '@/utils/toast';
|
||||||
import type {
|
import type {
|
||||||
PrefetchNewAppPlansFragment,
|
PrefetchNewAppPlansFragment,
|
||||||
@@ -35,19 +37,25 @@ import type {
|
|||||||
PrefetchNewAppWorkspaceFragment,
|
PrefetchNewAppWorkspaceFragment,
|
||||||
} from '@/utils/__generated__/graphql';
|
} from '@/utils/__generated__/graphql';
|
||||||
import {
|
import {
|
||||||
|
useGetFreeAndActiveProjectsQuery,
|
||||||
useInsertApplicationMutation,
|
useInsertApplicationMutation,
|
||||||
usePrefetchNewAppQuery,
|
usePrefetchNewAppQuery,
|
||||||
} from '@/utils/__generated__/graphql';
|
} from '@/utils/__generated__/graphql';
|
||||||
|
import type { ApolloError } from '@apollo/client';
|
||||||
|
import { useUserData } from '@nhost/nextjs';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import type { ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
import { cloneElement, isValidElement, useState } from 'react';
|
import { cloneElement, isValidElement, useState } from 'react';
|
||||||
|
import { toast } from 'react-hot-toast';
|
||||||
|
import slugify from 'slugify';
|
||||||
import { twMerge } from 'tailwind-merge';
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|
||||||
type NewAppPageProps = {
|
type NewAppPageProps = {
|
||||||
regions: PrefetchNewAppRegionsFragment[];
|
regions: PrefetchNewAppRegionsFragment[];
|
||||||
plans: PrefetchNewAppPlansFragment[];
|
plans: PrefetchNewAppPlansFragment[];
|
||||||
workspaces: PrefetchNewAppWorkspaceFragment[];
|
workspaces: PrefetchNewAppWorkspaceFragment[];
|
||||||
|
numberOfFreeAndLiveProjects: number;
|
||||||
preSelectedWorkspace: PrefetchNewAppWorkspaceFragment;
|
preSelectedWorkspace: PrefetchNewAppWorkspaceFragment;
|
||||||
preSelectedRegion: PrefetchNewAppRegionsFragment;
|
preSelectedRegion: PrefetchNewAppRegionsFragment;
|
||||||
};
|
};
|
||||||
@@ -56,6 +64,7 @@ export function NewProjectPageContent({
|
|||||||
regions,
|
regions,
|
||||||
plans,
|
plans,
|
||||||
workspaces,
|
workspaces,
|
||||||
|
numberOfFreeAndLiveProjects,
|
||||||
preSelectedWorkspace,
|
preSelectedWorkspace,
|
||||||
preSelectedRegion,
|
preSelectedRegion,
|
||||||
}: NewAppPageProps) {
|
}: NewAppPageProps) {
|
||||||
@@ -86,15 +95,23 @@ export function NewProjectPageContent({
|
|||||||
generateRandomDatabasePassword(),
|
generateRandomDatabasePassword(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [plan, setPlan] = useState(plans[0]);
|
// find the first acceptable plan as default plan
|
||||||
|
const defaultSelectedPlan = plans.find((plan) => {
|
||||||
|
if (!plan.isFree) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return numberOfFreeAndLiveProjects < MAX_FREE_PROJECTS;
|
||||||
|
});
|
||||||
|
|
||||||
|
const [plan, setPlan] = useState(defaultSelectedPlan);
|
||||||
|
|
||||||
// state
|
// state
|
||||||
const { submitState, setSubmitState } = useSubmitState();
|
const { submitState, setSubmitState } = useSubmitState();
|
||||||
const [applicationError, setApplicationError] = useState<any>('');
|
|
||||||
const [showPaymentModal, setShowPaymentModal] = useState(false);
|
const [showPaymentModal, setShowPaymentModal] = useState(false);
|
||||||
|
|
||||||
// graphql mutations
|
// graphql mutations
|
||||||
const [insertApp] = useInsertApplicationMutation();
|
|
||||||
|
const [insertApp] = useInsertApplicationMutation({});
|
||||||
const { refetchUserData } = useLazyRefetchUserData();
|
const { refetchUserData } = useLazyRefetchUserData();
|
||||||
|
|
||||||
// options
|
// options
|
||||||
@@ -119,8 +136,6 @@ export function NewProjectPageContent({
|
|||||||
(availableWorkspace) => availableWorkspace.id === selectedWorkspace.id,
|
(availableWorkspace) => availableWorkspace.id === selectedWorkspace.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
const user = nhost.auth.getUser();
|
|
||||||
|
|
||||||
const isK8SPostgresEnabledInCurrentEnvironment = features[
|
const isK8SPostgresEnabledInCurrentEnvironment = features[
|
||||||
'k8s-postgres'
|
'k8s-postgres'
|
||||||
].enabled.find((e) => e === getCurrentEnvironment());
|
].enabled.find((e) => e === getCurrentEnvironment());
|
||||||
@@ -133,30 +148,24 @@ export function NewProjectPageContent({
|
|||||||
setDatabasePassword(newRandomDatabasePassword);
|
setDatabasePassword(newRandomDatabasePassword);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!plan.isFree && workspace.paymentMethods.length === 0) {
|
||||||
|
setShowPaymentModal(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setSubmitState({
|
setSubmitState({
|
||||||
error: null,
|
error: null,
|
||||||
loading: true,
|
loading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (name.length < 1 || name.length > 32) {
|
if (name.length < 1 || name.length > 32) {
|
||||||
setApplicationError(
|
|
||||||
`The project name must be between 1 and 32 characters`,
|
|
||||||
);
|
|
||||||
setSubmitState({
|
setSubmitState({
|
||||||
error: null,
|
error: Error('The project name must be between 1 and 32 characters'),
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const slug = slugifyString(name);
|
|
||||||
|
|
||||||
if (slug.length < 1 || slug.length > 32) {
|
|
||||||
setSubmitState({
|
|
||||||
error: Error('The project slug must be between 1 and 32 characters.'),
|
|
||||||
loading: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,14 +182,11 @@ export function NewProjectPageContent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Maybe we'll reintroduce this way of creating the subdomain in the future
|
const slug = slugify(name, { lower: true, strict: true });
|
||||||
// https://www.rfc-editor.org/rfc/rfc1034#section-3.1
|
|
||||||
// subdomain max length is 63 characters
|
|
||||||
// const subdomain = `${slug}-${workspaceSlug}`.substring(0, 63);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isK8SPostgresEnabledInCurrentEnvironment) {
|
await toast.promise(
|
||||||
await insertApp({
|
insertApp({
|
||||||
variables: {
|
variables: {
|
||||||
app: {
|
app: {
|
||||||
name,
|
name,
|
||||||
@@ -188,37 +194,40 @@ export function NewProjectPageContent({
|
|||||||
planId: plan.id,
|
planId: plan.id,
|
||||||
workspaceId: selectedWorkspace.id,
|
workspaceId: selectedWorkspace.id,
|
||||||
regionId: selectedRegion.id,
|
regionId: selectedRegion.id,
|
||||||
postgresPassword: databasePassword,
|
postgresPassword: isK8SPostgresEnabledInCurrentEnvironment
|
||||||
|
? databasePassword
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
}),
|
||||||
} else {
|
{
|
||||||
await insertApp({
|
loading: 'Creating the project...',
|
||||||
variables: {
|
success: 'The project has been created successfully.',
|
||||||
app: {
|
error: (arg: ApolloError) => {
|
||||||
name,
|
// we need to get the internal error message from the GraphQL error
|
||||||
slug,
|
const { internal } = arg.graphQLErrors[0]?.extensions || {};
|
||||||
planId: plan.id,
|
const { message } = (internal as Record<string, any>)?.error || {};
|
||||||
workspaceId: selectedWorkspace.id,
|
|
||||||
regionId: selectedRegion.id,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
triggerToast(`New project ${name} created`);
|
// we use the default Apollo error message if we can't find the
|
||||||
} catch (error) {
|
// internal error message
|
||||||
discordAnnounce(
|
return (
|
||||||
`Error creating project: ${error.message}. (${user.email})`,
|
message ||
|
||||||
|
arg.message ||
|
||||||
|
'An error occurred while creating the project. Please try again.'
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
getToastStyleProps(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await refetchUserData();
|
||||||
|
await router.push(`/${selectedWorkspace.slug}/${slug}`);
|
||||||
|
} catch (error) {
|
||||||
setSubmitState({
|
setSubmitState({
|
||||||
error: Error(getErrorMessage(error, 'application')),
|
error: null,
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await refetchUserData();
|
|
||||||
router.push(`/${selectedWorkspace.slug}/${slug}`);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!selectedWorkspace) {
|
if (!selectedWorkspace) {
|
||||||
@@ -243,384 +252,376 @@ export function NewProjectPageContent({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<div className="mx-auto grid max-w-[760px] grid-flow-row gap-4 py-6 sm:py-14">
|
<form onSubmit={handleSubmit}>
|
||||||
<Text variant="h2" component="h1">
|
<div className="mx-auto grid max-w-[760px] grid-flow-row gap-4 py-6 sm:py-14">
|
||||||
New Project
|
<Text variant="h2" component="h1">
|
||||||
</Text>
|
New Project
|
||||||
|
</Text>
|
||||||
|
|
||||||
<div className="grid grid-flow-row gap-4">
|
<div className="grid grid-flow-row gap-4">
|
||||||
<Input
|
|
||||||
id="name"
|
|
||||||
autoComplete="off"
|
|
||||||
label="Project Name"
|
|
||||||
variant="inline"
|
|
||||||
fullWidth
|
|
||||||
hideEmptyHelperText
|
|
||||||
placeholder="Project Name"
|
|
||||||
onChange={(event) => {
|
|
||||||
setSubmitState({
|
|
||||||
error: null,
|
|
||||||
loading: false,
|
|
||||||
});
|
|
||||||
setApplicationError('');
|
|
||||||
setName(event.target.value);
|
|
||||||
}}
|
|
||||||
value={name}
|
|
||||||
autoFocus
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Select
|
|
||||||
id="workspace"
|
|
||||||
label="Workspace"
|
|
||||||
variant="inline"
|
|
||||||
hideEmptyHelperText
|
|
||||||
placeholder="Select Workspace"
|
|
||||||
slotProps={{
|
|
||||||
root: { className: 'grid grid-flow-col gap-1' },
|
|
||||||
}}
|
|
||||||
onChange={(_event, value) => {
|
|
||||||
const workspaceInList = workspaces.find(({ id }) => id === value);
|
|
||||||
setPlan(plans[0]);
|
|
||||||
setSelectedWorkspace({
|
|
||||||
id: workspaceInList.id,
|
|
||||||
name: workspaceInList.name,
|
|
||||||
disabled: false,
|
|
||||||
slug: workspaceInList.slug,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
value={selectedWorkspace.id}
|
|
||||||
renderValue={(option) => (
|
|
||||||
<span className="inline-grid grid-flow-col items-center gap-2">
|
|
||||||
{option?.label}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{workspaceOptions.map((option) => (
|
|
||||||
<Option
|
|
||||||
value={option.id}
|
|
||||||
key={option.id}
|
|
||||||
className="grid grid-flow-col items-center gap-2"
|
|
||||||
>
|
|
||||||
<span className="inline-block h-6 w-6 overflow-hidden rounded-md">
|
|
||||||
<Image
|
|
||||||
src="/logos/new.svg"
|
|
||||||
alt="Nhost Logo"
|
|
||||||
width={24}
|
|
||||||
height={24}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{option.name}
|
|
||||||
</Option>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
{isK8SPostgresEnabledInCurrentEnvironment && (
|
|
||||||
<Input
|
<Input
|
||||||
name="databasePassword"
|
id="name"
|
||||||
id="databasePassword"
|
autoComplete="off"
|
||||||
autoComplete="new-password"
|
label="Project Name"
|
||||||
label="Database Password"
|
|
||||||
value={databasePassword}
|
|
||||||
variant="inline"
|
variant="inline"
|
||||||
type="password"
|
fullWidth
|
||||||
error={!!passwordError}
|
|
||||||
hideEmptyHelperText
|
hideEmptyHelperText
|
||||||
endAdornment={
|
placeholder="Project Name"
|
||||||
<InputAdornment position="end" className="mr-2">
|
onChange={(event) => {
|
||||||
<IconButton
|
|
||||||
color="secondary"
|
|
||||||
onClick={() => {
|
|
||||||
copy(databasePassword, 'Postgres password');
|
|
||||||
}}
|
|
||||||
variant="borderless"
|
|
||||||
aria-label="Copy password"
|
|
||||||
>
|
|
||||||
<CopyIcon className="h-4 w-4" />
|
|
||||||
</IconButton>
|
|
||||||
</InputAdornment>
|
|
||||||
}
|
|
||||||
slotProps={{
|
|
||||||
// Note: this is supposed to fix a `validateDOMNesting` error
|
|
||||||
helperText: { component: 'div' },
|
|
||||||
}}
|
|
||||||
helperText={
|
|
||||||
<div className="grid max-w-xs grid-flow-row gap-2">
|
|
||||||
{passwordError && (
|
|
||||||
<Text
|
|
||||||
variant="subtitle2"
|
|
||||||
sx={{
|
|
||||||
color: (theme) =>
|
|
||||||
`${theme.palette.error.main} !important`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{passwordError}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Box className="font-medium">
|
|
||||||
The root Postgres password for your database - it must be
|
|
||||||
strong and hard to guess.{' '}
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="borderless"
|
|
||||||
color="secondary"
|
|
||||||
onClick={handleGenerateRandomPassword}
|
|
||||||
className="px-1 py-0.5 text-xs underline underline-offset-2 hover:underline"
|
|
||||||
tabIndex={-1}
|
|
||||||
>
|
|
||||||
Generate a password
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
onChange={async (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
setSubmitState({
|
setSubmitState({
|
||||||
error: null,
|
error: null,
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
if (e.target.value.length === 0) {
|
setName(event.target.value);
|
||||||
setDatabasePassword(e.target.value);
|
|
||||||
setPasswordError('Please enter a password');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setDatabasePassword(e.target.value);
|
|
||||||
setPasswordError('');
|
|
||||||
try {
|
|
||||||
await resetDatabasePasswordValidationSchema.validate({
|
|
||||||
databasePassword: e.target.value,
|
|
||||||
});
|
|
||||||
setPasswordError('');
|
|
||||||
} catch (validationError) {
|
|
||||||
setPasswordError(validationError.message);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
fullWidth
|
value={name}
|
||||||
|
autoFocus
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
id="region"
|
id="workspace"
|
||||||
label="Region"
|
label="Workspace"
|
||||||
variant="inline"
|
variant="inline"
|
||||||
hideEmptyHelperText
|
hideEmptyHelperText
|
||||||
placeholder="Select Region"
|
placeholder="Select Workspace"
|
||||||
slotProps={{
|
slotProps={{
|
||||||
root: { className: 'grid grid-flow-col gap-1' },
|
root: { className: 'grid grid-flow-col gap-1' },
|
||||||
}}
|
}}
|
||||||
onChange={(_event, value) => {
|
onChange={(_event, value) => {
|
||||||
const regionInList = regions.find(({ id }) => id === value);
|
const workspaceInList = workspaces.find(
|
||||||
setPlan(plans[0]);
|
({ id }) => id === value,
|
||||||
setSelectedRegion({
|
);
|
||||||
id: regionInList.id,
|
setPlan(plans[0]);
|
||||||
name: regionInList.country.name,
|
setSelectedWorkspace({
|
||||||
disabled: false,
|
id: workspaceInList.id,
|
||||||
code: regionInList.country.code,
|
name: workspaceInList.name,
|
||||||
});
|
disabled: false,
|
||||||
}}
|
slug: workspaceInList.slug,
|
||||||
value={selectedRegion.id}
|
});
|
||||||
renderValue={(option) => {
|
}}
|
||||||
const [flag, , country] = (option?.label as any[]) || [];
|
value={selectedWorkspace.id}
|
||||||
|
renderValue={(option) => (
|
||||||
return (
|
<span className="inline-grid grid-flow-col items-center gap-2">
|
||||||
<span className="inline-grid grid-flow-col grid-rows-none items-center gap-x-2">
|
{option?.label}
|
||||||
{flag}
|
|
||||||
|
|
||||||
{isValidElement<TextProps>(country)
|
|
||||||
? cloneElement(country, {
|
|
||||||
...country.props,
|
|
||||||
variant: 'body1',
|
|
||||||
})
|
|
||||||
: null}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{regionOptions.map((option) => (
|
|
||||||
<Option
|
|
||||||
value={option.id}
|
|
||||||
key={option.id}
|
|
||||||
className={twMerge(
|
|
||||||
'relative grid grid-flow-col grid-rows-2 items-center justify-start gap-x-3',
|
|
||||||
option.disabled && 'pointer-events-none opacity-50',
|
|
||||||
)}
|
|
||||||
disabled={option.disabled}
|
|
||||||
>
|
|
||||||
<span className="row-span-2 flex">
|
|
||||||
<Image
|
|
||||||
src={`/assets/flags/${option.code}.svg`}
|
|
||||||
alt={`${option.country} country flag`}
|
|
||||||
width={16}
|
|
||||||
height={12}
|
|
||||||
/>
|
|
||||||
</span>
|
</span>
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{workspaceOptions.map((option) => (
|
||||||
|
<Option
|
||||||
|
value={option.id}
|
||||||
|
key={option.id}
|
||||||
|
className="grid grid-flow-col items-center gap-2"
|
||||||
|
>
|
||||||
|
<span className="inline-block h-6 w-6 overflow-hidden rounded-md">
|
||||||
|
<Image
|
||||||
|
src="/logos/new.svg"
|
||||||
|
alt="Nhost Logo"
|
||||||
|
width={24}
|
||||||
|
height={24}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
|
||||||
<Text className="row-span-1 font-medium">{option.name}</Text>
|
{option.name}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
|
||||||
<Text variant="subtitle2" className="row-span-1">
|
{isK8SPostgresEnabledInCurrentEnvironment && (
|
||||||
{option.country}
|
<Input
|
||||||
</Text>
|
name="databasePassword"
|
||||||
|
id="databasePassword"
|
||||||
|
autoComplete="new-password"
|
||||||
|
label="Database Password"
|
||||||
|
value={databasePassword}
|
||||||
|
variant="inline"
|
||||||
|
type="password"
|
||||||
|
error={!!passwordError}
|
||||||
|
hideEmptyHelperText
|
||||||
|
endAdornment={
|
||||||
|
<InputAdornment position="end" className="mr-2">
|
||||||
|
<IconButton
|
||||||
|
color="secondary"
|
||||||
|
onClick={() => {
|
||||||
|
copy(databasePassword, 'Postgres password');
|
||||||
|
}}
|
||||||
|
variant="borderless"
|
||||||
|
aria-label="Copy password"
|
||||||
|
>
|
||||||
|
<CopyIcon className="h-4 w-4" />
|
||||||
|
</IconButton>
|
||||||
|
</InputAdornment>
|
||||||
|
}
|
||||||
|
slotProps={{
|
||||||
|
// Note: this is supposed to fix a `validateDOMNesting` error
|
||||||
|
helperText: { component: 'div' },
|
||||||
|
}}
|
||||||
|
helperText={
|
||||||
|
<div className="grid max-w-xs grid-flow-row gap-2">
|
||||||
|
{passwordError && (
|
||||||
|
<Text
|
||||||
|
variant="subtitle2"
|
||||||
|
sx={{
|
||||||
|
color: (theme) =>
|
||||||
|
`${theme.palette.error.main} !important`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{passwordError}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
|
||||||
{option.disabled && (
|
<Box className="font-medium">
|
||||||
<Text
|
The root Postgres password for your database - it must be
|
||||||
variant="subtitle2"
|
strong and hard to guess.{' '}
|
||||||
className="absolute top-1/2 right-4 -translate-y-1/2"
|
<Button
|
||||||
>
|
type="button"
|
||||||
Disabled
|
variant="borderless"
|
||||||
</Text>
|
color="secondary"
|
||||||
)}
|
onClick={handleGenerateRandomPassword}
|
||||||
</Option>
|
className="px-1 py-0.5 text-xs underline underline-offset-2 hover:underline"
|
||||||
))}
|
tabIndex={-1}
|
||||||
</Select>
|
>
|
||||||
|
Generate a password
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
onChange={async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setSubmitState({
|
||||||
|
error: null,
|
||||||
|
loading: false,
|
||||||
|
});
|
||||||
|
setDatabasePassword(e.target.value);
|
||||||
|
|
||||||
<div className="grid w-full grid-cols-8 gap-x-4 gap-y-2">
|
try {
|
||||||
<div className="col-span-8 sm:col-span-2">
|
await resetDatabasePasswordValidationSchema.validate({
|
||||||
<Text className="text-xs font-medium">Plan</Text>
|
databasePassword: e.target.value,
|
||||||
<Text variant="subtitle2">You can change this later.</Text>
|
});
|
||||||
</div>
|
setPasswordError('');
|
||||||
|
} catch (validationError) {
|
||||||
|
setPasswordError(validationError.message);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="col-span-8 sm:col-span-6">
|
<Select
|
||||||
{plans.map((currentPlan) => {
|
id="region"
|
||||||
const checked = plan.id === currentPlan.id;
|
label="Region"
|
||||||
|
variant="inline"
|
||||||
|
hideEmptyHelperText
|
||||||
|
placeholder="Select Region"
|
||||||
|
slotProps={{
|
||||||
|
root: { className: 'grid grid-flow-col gap-1' },
|
||||||
|
}}
|
||||||
|
onChange={(_event, value) => {
|
||||||
|
const regionInList = regions.find(({ id }) => id === value);
|
||||||
|
setSelectedRegion({
|
||||||
|
id: regionInList.id,
|
||||||
|
name: regionInList.country.name,
|
||||||
|
disabled: false,
|
||||||
|
code: regionInList.country.code,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
value={selectedRegion.id}
|
||||||
|
renderValue={(option) => {
|
||||||
|
const [flag, , country] = (option?.label as any[]) || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<span className="inline-grid grid-flow-col grid-rows-none items-center gap-x-2">
|
||||||
className="border-t py-4 last-of-type:border-b"
|
{flag}
|
||||||
key={currentPlan.id}
|
|
||||||
>
|
|
||||||
<Checkbox
|
|
||||||
label={
|
|
||||||
<>
|
|
||||||
<span className="inline-block max-w-xs">
|
|
||||||
<span className="font-medium">
|
|
||||||
{currentPlan.name}:
|
|
||||||
</span>{' '}
|
|
||||||
{planDescriptions[currentPlan.name]}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{currentPlan.isFree ? (
|
{isValidElement<TextProps>(country)
|
||||||
<Text variant="h3" component="span">
|
? cloneElement(country, {
|
||||||
Free
|
...country.props,
|
||||||
</Text>
|
variant: 'body1',
|
||||||
) : (
|
})
|
||||||
<Text
|
: null}
|
||||||
variant="h3"
|
</span>
|
||||||
component="span"
|
|
||||||
className="inline-grid grid-flow-col items-center gap-1"
|
|
||||||
>
|
|
||||||
$ {currentPlan.price}{' '}
|
|
||||||
<Text variant="subtitle2" component="span">
|
|
||||||
/ mo
|
|
||||||
</Text>
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
componentsProps={{
|
|
||||||
formControlLabel: {
|
|
||||||
className: 'flex',
|
|
||||||
componentsProps: {
|
|
||||||
typography: {
|
|
||||||
className:
|
|
||||||
'font-regular text-xs grid grid-flow-col justify-between items-center w-full',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
checked={checked}
|
|
||||||
key={currentPlan.id}
|
|
||||||
onChange={(event, inputChecked) => {
|
|
||||||
if (!inputChecked) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setPlan(currentPlan);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
);
|
);
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{submitState.error && (
|
|
||||||
<Alert severity="error" className="text-left">
|
|
||||||
<Text className="font-medium">Warning</Text>{' '}
|
|
||||||
<Text className="font-medium">
|
|
||||||
{submitState.error &&
|
|
||||||
getErrorMessage(submitState.error, 'application')}{' '}
|
|
||||||
asdsda
|
|
||||||
</Text>
|
|
||||||
</Alert>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="flex justify-end">
|
|
||||||
{showPaymentModal && (
|
|
||||||
<Modal
|
|
||||||
showModal={showPaymentModal}
|
|
||||||
close={() => {
|
|
||||||
setShowPaymentModal(false);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<BillingPaymentMethodForm
|
{regionOptions.map((option) => (
|
||||||
|
<Option
|
||||||
|
value={option.id}
|
||||||
|
key={option.id}
|
||||||
|
className={twMerge(
|
||||||
|
'relative grid grid-flow-col grid-rows-2 items-center justify-start gap-x-3',
|
||||||
|
option.disabled && 'pointer-events-none opacity-50',
|
||||||
|
)}
|
||||||
|
disabled={option.disabled}
|
||||||
|
>
|
||||||
|
<span className="row-span-2 flex">
|
||||||
|
<Image
|
||||||
|
src={`/assets/flags/${option.code}.svg`}
|
||||||
|
alt={`${option.country} country flag`}
|
||||||
|
width={16}
|
||||||
|
height={12}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<Text className="row-span-1 font-medium">{option.name}</Text>
|
||||||
|
|
||||||
|
<Text variant="subtitle2" className="row-span-1">
|
||||||
|
{option.country}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{option.disabled && (
|
||||||
|
<Text
|
||||||
|
variant="subtitle2"
|
||||||
|
className="absolute top-1/2 right-4 -translate-y-1/2"
|
||||||
|
>
|
||||||
|
Disabled
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
<div className="grid w-full grid-cols-8 gap-x-4 gap-y-2">
|
||||||
|
<div className="col-span-8 sm:col-span-2">
|
||||||
|
<Text className="text-xs font-medium">Plan</Text>
|
||||||
|
<Text variant="subtitle2">You can change this later.</Text>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
value={plan.id}
|
||||||
|
onChange={(_event, value) => {
|
||||||
|
setPlan(plans.find((p) => p.id === value));
|
||||||
|
}}
|
||||||
|
className="col-span-8 space-y-2 sm:col-span-6"
|
||||||
|
>
|
||||||
|
{plans.map((currentPlan) => {
|
||||||
|
const disabledPlan =
|
||||||
|
currentPlan.isFree &&
|
||||||
|
numberOfFreeAndLiveProjects >= MAX_FREE_PROJECTS;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
visible={disabledPlan}
|
||||||
|
title="Only one free project can be active at any given time. Please pause your active free project before creating a new one."
|
||||||
|
key={currentPlan.id}
|
||||||
|
slotProps={{
|
||||||
|
tooltip: { className: '!max-w-xs w-full text-center' },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box className="w-full rounded-md border">
|
||||||
|
<Radio
|
||||||
|
slotProps={{
|
||||||
|
formControl: {
|
||||||
|
className: 'p-3 w-full',
|
||||||
|
slotProps: {
|
||||||
|
typography: { className: 'w-full' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
value={currentPlan.id}
|
||||||
|
disabled={disabledPlan}
|
||||||
|
label={
|
||||||
|
<div className="flex w-full items-center justify-between ">
|
||||||
|
<div className="inline-block max-w-xs">
|
||||||
|
<Text className="font-medium text-[inherit]">
|
||||||
|
{currentPlan.name}
|
||||||
|
</Text>
|
||||||
|
<Text className="text-xs text-[inherit]">
|
||||||
|
{planDescriptions[currentPlan.name]}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{currentPlan.isFree ? (
|
||||||
|
<Text
|
||||||
|
variant="h3"
|
||||||
|
component="span"
|
||||||
|
className="text-[inherit]"
|
||||||
|
>
|
||||||
|
Free
|
||||||
|
</Text>
|
||||||
|
) : (
|
||||||
|
<Text variant="h3" component="span">
|
||||||
|
${currentPlan.price}/mo
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</RadioGroup>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{submitState.error && (
|
||||||
|
<Alert severity="error" className="text-left">
|
||||||
|
<Text className="font-medium">Error</Text>{' '}
|
||||||
|
<Text className="font-medium">
|
||||||
|
{submitState.error &&
|
||||||
|
getErrorMessage(submitState.error, 'application')}{' '}
|
||||||
|
</Text>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="flex justify-end">
|
||||||
|
{showPaymentModal && (
|
||||||
|
<Modal
|
||||||
|
showModal={showPaymentModal}
|
||||||
close={() => {
|
close={() => {
|
||||||
setShowPaymentModal(false);
|
setShowPaymentModal(false);
|
||||||
}}
|
}}
|
||||||
onPaymentMethodAdded={handleSubmit}
|
>
|
||||||
workspaceId={workspace.id}
|
<BillingPaymentMethodForm
|
||||||
/>
|
close={() => {
|
||||||
</Modal>
|
setShowPaymentModal(false);
|
||||||
)}
|
}}
|
||||||
|
onPaymentMethodAdded={handleSubmit}
|
||||||
|
workspaceId={workspace.id}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
|
)}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
type="submit"
|
||||||
if (!plan.isFree && workspace.paymentMethods.length === 0) {
|
loading={submitState.loading}
|
||||||
setShowPaymentModal(true);
|
disabled={!!passwordError || maintenanceActive}
|
||||||
|
id="create-app"
|
||||||
return;
|
>
|
||||||
}
|
Create Project
|
||||||
|
</Button>
|
||||||
handleSubmit();
|
</div>
|
||||||
}}
|
|
||||||
type="submit"
|
|
||||||
loading={submitState.loading}
|
|
||||||
disabled={
|
|
||||||
!!applicationError ||
|
|
||||||
!!submitState.error ||
|
|
||||||
!!passwordError ||
|
|
||||||
maintenanceActive
|
|
||||||
}
|
|
||||||
id="create-app"
|
|
||||||
>
|
|
||||||
Create Project
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function NewProjectPage() {
|
export default function NewProjectPage() {
|
||||||
const { data, loading, error } = usePrefetchNewAppQuery();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const user = useUserData();
|
||||||
|
|
||||||
if (error) {
|
const { data, loading, error } = usePrefetchNewAppQuery();
|
||||||
throw error;
|
|
||||||
|
const {
|
||||||
|
data: freeAndActiveProjectsData,
|
||||||
|
loading: freeAndActiveProjectsLoading,
|
||||||
|
error: freeAndActiveProjectsError,
|
||||||
|
} = useGetFreeAndActiveProjectsQuery({
|
||||||
|
variables: { userId: user?.id },
|
||||||
|
fetchPolicy: 'cache-and-network',
|
||||||
|
});
|
||||||
|
|
||||||
|
if (error || freeAndActiveProjectsError) {
|
||||||
|
throw error || freeAndActiveProjectsError;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loading) {
|
if (loading || freeAndActiveProjectsLoading) {
|
||||||
return (
|
return (
|
||||||
<ActivityIndicator delay={500} label="Loading plans and regions..." />
|
<ActivityIndicator delay={500} label="Loading plans and regions..." />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { workspace } = router.query;
|
const { workspace } = router.query;
|
||||||
|
|
||||||
const { regions, plans, workspaces } = data;
|
const { regions, plans, workspaces } = data;
|
||||||
|
|
||||||
// get pre-selected workspace
|
// get pre-selected workspace
|
||||||
@@ -629,13 +630,16 @@ export default function NewProjectPage() {
|
|||||||
? workspaces.find((w) => w.slug === workspace)
|
? workspaces.find((w) => w.slug === workspace)
|
||||||
: workspaces[0];
|
: workspaces[0];
|
||||||
|
|
||||||
const preSelectedRegion = regions.filter((region) => region.active)[0];
|
const preSelectedRegion = regions.find((region) => region.active);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NewProjectPageContent
|
<NewProjectPageContent
|
||||||
regions={regions}
|
regions={regions}
|
||||||
plans={plans}
|
plans={plans}
|
||||||
workspaces={workspaces}
|
workspaces={workspaces}
|
||||||
|
numberOfFreeAndLiveProjects={
|
||||||
|
freeAndActiveProjectsData?.freeAndActiveProjects.length
|
||||||
|
}
|
||||||
preSelectedWorkspace={preSelectedWorkspace}
|
preSelectedWorkspace={preSelectedWorkspace}
|
||||||
preSelectedRegion={preSelectedRegion}
|
preSelectedRegion={preSelectedRegion}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -22,3 +22,8 @@ export const READ_ONLY_SCHEMAS = ['auth', 'storage'];
|
|||||||
* Key used to store the color preference in local storage.
|
* Key used to store the color preference in local storage.
|
||||||
*/
|
*/
|
||||||
export const COLOR_PREFERENCE_STORAGE_KEY = 'nhost-color-preference';
|
export const COLOR_PREFERENCE_STORAGE_KEY = 'nhost-color-preference';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of free projects a user is allowed to have.
|
||||||
|
*/
|
||||||
|
export const MAX_FREE_PROJECTS = 1;
|
||||||
|
|||||||
2934
dashboard/src/utils/__generated__/graphql.ts
generated
2934
dashboard/src/utils/__generated__/graphql.ts
generated
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ export interface ColumnDetails {
|
|||||||
hasDefaultValue: boolean;
|
hasDefaultValue: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createGenericValidationSchema<T extends yup.BaseSchema>(
|
function createGenericValidationSchema<T extends yup.Schema>(
|
||||||
genericSchema: T,
|
genericSchema: T,
|
||||||
{ isNullable, hasDefaultValue, isIdentity }: ColumnDetails,
|
{ isNullable, hasDefaultValue, isIdentity }: ColumnDetails,
|
||||||
): T {
|
): T {
|
||||||
@@ -136,7 +136,10 @@ export function createDynamicValidationSchema(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.type === 'text' && column.specificType === 'jsonb') {
|
if (
|
||||||
|
column.type === 'text' &&
|
||||||
|
(column.specificType === 'jsonb' || column.specificType === 'json')
|
||||||
|
) {
|
||||||
return {
|
return {
|
||||||
...schema,
|
...schema,
|
||||||
[column.id]: createJSONValidationSchema(details),
|
[column.id]: createJSONValidationSchema(details),
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ import { isDevOrStaging } from './helpers';
|
|||||||
* @param content {string} This string to log on the particular channel.
|
* @param content {string} This string to log on the particular channel.
|
||||||
*/
|
*/
|
||||||
export const discordAnnounce = async (content: string) => {
|
export const discordAnnounce = async (content: string) => {
|
||||||
|
if (!process.env.NEXT_PUBLIC_DISCORD_LOGGING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const username = isDevOrStaging() ? 'console-next(dev)' : 'console-next';
|
const username = isDevOrStaging() ? 'console-next(dev)' : 'console-next';
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { graphql } from 'msw';
|
import { graphql } from 'msw';
|
||||||
|
|
||||||
const nhostGraphQLLink = graphql.link('http://localhost:1337/v1/graphql');
|
const nhostGraphQLLink = graphql.link('https://local.graphql.nhost.run/v1');
|
||||||
|
|
||||||
export default nhostGraphQLLink;
|
export default nhostGraphQLLink;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ function Providers({ children }: PropsWithChildren<{}>) {
|
|||||||
<NhostApolloProvider
|
<NhostApolloProvider
|
||||||
nhost={nhost}
|
nhost={nhost}
|
||||||
link={createHttpLink({
|
link={createHttpLink({
|
||||||
uri: 'http://localhost:1337/v1/graphql',
|
uri: 'https://local.graphql.nhost.run/v1',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<WorkspaceProvider>
|
<WorkspaceProvider>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"baseUrl": "./src",
|
"baseUrl": "./src",
|
||||||
"useUnknownInCatchVariables": false,
|
"useUnknownInCatchVariables": false,
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"@/e2e/*": ["../e2e/*"],
|
||||||
"@/components/*": ["components/*"],
|
"@/components/*": ["components/*"],
|
||||||
"@/hooks/*": ["hooks/*"],
|
"@/hooks/*": ["hooks/*"],
|
||||||
"@/utils/*": ["utils/*"],
|
"@/utils/*": ["utils/*"],
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"types": ["vitest/globals"],
|
"types": ["vitest/globals"],
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"@/e2e/*": ["../e2e/*"],
|
||||||
"@/components/*": ["components/*"],
|
"@/components/*": ["components/*"],
|
||||||
"@/hooks/*": ["hooks/*"],
|
"@/hooks/*": ["hooks/*"],
|
||||||
"@/utils/*": ["utils/*"],
|
"@/utils/*": ["utils/*"],
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ export default defineConfig({
|
|||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
globals: true,
|
globals: true,
|
||||||
setupFiles: 'src/setupTests.ts',
|
setupFiles: 'src/setupTests.ts',
|
||||||
|
include: ['src/**/*.(spec|test).{js,jsx,ts,tsx}'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/docs
|
# @nhost/docs
|
||||||
|
|
||||||
|
## 0.0.14
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- bfb4c1a6: fix(docs): restore autogenerated `@nhost/nhost-js` docs
|
||||||
|
|
||||||
## 0.0.13
|
## 0.0.13
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ Follow this guide to sign in users with Google.
|
|||||||
- Click on **Credentials** under **APIs & Services** in the left menu.
|
- Click on **Credentials** under **APIs & Services** in the left menu.
|
||||||
- Click **+ CREATE CREDENTIALS** and then **OAuth client ID** in the top menu.
|
- Click **+ CREATE CREDENTIALS** and then **OAuth client ID** in the top menu.
|
||||||
- On the **Create OAuth client ID** page for **Application Type** select **Web application**.
|
- On the **Create OAuth client ID** page for **Application Type** select **Web application**.
|
||||||
|
- Under **Authorized JavaScript origins**, add your project's redirect URL for the Google sign-in method in the following format: `https://<subdomain>.auth.<region>.nhost.run`
|
||||||
- Under **Authorized redirect URIs** add your **OAuth Callback URL** from Nhost.
|
- Under **Authorized redirect URIs** add your **OAuth Callback URL** from Nhost.
|
||||||
- Click **CREATE**.
|
- Click **CREATE**.
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ In this section:
|
|||||||
- [Overview](/reference/javascript)
|
- [Overview](/reference/javascript)
|
||||||
- [Authentication](/reference/javascript/auth)
|
- [Authentication](/reference/javascript/auth)
|
||||||
- [Storage](/reference/javascript/storage)
|
- [Storage](/reference/javascript/storage)
|
||||||
- [Functions](/reference/javascript/functions)
|
- [Functions](/reference/javascript/nhost-js/functions)
|
||||||
- [GraphQL](/reference/javascript/graphql)
|
- [GraphQL](/reference/javascript/graphql)
|
||||||
|
|
||||||
### React
|
### React
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
---
|
|
||||||
title: call()
|
|
||||||
sidebar_label: call()
|
|
||||||
slug: /reference/javascript/functions/call
|
|
||||||
description: Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/index.ts#L55
|
|
||||||
---
|
|
||||||
|
|
||||||
# `call()`
|
|
||||||
|
|
||||||
## Overload 1 of 2
|
|
||||||
|
|
||||||
Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
|
||||||
|
|
||||||
:::caution Deprecated
|
|
||||||
Axios will be replaced by cross-fetch in the near future. Only the headers configuration will be kept.
|
|
||||||
:::
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">url</span>** <span className="optional-status">required</span> <code>string</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">data</span>** <span className="optional-status">optional</span> <code>D</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">config</span>** <span className="optional-status">optional</span> <code>AxiosRequestConfig<any> & { useAxios: "true" } & [`NhostFunctionCallConfig`](/reference/javascript/functions/types/nhost-function-call-config) & { useAxios: "true" }</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Overload 2 of 2
|
|
||||||
|
|
||||||
Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
await nhost.functions.call('send-welcome-email', {
|
|
||||||
email: 'joe@example.com',
|
|
||||||
name: 'Joe Doe'
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">url</span>** <span className="optional-status">required</span> <code>string</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">data</span>** <span className="optional-status">required</span> <code>D</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">config</span>** <span className="optional-status">optional</span> <code>[`NhostFunctionCallConfig`](/reference/javascript/functions/types/nhost-function-call-config) & { useAxios: "false" }</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
title: setAccessToken()
|
|
||||||
sidebar_label: setAccessToken()
|
|
||||||
slug: /reference/javascript/functions/set-access-token
|
|
||||||
description: Use `nhost.functions.setAccessToken` to a set an access token to be used in subsequent functions requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically.
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/index.ts#L155
|
|
||||||
---
|
|
||||||
|
|
||||||
# `setAccessToken()`
|
|
||||||
|
|
||||||
Use `nhost.functions.setAccessToken` to a set an access token to be used in subsequent functions requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
nhost.functions.setAccessToken('some-access-token')
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">accessToken</span>** <span className="optional-status">required</span> <code>undefined | string</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionsClient
|
|
||||||
sidebar_label: Functions
|
|
||||||
description: No description provided.
|
|
||||||
slug: /reference/javascript/functions
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/docs/docs/reference/javascript/functions/index.mdx
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionsClient`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`NhostFunctionsConstructorParams`](/reference/javascript/functions/types/nhost-functions-constructor-params)
|
|
||||||
|
|
||||||
| Property | Type | Required | Notes |
|
|
||||||
| :--------------------------------------------------------------------------------------------- | :------------------ | :------: | :---------------------------------------------------------------------------------------- |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">params.</span>url</span> | <code>string</code> | ✔️ | Serverless Functions endpoint. |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | <code>string</code> | | Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all requests. |
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionCallConfig
|
|
||||||
sidebar_label: NhostFunctionCallConfig
|
|
||||||
description: Subset of RequestInit parameters that are supported by the functions client
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/types.ts#L41
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionCallConfig`
|
|
||||||
|
|
||||||
Subset of RequestInit parameters that are supported by the functions client
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">headers</span>** <span className="optional-status">optional</span> <code>Record<string, string></code>
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionCallResponse
|
|
||||||
sidebar_label: NhostFunctionCallResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/types.ts#L15
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionCallResponse`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type NhostFunctionCallResponse =
|
|
||||||
| { res: { data: T; status: number; statusText: string }; error: null }
|
|
||||||
| { res: null; error: ErrorPayload }
|
|
||||||
```
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionsConstructorParams
|
|
||||||
sidebar_label: NhostFunctionsConstructorParams
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/types.ts#L4
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionsConstructorParams`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">url</span>** <span className="optional-status">required</span> <code>string</code>
|
|
||||||
|
|
||||||
Serverless Functions endpoint.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> <code>string</code>
|
|
||||||
|
|
||||||
Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all requests.
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -10,7 +10,7 @@ The Nhost JavaScript client is the primary way of interacting with your Nhost pr
|
|||||||
|
|
||||||
- [Authentication](/reference/javascript/auth)
|
- [Authentication](/reference/javascript/auth)
|
||||||
- [Storage](/reference/javascript/storage)
|
- [Storage](/reference/javascript/storage)
|
||||||
- [Functions](/reference/javascript/functions)
|
- [Functions](/reference/javascript/nhost-js/functions)
|
||||||
- [GraphQL](/reference/javascript/graphql)
|
- [GraphQL](/reference/javascript/graphql)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ export default (req: Request, res: Response) => {
|
|||||||
To get the `Request`, and `Response` types you can install the `@types/express` package.
|
To get the `Request`, and `Response` types you can install the `@types/express` package.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install -d @types/express
|
npm install -D @types/express
|
||||||
# or yarn
|
# or yarn
|
||||||
yarn add -d @types/express
|
yarn add -D @types/express
|
||||||
# or pnpm
|
# or pnpm
|
||||||
pnpm add -d @types/express
|
pnpm add -D @types/express
|
||||||
```
|
```
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/docs",
|
"name": "@nhost/docs",
|
||||||
"version": "0.0.13",
|
"version": "0.0.14",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@algolia/client-search": "^4.9.1",
|
"@algolia/client-search": "^4.9.1",
|
||||||
"@docusaurus/core": "2.3.1",
|
"@docusaurus/core": "2.4.0",
|
||||||
"@docusaurus/plugin-sitemap": "2.3.1",
|
"@docusaurus/plugin-sitemap": "2.4.0",
|
||||||
"@docusaurus/preset-classic": "2.3.1",
|
"@docusaurus/preset-classic": "2.4.0",
|
||||||
"@mdx-js/react": "^1.6.22",
|
"@mdx-js/react": "^1.6.22",
|
||||||
"clsx": "^1.2.1",
|
"clsx": "^1.2.1",
|
||||||
"docusaurus-plugin-image-zoom": "^0.1.1",
|
"docusaurus-plugin-image-zoom": "^0.1.1",
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
"unist-util-visit": "^2.0.0"
|
"unist-util-visit": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@docusaurus/module-type-aliases": "2.3.1",
|
"@docusaurus/module-type-aliases": "2.4.0",
|
||||||
"@tsconfig/docusaurus": "^1.0.6",
|
"@tsconfig/docusaurus": "^1.0.6",
|
||||||
"typescript": "^4.8.4"
|
"typescript": "^4.8.4"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -111,12 +111,12 @@ const sidebars = {
|
|||||||
label: 'Functions',
|
label: 'Functions',
|
||||||
link: {
|
link: {
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
id: 'reference/javascript/functions/index'
|
id: 'reference/docgen/javascript/nhost-js/content/nhost-functions-client/index'
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: 'autogenerated',
|
type: 'autogenerated',
|
||||||
dirName: 'reference/javascript/functions/content'
|
dirName: 'reference/docgen/javascript/nhost-js/content/nhost-functions-client/content'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
extends: [
|
extends: ['../../config/.eslintrc.js', 'plugin:@next/next/recommended'],
|
||||||
'../../config/.eslintrc.js',
|
|
||||||
'plugin:react/jsx-runtime',
|
|
||||||
'plugin:@next/next/recommended'
|
|
||||||
],
|
|
||||||
rules: {
|
rules: {
|
||||||
'react/react-in-jsx-scope': 'off'
|
'react/react-in-jsx-scope': 'off'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @nhost-examples/nextjs
|
# @nhost-examples/nextjs
|
||||||
|
|
||||||
|
## 0.1.8
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- ce1ee40d: fix(nextjs): allow `subdomain`, `region` and service URLs
|
||||||
|
- Updated dependencies [ce1ee40d]
|
||||||
|
- @nhost/nextjs@1.13.16
|
||||||
|
- @nhost/react@2.0.10
|
||||||
|
- @nhost/react-apollo@5.0.11
|
||||||
|
|
||||||
## 0.1.7
|
## 0.1.7
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export * from './queries'
|
export * from './queries'
|
||||||
export const BACKEND_URL = 'http://127.0.0.1:1337'
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost-examples/nextjs",
|
"name": "@nhost-examples/nextjs",
|
||||||
"version": "0.1.7",
|
"version": "0.1.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { inspect } from '@xstate/inspect'
|
|||||||
import type { AppProps } from 'next/app'
|
import type { AppProps } from 'next/app'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import NavBar from '../components/NavBar'
|
import NavBar from '../components/NavBar'
|
||||||
import { BACKEND_URL } from '../helpers'
|
|
||||||
import '../styles/globals.css?inline'
|
import '../styles/globals.css?inline'
|
||||||
|
|
||||||
const devTools = typeof window !== 'undefined' && !!process.env.NEXT_PUBLIC_DEBUG
|
const devTools = typeof window !== 'undefined' && !!process.env.NEXT_PUBLIC_DEBUG
|
||||||
@@ -16,7 +15,7 @@ if (devTools) {
|
|||||||
iframe: false
|
iframe: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const nhost = new NhostClient({ backendUrl: BACKEND_URL, devTools })
|
const nhost = new NhostClient({ subdomain: 'localhost', devTools })
|
||||||
const title = 'Nhost with NextJs'
|
const title = 'Nhost with NextJs'
|
||||||
function MyApp({ Component, pageProps }: AppProps) {
|
function MyApp({ Component, pageProps }: AppProps) {
|
||||||
// * Monorepo-related. See: https://stackoverflow.com/questions/71843247/react-nextjs-type-error-component-cannot-be-used-as-a-jsx-component
|
// * Monorepo-related. See: https://stackoverflow.com/questions/71843247/react-nextjs-type-error-component-cannot-be-used-as-a-jsx-component
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ import { Container, Title } from '@mantine/core'
|
|||||||
import { getNhostSession, NhostSession, useAccessToken } from '@nhost/nextjs'
|
import { getNhostSession, NhostSession, useAccessToken } from '@nhost/nextjs'
|
||||||
|
|
||||||
import { authProtected } from '../components/protected-route'
|
import { authProtected } from '../components/protected-route'
|
||||||
import { BACKEND_URL } from '../helpers'
|
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
const nhostSession = await getNhostSession(BACKEND_URL, context)
|
const nhostSession = await getNhostSession({ subdomain: 'localhost' }, context)
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
nhostSession
|
nhostSession
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ import { GetServerSideProps } from 'next'
|
|||||||
import { Container, Title } from '@mantine/core'
|
import { Container, Title } from '@mantine/core'
|
||||||
import { getNhostSession, NhostSession, useAccessToken, useAuthenticated } from '@nhost/nextjs'
|
import { getNhostSession, NhostSession, useAccessToken, useAuthenticated } from '@nhost/nextjs'
|
||||||
|
|
||||||
import { BACKEND_URL } from '../helpers'
|
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
const nhostSession = await getNhostSession(BACKEND_URL, context)
|
const nhostSession = await getNhostSession({ subdomain: 'localhost' }, context)
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
nhostSession
|
nhostSession
|
||||||
|
|||||||
6
examples/react-apollo/.gitignore
vendored
6
examples/react-apollo/.gitignore
vendored
@@ -25,5 +25,7 @@ yarn-error.log*
|
|||||||
.nhost
|
.nhost
|
||||||
functions/node_modules
|
functions/node_modules
|
||||||
|
|
||||||
cypress/videos
|
/test-results/
|
||||||
cypress/screenshots
|
/playwright-report/
|
||||||
|
/playwright/.cache/
|
||||||
|
storageState.json
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost-examples/react-apollo
|
# @nhost-examples/react-apollo
|
||||||
|
|
||||||
|
## 0.1.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- caba147b: chore(examples): improve tests of the React Apollo example
|
||||||
|
|
||||||
## 0.1.9
|
## 0.1.9
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import { defineConfig } from 'cypress'
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
e2e: {
|
|
||||||
baseUrl: 'http://localhost:3000',
|
|
||||||
chromeWebSecurity: false,
|
|
||||||
// * for some reason, the mailhog API is not systematically available
|
|
||||||
// * when using `localhost` instead of `127.0.0.1`
|
|
||||||
mailHogUrl: 'http://127.0.0.1:8025',
|
|
||||||
env: {
|
|
||||||
backendUrl: 'http://localhost:1337'
|
|
||||||
},
|
|
||||||
defaultCommandTimeout: 20000,
|
|
||||||
requestTimeout: 20000
|
|
||||||
}
|
|
||||||
} as Cypress.ConfigOptions)
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
context('Authentication guards', () => {
|
|
||||||
it('should redirect to /sign-in when not authenticated', () => {
|
|
||||||
cy.visit('/')
|
|
||||||
cy.location('pathname').should('equal', '/sign-in')
|
|
||||||
cy.visit('/apollo')
|
|
||||||
cy.location('pathname').should('equal', '/sign-in')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Forgot password', () => {
|
|
||||||
it('should reset password', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const password = faker.internet.password(8)
|
|
||||||
|
|
||||||
cy.signUpEmailPassword(email, password)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
|
|
||||||
cy.visit('/sign-in')
|
|
||||||
cy.findByRole('button', { name: /Continue with email \+ password/i }).click()
|
|
||||||
cy.findByRole('button', { name: /Forgot Password?/i }).click()
|
|
||||||
|
|
||||||
cy.findByPlaceholderText('Email Address').type(email)
|
|
||||||
cy.findByRole('button', { name: /Reset your password/i }).click()
|
|
||||||
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
cy.contains('Profile page')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Anonymous users', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.signInAnonymous()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should sign-up anonymously', () => {
|
|
||||||
cy.contains('You signed in anonymously')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should deanonymise with email+password', () => {
|
|
||||||
cy.fetchUserData()
|
|
||||||
.its('id')
|
|
||||||
.then((id) => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const password = faker.internet.password()
|
|
||||||
cy.signUpEmailPassword(email, password)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
cy.contains('You signed in anonymously').should('not.exist')
|
|
||||||
|
|
||||||
cy.fetchUserData().then((user) => {
|
|
||||||
cy.wrap(user).its('id').should('equal', id)
|
|
||||||
cy.wrap(user).its('email').should('equal', email)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should deanonymise with a magic link', () => {
|
|
||||||
cy.fetchUserData()
|
|
||||||
.its('id')
|
|
||||||
.then((id) => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
cy.signUpEmailPasswordless(email)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
cy.goToHomePage()
|
|
||||||
cy.contains('You signed in anonymously').should('not.exist')
|
|
||||||
|
|
||||||
cy.fetchUserData().then((user) => {
|
|
||||||
cy.wrap(user).its('id').should('equal', id)
|
|
||||||
cy.wrap(user).its('email').should('equal', email)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// TODO implement deanonymisation with Oauth?
|
|
||||||
// TODO forbid email/password change, MFA activation, and password reset when the following PR is released
|
|
||||||
// * https://github.com/nhost/hasura-auth/pull/190
|
|
||||||
})
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Sign up with email+password', () => {
|
|
||||||
it('should sign-up with email and password', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const password = faker.internet.password()
|
|
||||||
cy.signUpEmailPassword(email, password)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
cy.contains('You are authenticated')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shoud raise an error when trying to sign up with an existing email', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const password = faker.internet.password(10)
|
|
||||||
cy.signUpEmailPassword(email, password)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
cy.signUpEmailPassword(email, password)
|
|
||||||
cy.contains('Email already in use').should('be.visible')
|
|
||||||
})
|
|
||||||
|
|
||||||
// TODO implement in the UI
|
|
||||||
it.skip('should fail when network is not available', () => {
|
|
||||||
cy.disconnectBackend()
|
|
||||||
cy.signUpEmailPassword(faker.internet.email(), faker.internet.password())
|
|
||||||
cy.contains('Error').should('be.visible')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Sign up with a magic link', () => {
|
|
||||||
it('should sign-up with a magic link', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
cy.signUpEmailPasswordless(email)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
cy.contains('Profile page')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should fail when network is not available', () => {
|
|
||||||
cy.disconnectBackend()
|
|
||||||
cy.signUpEmailPasswordless(faker.internet.email())
|
|
||||||
cy.contains('Error').should('be.visible')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
import totp from 'totp-generator'
|
|
||||||
|
|
||||||
import { faker } from '@faker-js/faker'
|
|
||||||
import { Decoder } from '@nuintun/qrcode'
|
|
||||||
|
|
||||||
context('Sign in with email+password', () => {
|
|
||||||
it('should sign-in with email and password', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const password = faker.internet.password()
|
|
||||||
cy.signUpEmailPassword(email, password)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
cy.signOut()
|
|
||||||
cy.contains('Sign in to the Application').should('be.visible')
|
|
||||||
cy.signInEmailPassword(email, password)
|
|
||||||
|
|
||||||
cy.contains('You are authenticated')
|
|
||||||
})
|
|
||||||
|
|
||||||
// TODO implement in the UI
|
|
||||||
it.skip('should fail when network is not available', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const password = faker.internet.password()
|
|
||||||
cy.disconnectBackend()
|
|
||||||
cy.signInEmailPassword(email, password)
|
|
||||||
cy.contains('Error').should('be.visible')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should activate and sign-in with MFA', () => {
|
|
||||||
// * Sign-up with email+password
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const password = faker.internet.email()
|
|
||||||
cy.signUpEmailPassword(email, password)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
|
|
||||||
cy.getNavBar()
|
|
||||||
.findByRole('button', { name: /Profile/i })
|
|
||||||
.click()
|
|
||||||
|
|
||||||
cy.findByText(/Activate 2-step verification/i)
|
|
||||||
.parent()
|
|
||||||
.findByRole('button')
|
|
||||||
.click()
|
|
||||||
|
|
||||||
cy.findAllByAltText(/qrcode/i).then(async (img) => {
|
|
||||||
// * Activate MFA
|
|
||||||
const result = await new Decoder().scan(img.prop('src'))
|
|
||||||
const [, params] = result.data.split('?')
|
|
||||||
const { secret, algorithm, digits, period } = Object.fromEntries(new URLSearchParams(params))
|
|
||||||
const code = totp(secret, {
|
|
||||||
algorithm: algorithm.replace('SHA1', 'SHA-1'),
|
|
||||||
digits: parseInt(digits),
|
|
||||||
period: parseInt(period)
|
|
||||||
})
|
|
||||||
cy.findByPlaceholderText('Enter activation code').type(code)
|
|
||||||
cy.findByRole('button', { name: /Activate/i }).click()
|
|
||||||
cy.contains('MFA has been activated!!!')
|
|
||||||
cy.signOut()
|
|
||||||
|
|
||||||
// * Sign-in with MFA
|
|
||||||
cy.visit('/sign-in')
|
|
||||||
cy.findByRole('button', { name: /Continue with email \+ password/i }).click()
|
|
||||||
cy.findByPlaceholderText('Email Address').type(email)
|
|
||||||
cy.findByPlaceholderText('Password').type(password)
|
|
||||||
cy.findByRole('button', { name: /Sign in/i }).click()
|
|
||||||
cy.contains('Send 2-step verification code')
|
|
||||||
const newCode = totp(secret, { timestamp: Date.now() })
|
|
||||||
cy.findByPlaceholderText('One-time password').type(newCode)
|
|
||||||
cy.findByRole('button', { name: /Send 2-step verification code/i }).click()
|
|
||||||
cy.contains('You are authenticated')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
context('Automatic sign-in with a refresh token', () => {
|
|
||||||
it('should sign in automatically with a refresh token', () => {
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.contains('Profile page')
|
|
||||||
cy.clearLocalStorage()
|
|
||||||
cy.reload()
|
|
||||||
cy.contains('Sign in to the Application')
|
|
||||||
cy.visitPathWithRefreshToken('/profile')
|
|
||||||
cy.contains('Profile page')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should fail automatic sign-in when network is not available', () => {
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.contains('Profile page')
|
|
||||||
cy.disconnectBackend()
|
|
||||||
cy.clearLocalStorage()
|
|
||||||
cy.reload()
|
|
||||||
cy.contains('Sign in to the Application')
|
|
||||||
cy.visitPathWithRefreshToken('/profile')
|
|
||||||
cy.contains('Could not sign in automatically. Retrying to get user information..')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Apollo', () => {
|
|
||||||
const addItemTest = (sentence: string) => {
|
|
||||||
cy.getNavBar()
|
|
||||||
.findByRole('button', { name: /Apollo/i })
|
|
||||||
.click()
|
|
||||||
cy.contains('Todo list')
|
|
||||||
cy.focused().type(sentence)
|
|
||||||
cy.findByRole('button', { name: /Add/i }).click()
|
|
||||||
}
|
|
||||||
|
|
||||||
it('should add an item to the todo list when normally authenticated', () => {
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
const sentence = faker.lorem.sentence()
|
|
||||||
addItemTest(sentence)
|
|
||||||
cy.get('li').contains(sentence)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should add an item to the todo list when anonymous', () => {
|
|
||||||
cy.signInAnonymous()
|
|
||||||
const sentence = faker.lorem.sentence()
|
|
||||||
addItemTest(sentence)
|
|
||||||
cy.get('li').contains(sentence)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should add an item to the todo list after a token refresh', () => {
|
|
||||||
// * This test has a limitation: Hasura's clock is not changing, so the previous JWT will still be valid.
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
const now = Date.now()
|
|
||||||
cy.clock(now)
|
|
||||||
cy.tick(4 * 7 * 24 * 60 * 60 * 1000)
|
|
||||||
const sentence = faker.lorem.sentence()
|
|
||||||
addItemTest(sentence)
|
|
||||||
cy.get('li').contains(sentence)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should not add an item when backend is disconnected', () => {
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.disconnectBackend()
|
|
||||||
addItemTest(faker.lorem.sentence())
|
|
||||||
cy.contains('Network error')
|
|
||||||
cy.get('ul').should('be.empty')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Change email', () => {
|
|
||||||
it('should change email', () => {
|
|
||||||
const newEmail = faker.internet.email()
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.findByPlaceholderText('New email').type(newEmail)
|
|
||||||
cy.findByText(/Change Email/i)
|
|
||||||
.parent()
|
|
||||||
.findByRole('button')
|
|
||||||
.click()
|
|
||||||
cy.contains('Please check your inbox and follow the link to confirm the email change').should(
|
|
||||||
'be.visible'
|
|
||||||
)
|
|
||||||
cy.signOut()
|
|
||||||
cy.confirmEmail(newEmail)
|
|
||||||
cy.contains('Profile page')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should not accept an invalid email', () => {
|
|
||||||
const newEmail = faker.random.alphaNumeric()
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.findByPlaceholderText('New email').type(newEmail)
|
|
||||||
cy.findByText(/Change Email/i)
|
|
||||||
.parent()
|
|
||||||
.findByRole('button')
|
|
||||||
.click()
|
|
||||||
cy.contains('Email is incorrectly formatted').should('be.visible')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Change password', () => {
|
|
||||||
it('should change password', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
const newPassword = faker.internet.password()
|
|
||||||
cy.signUpAndConfirmEmail(email)
|
|
||||||
cy.findByPlaceholderText('New password').type(newPassword)
|
|
||||||
cy.findByText(/Change Password/i)
|
|
||||||
.parent()
|
|
||||||
.findByRole('button')
|
|
||||||
.click()
|
|
||||||
cy.contains('Password changed successfully').should('be.visible')
|
|
||||||
cy.signOut()
|
|
||||||
cy.signInEmailPassword(email, newPassword)
|
|
||||||
cy.contains('You are authenticated')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should not accept an invalid password', () => {
|
|
||||||
const newPassword = faker.random.alphaNumeric(2)
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.findByPlaceholderText('New password').type(newPassword)
|
|
||||||
cy.findByText(/Change Password/i)
|
|
||||||
.parent()
|
|
||||||
.findByRole('button')
|
|
||||||
.click()
|
|
||||||
cy.contains('Password is incorrectly formatted').should('be.visible')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
context('File uploads', () => {
|
|
||||||
it('should upload a single file', () => {
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.findByRole('button', { name: /Storage/i }).click()
|
|
||||||
cy.findByRole('button', { name: /Drag a file here or click to select/i })
|
|
||||||
.children('input[type=file]')
|
|
||||||
.selectFile(
|
|
||||||
{
|
|
||||||
contents: Cypress.Buffer.from('file contents'),
|
|
||||||
fileName: 'file.txt',
|
|
||||||
mimeType: 'text/plain',
|
|
||||||
lastModified: Date.now()
|
|
||||||
},
|
|
||||||
{ force: true }
|
|
||||||
)
|
|
||||||
.parent()
|
|
||||||
.contains('Successfully uploaded')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should upload two files using the same single file uploader', () => {
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.findByRole('button', { name: /Storage/i }).click()
|
|
||||||
cy.findByRole('button', { name: /Drag a file here or click to select/i })
|
|
||||||
.children('input[type=file]')
|
|
||||||
.selectFile(
|
|
||||||
{
|
|
||||||
contents: Cypress.Buffer.from('file contents'),
|
|
||||||
fileName: 'file.txt',
|
|
||||||
mimeType: 'text/plain',
|
|
||||||
lastModified: Date.now()
|
|
||||||
},
|
|
||||||
{ force: true }
|
|
||||||
)
|
|
||||||
.selectFile(
|
|
||||||
{
|
|
||||||
contents: Cypress.Buffer.from('file contents'),
|
|
||||||
fileName: 'file.txt',
|
|
||||||
mimeType: 'text/plain',
|
|
||||||
lastModified: Date.now()
|
|
||||||
},
|
|
||||||
{ force: true }
|
|
||||||
)
|
|
||||||
.parent()
|
|
||||||
.contains('Successfully uploaded')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should upload multiple files', () => {
|
|
||||||
const files: Required<Cypress.FileReferenceObject>[] = [
|
|
||||||
{
|
|
||||||
contents: Cypress.Buffer.from('file contents'),
|
|
||||||
fileName: 'file1.txt',
|
|
||||||
mimeType: 'text/plain',
|
|
||||||
lastModified: Date.now()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
contents: Cypress.Buffer.from('file contents'),
|
|
||||||
fileName: 'file2.txt',
|
|
||||||
mimeType: 'text/plain',
|
|
||||||
lastModified: Date.now()
|
|
||||||
}
|
|
||||||
]
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
cy.findByRole('button', { name: /Storage/i }).click()
|
|
||||||
cy.findByRole('button', { name: /Drag files here or click to select/i })
|
|
||||||
.children('input[type=file]')
|
|
||||||
.selectFile(files, { force: true })
|
|
||||||
cy.findByRole('button', { name: /Upload/i }).click()
|
|
||||||
cy.findByRole('button', { name: /Successfully uploaded/i }).should('be.visible')
|
|
||||||
cy.findByRole('table').within(() => {
|
|
||||||
files.forEach((file) => {
|
|
||||||
cy.contains(file.fileName).parent().findByTitle('success').should('exist')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
context('Sign out', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.signUpAndConfirmEmail()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should sign out', () => {
|
|
||||||
cy.visitPathWithRefreshToken()
|
|
||||||
cy.goToProfilePage()
|
|
||||||
cy.contains('Profile page')
|
|
||||||
cy.signOut()
|
|
||||||
cy.contains('Sign in to the Application')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import { faker } from '@faker-js/faker'
|
|
||||||
|
|
||||||
context('Token refresh', () => {
|
|
||||||
it('should refresh token one minute before it expires', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
cy.signUpEmailPasswordless(email)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
const now = Date.now()
|
|
||||||
cy.clock(now)
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
|
|
||||||
cy.intercept(Cypress.env('backendUrl') + '/v1/auth/token').as('tokenRequest')
|
|
||||||
cy.tick(14 * 60 * 1000)
|
|
||||||
cy.wait('@tokenRequest').its('response.statusCode').should('eq', 200)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should refresh session from localStorage after 4 weeks of inactivity', () => {
|
|
||||||
const email = faker.internet.email()
|
|
||||||
cy.signUpEmailPasswordless(email)
|
|
||||||
cy.contains('Verification email sent').should('be.visible')
|
|
||||||
const now = Date.now()
|
|
||||||
cy.clock(now)
|
|
||||||
cy.confirmEmail(email)
|
|
||||||
cy.contains('Profile page')
|
|
||||||
|
|
||||||
cy.tick(4 * 7 * 24 * 60 * 60 * 1000)
|
|
||||||
cy.reload()
|
|
||||||
cy.contains('Profile page')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user