Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feat/adding pages #3

Merged
merged 74 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
8484c76
feat: reset password page
armanddidierjean May 26, 2024
75039b1
format
armanddidierjean May 26, 2024
5763656
feat: show a toast in case of success or error
armanddidierjean May 26, 2024
de0aa69
feat: get variables from json file
armanddidierjean May 26, 2024
01f1f61
feat: get query param using window.location.search
armanddidierjean May 27, 2024
f62a3d2
feat: serve variable.json from Python module
armanddidierjean May 27, 2024
dc0b8dc
feat: adding hidden input
maximeroucher May 27, 2024
5e4188d
feat: UI improvement
maximeroucher May 27, 2024
40bd506
feat: adding remaining pages
maximeroucher May 27, 2024
453d576
fix: ui
maximeroucher May 27, 2024
462d979
feat: adding border animation on border
maximeroucher May 27, 2024
8552232
feat: cleanup
maximeroucher May 27, 2024
2bf3d41
feat: adding responsive
maximeroucher May 27, 2024
1b172d4
feat: color and text update
maximeroucher May 28, 2024
f4f5ba2
fix: hidden input border
maximeroucher May 28, 2024
a94f4bd
fix: background
maximeroucher May 28, 2024
9bbeacf
fix: config
maximeroucher May 29, 2024
1e25bd5
refacto extracting background
maximeroucher May 29, 2024
38fa938
fix: typo
maximeroucher May 29, 2024
2f22dac
feat: extracting all pages
maximeroucher May 29, 2024
6d2c78f
refacto: extracting card
maximeroucher May 29, 2024
eaaeaf5
fix: link between pages
maximeroucher May 29, 2024
fa18bd7
feat: using hidden field for query code
maximeroucher May 29, 2024
80b7172
feat: removing unused component
maximeroucher May 29, 2024
803dd6b
feat: removing root page
maximeroucher May 29, 2024
c77b6dc
fix: adding suspense boundary for hidden field
maximeroucher May 29, 2024
4f49494
fix: centeredCard unused style
maximeroucher May 29, 2024
6f92e83
feat: adding success pages
maximeroucher May 29, 2024
29d933b
refacto: extracting success card
maximeroucher May 29, 2024
3aa6273
feat: adding codegen for api calls
maximeroucher May 29, 2024
b2a90da
feat: adding api calls for all but login
maximeroucher May 29, 2024
ceb28c6
feat: adding authentication
maximeroucher May 30, 2024
50ab8e1
feat: adding error handling
maximeroucher May 30, 2024
6e90751
feat: retrieving auth information
maximeroucher May 30, 2024
7819045
feat: retrieving backend url
maximeroucher May 30, 2024
81230a1
feat: updating font
maximeroucher May 30, 2024
f3fa6f6
feat: remove variables.json
armanddidierjean May 30, 2024
ca40db6
feat: use NEXT_PUBLIC_OVERRIDE_HYPERION_URL instead of the current pa…
armanddidierjean May 30, 2024
e41c416
fix: muted foreground color
maximeroucher May 30, 2024
a5bf468
fix: get baseUrl from window only if defined
armanddidierjean May 30, 2024
8806a81
feat: SuspenseHiddenFields
armanddidierjean May 30, 2024
1ab63ff
feat: build with trailingSlash to be able to access files without the…
armanddidierjean May 30, 2024
e5b0198
feat: format
armanddidierjean May 31, 2024
091501d
fix: lint
armanddidierjean May 31, 2024
8543888
feat: generate client using Hyperion main
armanddidierjean Jun 1, 2024
bedf123
fix: allow to override client baseUrl with an environment variable
armanddidierjean Jun 1, 2024
172ba66
wip: login logic
armanddidierjean Jun 2, 2024
1ee48da
refacto: using new codegen
maximeroucher Jun 6, 2024
4a08175
feat: updating provider
maximeroucher Jun 6, 2024
6fd13f2
feat: adding error toast
maximeroucher Jun 6, 2024
c21f92f
fix: login form
maximeroucher Jun 6, 2024
ac78c67
fix: base url
maximeroucher Jun 6, 2024
033cbaf
fix: codegen output folder
maximeroucher Jun 8, 2024
750c315
Fix types
armanddidierjean Jun 9, 2024
523f5e2
Allow to register external users
armanddidierjean Jun 9, 2024
d12159c
Add password validation rules
armanddidierjean Jun 9, 2024
aa2f170
Add a password type
armanddidierjean Jun 10, 2024
385fd4f
fix: removing button on link
maximeroucher Jun 11, 2024
a535830
feat: add required hidden fields for login
armanddidierjean Jun 11, 2024
3d2a065
feat: error page
armanddidierjean Jun 11, 2024
924c739
fix: use SuspenseHiddenField for reset-password
armanddidierjean Jun 11, 2024
0729b2d
feat: adding error message on login
maximeroucher Jun 11, 2024
ab78e14
feat: updating reset_token query
maximeroucher Jun 11, 2024
9153d8b
fix: restricting suspense to login fields
maximeroucher Jun 11, 2024
34f0160
feat: remove activation code min requirement
armanddidierjean Jun 13, 2024
e21a170
fix: make login query params optional
armanddidierjean Jun 13, 2024
9914725
feat: redirect to an error page if a required hidden param is missing
armanddidierjean Jun 13, 2024
2a24f9b
feat: allow to activate ECL account with more information
armanddidierjean Jun 13, 2024
cd09e83
fix: lower case external value boolean
armanddidierjean Jun 13, 2024
2de6447
feat(Python): methods to construct relative urls
armanddidierjean Jun 13, 2024
7f98e4c
feat(Python): add ruff and mypy configuration
armanddidierjean Jun 13, 2024
937c7d8
fix: mask component instead of show
armanddidierjean Jun 13, 2024
24ec3b7
feat: animate phone and select borders
armanddidierjean Jun 13, 2024
6fec706
feat: format project
armanddidierjean Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_OVERRIDE_HYPERION_URL = "http://localhost:8000"
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"ignorePatterns": [
"src/components/ui/*",
"src/api/hyperionComponents.ts",
"src/api/hyperionSchemas.ts"
"src/api/hyperionSchemas.ts",
"src/api/hyperionFetcher.ts",
"src/api/hyperionContext.ts"
],
"parser": "@typescript-eslint/parser",
"root": true
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ next-env.d.ts

