diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 00000000..037a74c4 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,92 @@ +name: Nightly + +on: + push: + branches: + - staging + paths-ignore: + - '.devcontainer/**' + - '.zed/**' + - '.husky/**' + - 'docs/**' + - 'release/**' + +jobs: + # sonarcloud: + # name: SonarCloud + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # with: + # fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + # - name: SonarCloud Scan + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + release: + name: 'Build and push image 🔨🚀' + runs-on: ubuntu-latest + # needs: sonarcloud + environment: + name: staging + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Make envfile + uses: SpicyPizza/create-envfile@v2 + with: + envkey_NODE_ENV: production + envkey_CONTACT_MAIL: ${{ secrets.CONTACT_MAIL }} + envkey_DATABASE_URL: ${{ secrets.DATABASE_URL }} + envkey_SESSION_SECRET_KEY: ${{ secrets.SESSION_SECRET_KEY }} + envkey_NEXT_PUBLIC_FRONTEND_URL: ${{ secrets.NEXT_PUBLIC_FRONTEND_URL }} + envkey_NEXT_PUBLIC_GA_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GA_TRACKING_ID }} + envkey_NEXT_PUBLIC_DISCORD_SERVER_URL: ${{ secrets.NEXT_PUBLIC_DISCORD_SERVER_URL }} + envkey_SMTP_EMAIL: bde.isima.webmaster@gmail.com + envkey_SMTP_USER: bde.isima.webmaster + envkey_SMTP_HOST: ${{ secrets.SMTP_HOST }} + envkey_SMTP_PORT: ${{ secrets.SMTP_PORT }} + envkey_SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push container image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ghcr.io/bde-isima/bde.isima.fr/staging:latest + build-args: | + DATABASE_URL=${{ secrets.DATABASE_URL }} + + deploy: + name: Deploy to VPS + runs-on: ubuntu-latest + needs: release + steps: + - name: Connecting via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY}} + port: 22 + script_stop: true # stop script on first error + script: | + docker pull -q ghcr.io/bde-isima/bde.isima.fr/staging:latest + if [ "$(docker ps -aq -f name=bde_app_dev)" ]; then + docker stop bde_app_dev && docker rm bde_app_dev + fi + docker run -d --name bde_app_dev --network ubuntu_bde_isima_net ghcr.io/bde-isima/bde.isima.fr/staging:latest + docker image prune -f + docker exec bde_nginx nginx -s reload + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 28511bd9..3e5f8b0d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,44 +2,36 @@ name: Release on: push: - branches: - - main - - staging - paths-ignore: - - '.devcontainer/**' - - '.husky/**' - - 'docs/**' - - 'release/**' + tags: + - 'v1.**' jobs: - branch_check: - name: 'Check current branch to determine environment 👀' - runs-on: ubuntu-latest - - steps: - - id: branch_check - run: | - if [ "${{ github.ref }}" = "refs/heads/main" ]; then - echo "::set-output name=env_name::production" - else - echo "::set-output name=env_name::staging" - fi - outputs: - env_name: ${{ steps.branch_check.outputs.env_name }} + # sonarcloud: + # name: SonarCloud + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # with: + # fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + # - name: SonarCloud Scan + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} release: name: 'Build and push image 🔨🚀' runs-on: ubuntu-latest needs: branch_check environment: - name: ${{ needs.branch_check.outputs.env_name }} + name: production steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Make envfile - uses: SpicyPizza/create-envfile@v1 + uses: SpicyPizza/create-envfile@v2 with: envkey_NODE_ENV: production envkey_CONTACT_MAIL: ${{ secrets.CONTACT_MAIL }} @@ -55,17 +47,17 @@ jobs: envkey_SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push container image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . push: true - tags: ghcr.io/bde-isima/bde.isima.fr/${{ needs.branch_check.outputs.env_name }}:latest + tags: ghcr.io/bde-isima/bde.isima.fr/production:latest build-args: | DATABASE_URL=${{ secrets.DATABASE_URL }} diff --git a/app/components/dashboard/data/Table.tsx b/app/components/dashboard/data/Table.tsx index 5fac375d..ad09c2b1 100644 --- a/app/components/dashboard/data/Table.tsx +++ b/app/components/dashboard/data/Table.tsx @@ -17,6 +17,7 @@ type TableProps = { deleteQuery: any; allowCopy?: boolean; actions?: any[]; + globalActions?: any[]; onExport?: (rowData: any) => void; FormComponent?: (props: unknown) => JSX.Element; }; diff --git a/app/components/dashboard/data/TableContainer.tsx b/app/components/dashboard/data/TableContainer.tsx index ad3e72f6..908b044a 100644 --- a/app/components/dashboard/data/TableContainer.tsx +++ b/app/components/dashboard/data/TableContainer.tsx @@ -28,6 +28,7 @@ type TableProps = { onExport?: (rowData: any) => void; FormComponent?: (props: unknown) => JSX.Element; actions?: any[]; + globalActions?: any[]; onAdd: () => void; onEdit?: (values) => void; }; @@ -44,6 +45,7 @@ export default function TableContainer(props: TableProps) { onExport, FormComponent, actions = [], + globalActions, onAdd, onEdit } = props; @@ -124,6 +126,7 @@ export default function TableContainer(props: TableProps) { onAdd={FormComponent ? onAdd : undefined} onDelete={handleDeleteAllClick} onExport={handleExportAllClick} + actions={globalActions} /> diff --git a/app/components/dashboard/data/TableToolbar.tsx b/app/components/dashboard/data/TableToolbar.tsx index 23416390..50fec6de 100644 --- a/app/components/dashboard/data/TableToolbar.tsx +++ b/app/components/dashboard/data/TableToolbar.tsx @@ -14,7 +14,29 @@ import Search from '@mui/icons-material/SearchTwoTone'; import TableDeleteConfirm from './TableDeleteConfirm'; import { useTableProps } from './TablePropsProvider'; -export default function TableToolbar({ title, numSelected, onAdd, onDelete, onExport }) { +type TableActionProps = { + title: string; + icon: React.ReactNode; + action: () => void; +}; + +type TableToolbarProps = { + title: string; + numSelected: number; + onAdd?: () => void; + onDelete?: () => void; + onExport?: (rowData: any) => void; + actions?: TableActionProps[]; +}; + +export default function TableToolbar({ + title, + numSelected, + onAdd, + onDelete, + onExport, + actions = [] +}: TableToolbarProps) { const { search } = useTableProps(); const [open, setOpen] = useState(false); @@ -69,6 +91,16 @@ export default function TableToolbar({ title, numSelected, onAdd, onDelete, onEx onKeyDown={onSearch} /> + {actions.map(({ title, icon, action }) => ( + <> + + + {icon} + + + + ))} + {onAdd && (
diff --git a/app/core/lib/gtag.ts b/app/core/lib/gtag.ts deleted file mode 100644 index a12fef73..00000000 --- a/app/core/lib/gtag.ts +++ /dev/null @@ -1,21 +0,0 @@ -declare global { - interface Window { - gtag: any; - } -} - -// https://developers.google.com/analytics/devguides/collection/gtagjs/pages -export const pageview = (url) => { - window.gtag('config', process.env.NEXT_PUBLIC_GA_TRACKING_ID, { - page_path: url - }); -}; - -// https://developers.google.com/analytics/devguides/collection/gtagjs/events -export const event = ({ action, category, label, value }) => { - window.gtag('event', action, { - event_category: category, - event_label: label, - value: value - }); -}; diff --git a/app/entities/clubs/queries/README.md b/app/entities/clubs/queries/README.md index 49d12bce..f4a3ccdc 100644 --- a/app/entities/clubs/queries/README.md +++ b/app/entities/clubs/queries/README.md @@ -2,4 +2,9 @@ # getClubs -- Can be performed by any user \ No newline at end of file +- Can be performed by any registered user + +# getPublicClubs + +- Can be performed by any user and guest +- Restrict shown clubs and available operation to the data \ No newline at end of file diff --git a/app/entities/clubs/queries/getClubs.ts b/app/entities/clubs/queries/getClubs.ts index 287e8a7a..a818fc7a 100644 --- a/app/entities/clubs/queries/getClubs.ts +++ b/app/entities/clubs/queries/getClubs.ts @@ -5,7 +5,7 @@ import { resolver } from '@blitzjs/rpc'; type GetClubsInput = Pick; export default resolver.pipe( - resolver.authorize(['*', 'bde']), + resolver.authorize(), async ({ where, orderBy, skip = 0, take }: GetClubsInput, _ctx) => { const clubs = await db.club.findMany({ where, diff --git a/app/entities/users/mutations/resetMembershipState.ts b/app/entities/users/mutations/resetMembershipState.ts new file mode 100644 index 00000000..4cfb8b88 --- /dev/null +++ b/app/entities/users/mutations/resetMembershipState.ts @@ -0,0 +1,14 @@ +import db from 'db'; + +import { resolver } from '@blitzjs/rpc'; + +export default resolver.pipe(resolver.authorize(['*']), async () => { + return await db.user.updateMany({ + data: { + is_member: false + }, + where: { + is_member: true + } + }); +}); diff --git a/pages/_app.tsx b/pages/_app.tsx index 24555ea2..f93424bb 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -14,7 +14,6 @@ import { useQueryErrorResetBoundary } from '@blitzjs/rpc'; import { withBlitz } from 'app/blitz-client'; import Splash from 'app/components/common/Splash'; import RootErrorFallback from 'app/core/lib/ErrorBoundary'; -import * as gtag from 'app/core/lib/gtag'; import { useRouter } from 'app/core/lib/router'; import 'app/core/styles/index.css'; import { useTheme } from 'app/core/styles/theme'; @@ -33,9 +32,8 @@ export default withBlitz(function App({ Component, pageProps }: BDEAppProps) { useEffect(() => { const handleRouteChangeStart = () => NProgress.start(); - const handleRouteChange = (url: string) => { + const handleRouteChange = (_url: string) => { NProgress.done(); - gtag.pageview(url); }; router.events.on('routeChangeStart', handleRouteChangeStart); @@ -65,21 +63,6 @@ export default withBlitz(function App({ Component, pageProps }: BDEAppProps) { - -