Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
92 changes: 92 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -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

48 changes: 20 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
1 change: 1 addition & 0 deletions app/components/dashboard/data/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type TableProps = {
deleteQuery: any;
allowCopy?: boolean;
actions?: any[];
globalActions?: any[];
onExport?: (rowData: any) => void;
FormComponent?: (props: unknown) => JSX.Element;
};
Expand Down
3 changes: 3 additions & 0 deletions app/components/dashboard/data/TableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type TableProps = {
onExport?: (rowData: any) => void;
FormComponent?: (props: unknown) => JSX.Element;
actions?: any[];
globalActions?: any[];
onAdd: () => void;
onEdit?: (values) => void;
};
Expand All @@ -44,6 +45,7 @@ export default function TableContainer(props: TableProps) {
onExport,
FormComponent,
actions = [],
globalActions,
onAdd,
onEdit
} = props;
Expand Down Expand Up @@ -124,6 +126,7 @@ export default function TableContainer(props: TableProps) {
onAdd={FormComponent ? onAdd : undefined}
onDelete={handleDeleteAllClick}
onExport={handleExportAllClick}
actions={globalActions}
/>

<MuiTableContainer className="text-center">
Expand Down
34 changes: 33 additions & 1 deletion app/components/dashboard/data/TableToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -69,6 +91,16 @@ export default function TableToolbar({ title, numSelected, onAdd, onDelete, onEx
onKeyDown={onSearch}
/>

{actions.map(({ title, icon, action }) => (
<>
<Tooltip title={title}>
<IconButton aria-label={title} onClick={action} size="large">
{icon}
</IconButton>
</Tooltip>
</>
))}

{onAdd && (
<div>
<Tooltip title="Ajouter">
Expand Down
21 changes: 0 additions & 21 deletions app/core/lib/gtag.ts

This file was deleted.

7 changes: 6 additions & 1 deletion app/entities/clubs/queries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@

# getClubs

- Can be performed by any user
- 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
2 changes: 1 addition & 1 deletion app/entities/clubs/queries/getClubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resolver } from '@blitzjs/rpc';
type GetClubsInput = Pick<Prisma.ClubFindManyArgs, 'where' | 'orderBy' | 'skip' | 'take'>;

export default resolver.pipe(
resolver.authorize(['*', 'bde']),
resolver.authorize(),
async ({ where, orderBy, skip = 0, take }: GetClubsInput, _ctx) => {
const clubs = await db.club.findMany({
where,
Expand Down
14 changes: 14 additions & 0 deletions app/entities/users/mutations/resetMembershipState.ts
Original file line number Diff line number Diff line change
@@ -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
}
});
});
19 changes: 1 addition & 18 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -65,21 +63,6 @@ export default withBlitz(function App({ Component, pageProps }: BDEAppProps) {
</ErrorBoundary>
</ThemeProvider>
</StyledEngineProvider>

<Script id="gtag" src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_TRACKING_ID}`} />
<Script
id="gtag_init"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GA_TRACKING_ID}', {
page_path: window.location.pathname,
});
`
}}
/>
</StrictMode>
);
});
Loading
Loading