# Python module
*.egg-info
dist
dist
.env
.ruff_cache
.mypy_cache
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ node_modules

# Shadcn components
src/components/ui
src/api/hyperionComponents.ts
src/api/hyperionSchemas.ts

# Generated Hyperion client
src/api
3 changes: 3 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const nextConfig = {
output: "export",
basePath: "/calypsso",
distDir: "out",
// We use `trailingSlash` to ask Next to create `index.html` pages for all routes
// We need them to be able to access files without their .html extension (ex: /calypsso/register instead of needing /calypsso/register.html)
trailingSlash: true,
};

export default nextConfig;
7 changes: 7 additions & 0 deletions openapi-ts.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
input: `http://127.0.0.1:8000/openapi.json`,
output: "src/api",
client: "@hey-api/client-fetch",
});
22 changes: 19 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,40 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"format": "npx prettier . --write"
"format": "npx prettier . --write",
"generate": "openapi-ts"
},
"dependencies": {
"@hey-api/client-fetch": "^0.1.3",
"@hookform/resolvers": "^3.4.2",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"@tabler/icons-react": "^3.5.0",
"@tanstack/react-query": "^5.40.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"framer-motion": "^11.2.6",
"lucide-react": "^0.378.0",
"next": "14.2.3",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.51.5",
"react-icons": "^5.2.1",
"react-phone-input-2": "^2.15.1",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7"
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@hey-api/openapi-ts": "^0.46.3",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"eslint-config-prettier": "^9.1.0",
Expand Down
60 changes: 60 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,63 @@ packages = ["python/calypsso"]

[[tool.hatch.envs.all.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[tool.ruff]
# By default ruff also respect gitignore files
# Same as Black.
line-length = 88
indent-width = 4
target-version = "py311"

[tool.ruff.lint]
select = [
"F",
"E",
"W",
"I",
"T201",
"C90",
"DTZ",
"UP",
"ASYNC",
"S",
"B",
"A",
"COM",
"C4",
"ISC",
"ICN",
"INP",
"PIE",
"T20",
"PYI",
"PT",
"Q",
"SLF",
"SLOT",
"SIM",
"TCH",
"PTH",
"RUF",
]
ignore = [
"E501"
]

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"
# Like Black, indent with spaces, rather than tabs.
indent-style = "space"
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.mypy]
python_version = "3.11"
strict = true
77 changes: 73 additions & 4 deletions python/calypsso/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,87 @@
import importlib.resources
import urllib.parse
from typing import Any

from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles

import importlib.resources

MODULE_PATH = importlib.resources.files(__package__)


def get_calypsso_app() -> FastAPI:
"""
Construct a FastAPI application serving CalypSSO compiled ressources.

This application MUST be mounted on the subpath `/calypsso`.

Usage exemple with a FastAPI application `app`:
```python
calypsso = get_calypsso_app()
app.mount("/calypsso", calypsso)
```
"""
app = FastAPI()
print(MODULE_PATH)

app.mount(
"/",
StaticFiles(directory=MODULE_PATH / "public"),
StaticFiles(directory=str(MODULE_PATH / "public"), html=True),
name="calypsso",
)
return app


def exclude_none(original: dict[str, Any]) -> dict[str, Any]:
return {k: v for k, v in original.items() if v is not None}


def get_error_relative_url(message: str) -> str:
"""
Return CalypSSO error page relative url: `calypsso/error?message=...`
"""
params = {"message": message}
return f"calypsso/error?{urllib.parse.urlencode(exclude_none(params))}"


def get_reset_password_relative_url(reset_token: str) -> str:
"""
Return CalypSSO reset password page relative url: `calypsso/reset-password?reset_token=...`
"""
params = {"reset_token": reset_token}
return f"calypsso/reset-password/?{urllib.parse.urlencode(exclude_none(params))}"


def get_activate_relative_url(activation_token: str, external: bool) -> str:
"""
Return CalypSSO account activation page relative url: `calypsso/activate?activation_code=...`
"""
params = {"activation_token": activation_token, "external": external}
return f"calypsso/activate/?{urllib.parse.urlencode(exclude_none(params))}"


def get_login_relative_url(
client_id: str,
response_type: str,
redirect_uri: str | None = None,
scope: str | None = None,
state: str | None = None,
nonce: str | None = None,
code_challenge: str | None = None,
code_challenge_method: str | None = None,
credentials_error: bool | None = None,
) -> str:
"""
Return CalypSSO login page relative url: `calypsso/login?...`
"""
params = {
"client_id": client_id,
"response_type": response_type,
"redirect_uri": redirect_uri,
"scope": scope,
"state": state,
"nonce": nonce,
"code_challenge": code_challenge,
"code_challenge_method": code_challenge_method,
"credentials_error": credentials_error,
}

return f"calypsso/login/?{urllib.parse.urlencode(exclude_none(params))}"
4 changes: 4 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file is auto-generated by @hey-api/openapi-ts
export * from './schemas.gen';
export * from './services.gen';
export * from './types.gen';
Loading