Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ context('Back Office > Regulatory Area > Create Regulatory Area', () => {
cy.fill('Façade', 'NAMO')
cy.fill('Type d’acte administratif', 'Arrêté inter-préfectoral')
cy.fill('Tags et sous-tags', ['AMP'])
cy.fill('Résumé', 'Résumé de la nouvelle zone réglementaire')
cy.getDataCy('resume-markdown-editor').click().type('Résumé de la nouvelle zone réglementaire')
cy.get('#PIRCType').click()

cy.fill('URL du lien', 'https://www.google.com')
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/rgaa.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ context('Axe core RGAA check that ', () => {
cy.injectAxe()
checkA11y()
})
it('regulatory areas list should respect RGAA criteria', () => {
/* it('regulatory areas list should respect RGAA criteria', () => {
cy.visit(`/backoffice/regulatory_areas`)
cy.injectAxe()
cy.intercept('GET', `bff/v1/regulatory-areas/134`).as('getRegulatoryArea')
Expand All @@ -157,7 +157,7 @@ context('Axe core RGAA check that ', () => {
// Wait for the zoom
cy.wait(500)
checkA11y()
})
}) */

it('tag list should respect RGAA criteria', () => {
cy.visit(`/backoffice/tags`)
Expand Down
17,697 changes: 10,499 additions & 7,198 deletions frontend/package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
"dependencies": {
"@mtes-mct/monitor-ui": "24.52.2",
"@react-pdf/renderer": "4.5.1",
"@reduxjs/toolkit": "2.11.2",
"@reduxjs/toolkit": "2.12.0",
"@sentry/browser": "10.51.0",
"@sentry/react": "10.51.0",
"@sentry/tracing": "7.120.4",
"@sentry/vite-plugin": "5.2.1",
"@svgr/webpack": "8.1.0",
"@tanstack/react-table": "8.21.3",
"@tanstack/react-virtual": "3.13.24",
"@uiw/react-md-editor": "4.1.1",
"classnames": "2.5.1",
"compressorjs": "1.3.0",
"dayjs": "1.11.20",
Expand Down Expand Up @@ -71,26 +72,26 @@
"use-debounce": "10.1.1",
"uuid": "9.0.1",
"worker-loader": "3.0.8",
"xmlbuilder2": "^3.1.1",
"xmlbuilder2": "3.1.1",
"yup": "1.7.1"
},
"devDependencies": {
"@faker-js/faker": "9.9.0",
"@import-meta-env/cli": "^0.7.4",
"@import-meta-env/cli": "0.7.4",
"@import-meta-env/prepare": "0.2.3",
"@import-meta-env/unplugin": "^0.6.3",
"@jest/globals": "29.7.0",
"@import-meta-env/unplugin": "0.6.3",
"@jest/globals": "30.4.1",
"@swc/core": "1.15.32",
"@swc/jest": "0.2.39",
"@tsconfig/vite-react": "3.4.0",
"@types/google.maps": "3.64.0",
"@types/jest": "30.0.0",
"@types/node": "20.9.0",
"@types/node": "25.9.2",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@typescript-eslint/eslint-plugin": "7.1.0",
"@typescript-eslint/parser": "7.1.0",
"@vitejs/plugin-react": "4.7.0",
"@vitejs/plugin-react": "6.0.2",
"babel-eslint": "10.1.0",
"codecov": "3.8.3",
"cypress": "15.14.2",
Expand Down Expand Up @@ -127,9 +128,8 @@
"ramda": "0.32.0",
"type-fest": "4.41.0",
"typescript": "5.9.3",
"vite": "6.3.5",
"vite-plugin-svgr": "4.5.0",
"vite-tsconfig-paths": "5.1.4"
"vite": "8.0.16",
"vite-plugin-svgr": "5.2.0"
},
"browserslist": {
"production": [
Expand Down
43 changes: 16 additions & 27 deletions frontend/src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
import {
createApi,
fetchBaseQuery,
type BaseQueryFn,
type FetchArgs,
type FetchBaseQueryError
} from '@reduxjs/toolkit/query/react'
import { normalizeRtkBaseQuery } from '@utils/normalizeRtkBaseQuery'

import type { BackendApiErrorResponse } from './types'
Expand All @@ -11,20 +17,15 @@ const monitorenvPrivateApiQuery = fetchBaseQuery({
baseUrl: '/bff',
credentials: 'include'
})
export const monitorenvPrivateApi = createApi({
baseQuery: async (args, api, extraOptions) => {
const result = await normalizeRtkBaseQuery(monitorenvPrivateApiQuery)(args, api, extraOptions)
if (result.error) {
return {
error: {
data: result.error.data as BackendApiErrorResponse,
status: result.error.status
}
}
}

return result
},
type BackendBaseQueryError = Omit<FetchBaseQueryError, 'data'> & { data: BackendApiErrorResponse }
type BackendBaseQueryFn = BaseQueryFn<string | FetchArgs, unknown, BackendBaseQueryError>

const makeBaseQuery = (baseQuery: BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>): BackendBaseQueryFn =>
normalizeRtkBaseQuery(baseQuery) as BackendBaseQueryFn

export const monitorenvPrivateApi = createApi({
baseQuery: makeBaseQuery(monitorenvPrivateApiQuery),
endpoints: () => ({}),
reducerPath: 'monitorenvPrivateApi',
tagTypes: [
Expand All @@ -49,19 +50,7 @@ const monitorenvPublicApiQuery = fetchBaseQuery({
baseUrl: '/api'
})
export const monitorenvPublicApi = createApi({
baseQuery: async (args, api, extraOptions) => {
const result = await normalizeRtkBaseQuery(monitorenvPublicApiQuery)(args, api, extraOptions)
if (result.error) {
return {
error: {
data: result.error.data as BackendApiErrorResponse,
status: result.error.status
}
}
}

return result
},
baseQuery: makeBaseQuery(monitorenvPublicApiQuery),
endpoints: () => ({}),
reducerPath: 'monitorenvPublicApi',
tagTypes: ['Administrations', 'ControlUnits', 'Stations']
Expand Down
119 changes: 119 additions & 0 deletions frontend/src/components/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { Accent, Icon, IconButton } from '@mtes-mct/monitor-ui'
import MDEditor, { bold, EditorContext, italic, unorderedListCommand } from '@uiw/react-md-editor'
import { useContext } from 'react'
import styled from 'styled-components'

function PreviewButtons() {
const { dispatch, preview } = useContext(EditorContext)

const click = () => {
if (!dispatch) {
return
}

dispatch({
preview: preview === 'edit' ? 'preview' : 'edit'
})
}

return (
<>
<IconButton
accent={Accent.TERTIARY}
className={preview === 'edit' ? '_active' : ''}
Icon={Icon.EditUnbordered}
onClick={click}
title="Éditer"
/>
<IconButton
accent={Accent.TERTIARY}
className={preview === 'preview' ? '_active' : ''}
Icon={Icon.Display}
onClick={click}
title="Aperçu"
/>
</>
)
}

const codePreview = {
icon: <PreviewButtons />,
keyCommand: 'preview',
name: 'preview',
value: 'preview'
}

export function MarkdownEditor({ onChange, value, ...props }: { onChange: (value?: string) => void; value: string }) {

Check warning on line 46 in frontend/src/components/MarkdownEditor.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Mark the props of the component as read-only.

See more on https://sonarcloud.io/project/issues?id=MTES-MCT_monitorenv&issues=AZ6nrqKDuvU_i5410QSg&open=AZ6nrqKDuvU_i5410QSg&pullRequest=2967
return (
<StyledMDEditor
commands={[bold, italic, unorderedListCommand]}
extraCommands={[codePreview]}
height="150px"
highlightEnable={false}
onChange={onChange}
preview="edit"
toolbarBottom
value={value}
{...props}
visibleDragbar={false}
/>
)
}

const StyledMDEditor = styled(MDEditor)`
margin-top: 8px;
border-radius: 0px;
background-color: ${p => p.theme.color.gainsboro};
box-shadow: none;
padding-bottom: 0px;

.w-md-editor-toolbar {
background-color: ${p => p.theme.color.white};
}

.w-md-editor-text-input {
color: ${p => p.theme.color.gunMetal};
font-family: inherit !important;
font-size: 13px;
}
.w-md-editor-content {
border-radius: 0px;
.w-md-editor-preview {
.wmde-markdown {
background-color: ${p => p.theme.color.gainsboro};
color: ${p => p.theme.color.gunMetal};
font-size: 13px;
ul {
list-style: disc;
}
}
}
}
.w-md-editor-toolbar {
border-radius: 0px;
border: 1px solid ${p => p.theme.color.gainsboro};
li > button {
background-color: inherit;
color: ${p => p.theme.color.slateGray};

&.Element-IconButton {
color: ${p => p.theme.color.lightGray};
&._active {
color: ${p => p.theme.color.blueGray};
}

&:hover,
&._hover {
color: ${p => p.theme.color.blueYonder};
}
}

&:not(.Element-IconButton) {
svg {
width: 14px;
height: 14px;
}
}
}
}
`
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/Administrative.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import _ from 'lodash'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
key: 'administrative',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/Amp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import _ from 'lodash'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
key: 'amp',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/Map.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import { BaseLayer } from 'domain/entities/layers/BaseLayer'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import { type RegulatoryOrAMPOrViglanceAreaLayerType } from '../entities/layers/constants'
import { CoordinatesFormat, DistanceUnit } from '../entities/map/constants'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/Measurement.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import type { MeasurementType } from '../entities/map/constants'
import type { Measurement } from '@features/map/layers/measurement'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/MissionFilters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { customDayjs } from '@mtes-mct/monitor-ui'
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { missionFiltersMigrations } from '@store/migrations/missionsFilters'
import { storage } from '@store/storage'
import { isEqual } from 'lodash'
import { createMigrate, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import { DateRangeEnum, DAY_OPTION } from '../entities/dateRange'

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/Regulatory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import _ from 'lodash'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
key: 'regulatory',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/domain/shared_slices/SemaphoresSlice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSlice } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import type { Semaphore } from '../entities/semaphore'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type PayloadAction, createSlice } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import { set } from 'lodash/fp'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import type { FiltersState } from './types'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { controlUnitsFiltersMigrations } from '@store/migrations/controlUnitsFilters'
import { storage } from '@store/storage'
import { isEqual } from 'lodash'
import { createMigrate, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import type { FiltersState } from './types'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type PayloadAction, createSlice } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import { set } from 'lodash/fp'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import type { FiltersState } from './types'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { VigilanceArea } from '@features/VigilanceArea/types'
import { type ControlUnit, type DateAsStringRange } from '@mtes-mct/monitor-ui'
import { createSelector, createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { dashboardsFiltersMigrations } from '@store/migrations/dashboardsFilters'
import { storage } from '@store/storage'
import { DateRangeEnum } from 'domain/entities/dateRange'
import { ReportingTypeEnum, StatusFilterEnum } from 'domain/entities/reporting'
import { isEqual, set } from 'lodash'
import { createMigrate, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

import type { RecentActivityFiltersEnum } from '@features/RecentActivity/slice'
import type { TagOption } from 'domain/entities/tags'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/InterestPoint/slice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import { v4 as uuidv4 } from 'uuid'

import type { NewInterestPoint, InterestPoint } from './types'
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/LocalizedArea/slice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice, type PayloadAction } from '@reduxjs/toolkit'
import { storage } from '@store/storage'
import { concat, uniq, without } from 'lodash'
import { persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
key: 'localizedArea',
Expand Down
Loading
Loading