Skip to content
Merged
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
93 changes: 65 additions & 28 deletions .github/workflows/frontend_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,80 @@ on:
paths:
- "frontend/**"

defaults:
run:
working-directory: frontend

jobs:
fe-tests:
runs-on: ubuntu-22.04
# CHECK 1: Linter
fe-lint:
runs-on: ubuntu-24.04
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: "install node v20.15 and cash npm"
# https://github.com/actions/setup-node
uses: actions/setup-node@v7
- uses: actions/checkout@v6
- name: "install node and cache npm"
uses: actions/setup-node@v6
with:
node-version: 20.15
node-version: 26.12
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: "install dependencies"
working-directory: frontend
run: npm install --frozen-lockfile --silent
run: npm ci
- name: "run eslint check"
working-directory: frontend
run: npm run lint

# CHECK 2: Unit Tests
fe-test:
name: "fe-test"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6

- name: "install node and cache npm"
uses: actions/setup-node@v6
with:
node-version: 26.12
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: "install dependencies"
run: npm ci
- name: "run unit test"
working-directory: frontend
run: npm run test:coverage
# - name: Cache SonarCloud packages
# uses: actions/cache@v4
# with:
# path: ~/.sonar/cache
# key: ${{ runner.os }}-sonar
# restore-keys: ${{ runner.os }}-sonar
# - name: SonarCloud Scan frontend
# uses: sonarsource/sonarcloud-github-action@master
# with:
# projectBaseDir: frontend
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

# Save PR info inside the coverage directory for frontend_sonar.yml to use
- name: Save PR info
run: |
mkdir -p coverage
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "${{ github.event.pull_request.number }}" > coverage/pr_number.txt
echo "${{ github.event.pull_request.base.ref }}" > coverage/pr_base.txt
echo "PR_NUMBER: ${{ github.event.pull_request.number }}"
else
echo "false" > coverage/pr_number.txt
echo "false" > coverage/pr_base.txt
echo "Not a pull_request. Event: ${{ github.event_name }}"
fi
# Upload the coverage folder for SonarCloud (fe-sonar) to use
- name: "upload coverage artifact"
uses: actions/upload-artifact@v7
with:
name: frontend-coverage
path: frontend/coverage/
# Automatically clean up after 24 hours
retention-days: 1

# CHECK 3: Build Verification
fe-build:
name: "fe-build"
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: "install node and cache npm"
uses: actions/setup-node@v6
with:
node-version: 26.12
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: "install dependencies"
run: npm ci
- name: "run build test"
working-directory: frontend
run: npm run build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ yarn-error.log*
*.tsbuildinfo
.history

# next ignore
next-env.d.ts

**.tar
59 changes: 47 additions & 12 deletions frontend/components/admin/logs/DeleteOldLogsBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,61 @@
//
// SPDX-License-Identifier: Apache-2.0

import {useState} from 'react'
import IconButton from '@mui/material/IconButton'
import AutoDeleteIcon from '@mui/icons-material/AutoDelete'
import Menu from '@mui/material/Menu'
import MenuItem from '@mui/material/MenuItem'
import Fade from '@mui/material/Fade'

type DeleteOldLogs={
disabled: boolean
onDelete:()=>void
onDelete:(days:number)=>void
}

export default function DeleteOldLogsBtn({disabled,onDelete}:DeleteOldLogs) {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null)
const open = Boolean(anchorEl)
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget)
}
const handleClose = () => {
setAnchorEl(null)
}

function DeleteItems(days:number){
onDelete(days)
handleClose()
}
return (
<IconButton
title="Delete logs older than 30 days"
disabled={disabled}
sx={{
alignSelf:'center',
marginRight:'1rem'
}}
onClick={onDelete}
>
<AutoDeleteIcon />
</IconButton>
<div>
<IconButton
title="Delete logs"
disabled={disabled}
sx={{
alignSelf:'center',
margin: '0.25rem 0.5rem 0rem 0.25rem'
}}
onClick={handleClick}
>
<AutoDeleteIcon />
</IconButton>
<Menu
id="fade-menu"
slotProps={{
list: {
'aria-labelledby': 'fade-button',
},
}}
slots={{transition: Fade}}
anchorEl={anchorEl}
open={open}
onClose={handleClose}
>
<MenuItem onClick={()=>DeleteItems(30)}>&gt; 30 days</MenuItem>
<MenuItem onClick={()=>DeleteItems(7)}>&gt; 7 days</MenuItem>
<MenuItem onClick={()=>DeleteItems(0)}>Delete All</MenuItem>
</Menu>
</div>
)
}
2 changes: 1 addition & 1 deletion frontend/components/admin/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function ScraperErrorLogs() {
<div className="flex-1 flex py-8 md:py-0 flex-col xl:flex-row justify-start xl:items-center">
<div className="flex-1 flex justify-start">
<DeleteOldLogsBtn
onDelete={()=>deleteOldLogs()}
onDelete={deleteOldLogs}
disabled={logs.length===0}
/>
<Searchbox />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ export default function AutosaveFundingOrganisations({id,items}:FundingOrganisat
title={item.name}
label={item.name}
onDelete={() => onRemoveOgranisation(pos)}
sx={{
maxWidth: '21rem'
}}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ export default function AutosaveResearchDomains({project_id, research_domains}:
<FormControl
variant="standard"
fullWidth
// sx={{
// width: '100%',
// // maxWidth: '30rem'
// }}
>
<InputLabel
shrink={true}
Expand Down Expand Up @@ -222,10 +218,6 @@ export default function AutosaveResearchDomains({project_id, research_domains}:
<FormControl
variant="standard"
fullWidth
// sx={{
// width: '100%',
// // maxWidth: '30rem'
// }}
>
<InputLabel
shrink={true}
Expand Down Expand Up @@ -253,10 +245,6 @@ export default function AutosaveResearchDomains({project_id, research_domains}:
title={item.description}
key={item.key}
value={item.key}
sx={{
// maxWidth: '30rem',
whiteSpace: 'break-spaces'
}}
>
{item.name}
</MenuItem>
Expand Down
7 changes: 0 additions & 7 deletions frontend/next-env.d.ts

This file was deleted.

Loading