Skip to content

Commit

Permalink
Merge tag '2024-06-03-01' into feature/import-2024-06-10
Browse files Browse the repository at this point in the history
# Conflicts:
#	bun.lockb
#	package.json
  • Loading branch information
maatinito committed Oct 15, 2024
2 parents 492e9f7 + 9de97c8 commit 8e66cc9
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 132 deletions.
7 changes: 7 additions & 0 deletions app/controllers/manager/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def update
end
end

def unblock_mails
user = User.find(params[:id])
user.update!(email_verified_at: Time.current)
flash[:notice] = "Les emails ont été débloqués."
redirect_to manager_user_path(user)
end

def resend_confirmation_instructions
user = User.find(params[:id])
user.resend_confirmation_instructions
Expand Down
17 changes: 9 additions & 8 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module ApplicationHelper
APP_HOST = ENV['APP_HOST']
APP_HOST_LEGACY = ENV['APP_HOST_LEGACY']
REGEXP_REPLACE_TRAILING_EXTENSION = /(\.\w+)+$/.freeze
REGEXP_REPLACE_WORD_SEPARATOR = /[\s_-]+/.freeze

def app_host_legacy?(request)
return false if APP_HOST_LEGACY.blank?
Expand Down Expand Up @@ -126,14 +128,6 @@ def show_outdated_browser_banner?
!BrowserSupport.supported?(browser)
end

def vite_legacy?
if ENV['VITE_LEGACY'] == 'disabled'
false
else
Rails.env.production? || ENV['VITE_LEGACY'] == 'enabled'
end
end

def external_link_attributes
{ target: "_blank", rel: "noopener noreferrer" }
end
Expand All @@ -153,4 +147,11 @@ def dsfr_icon(classes, *options)
tag.span(class: class_names(classes, 'fr-icon--sm': sm, 'fr-mr-1v': mr),
"aria-hidden" => true)
end

def acronymize(str)
str.gsub(REGEXP_REPLACE_TRAILING_EXTENSION, '')
.split(REGEXP_REPLACE_WORD_SEPARATOR)
.map { |word| word[0].upcase }
.join
end
end
35 changes: 0 additions & 35 deletions app/helpers/vite_helper.rb

This file was deleted.

7 changes: 0 additions & 7 deletions app/javascript/entrypoints/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,5 @@ Turbo.session.drive = false;
// Expose globals
window.DS = window.DS || DS;

// enable legacy mode of DSFR when vite is not detectde as modern browser
window.addEventListener('load', function () {
if (!window.__vite_is_modern_browser) {
window.dsfr.internals.legacy.setLegacy();
}
});

import('../shared/track/matomo');
import('../shared/track/sentry');
7 changes: 3 additions & 4 deletions app/javascript/shared/track/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ if (enabled && key) {
]
});

Sentry.configureScope((scope) => {
scope.setUser(user);
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');
});
const scope = Sentry.getCurrentScope();
scope.setUser(user);
scope.setExtra('browser', browser.modern ? 'modern' : 'legacy');

// Register a way to explicitely capture messages from a different bundle.
addEventListener('sentry:capture-exception', (event) => {
Expand Down
4 changes: 1 addition & 3 deletions app/views/layouts/_outdated_browser_banner.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
- if show_outdated_browser_banner?
= render Dsfr::AlertComponent.new(state: :warning, title: "Navigateur trop ancien", heading_level: :h2) do |c|
- c.with_body do
Votre navigateur internet, #{browser.name} #{browser.version}, est malheureusement trop ancien. Il ne sera plus compatible avec #{APPLICATION_NAME} à partir du 
%strong
1 juin 2024.
Votre navigateur internet, #{browser.name} #{browser.version}, est malheureusement trop ancien. Il n’est plus compatible avec #{APPLICATION_NAME}.
%br
Veuillez installer un navigateur plus récent en suivant le lien suivant :
%br
Expand Down
7 changes: 0 additions & 7 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
- if administrateur_signed_in?
= vite_javascript_tag 'track-admin'

- if vite_legacy?
= vite_legacy_polyfill_tag
= vite_legacy_javascript_tag 'application'
- if administrateur_signed_in?
= vite_legacy_javascript_tag 'track-admin'
= vite_legacy_fallback_tag

= preload_link_tag(asset_url("Marianne-Regular.woff2"))
= preload_link_tag(asset_url("Spectral-Regular.ttf"))

Expand Down
8 changes: 8 additions & 0 deletions app/views/manager/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ as well as a link to its edit page.
</h1>

<div class="buttons">
<% if user.unverified_email? %>
<%= link_to(
"Débloquer mails",
[:unblock_mails, namespace, page.resource],
method: :post,
class: "button") %>
<% end %>

<%= link_to(
"Modifier",
edit_manager_user_path(page.resource),
Expand Down
Binary file modified bun.lockb
Binary file not shown.
4 changes: 0 additions & 4 deletions config/env.example.optional
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ DOLIST_API_BALANCING_VALUE="50"
# Used only by a migration to choose your default regarding procedure archive dossiers after duree_conservation_dossiers_dans_ds
# DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true

# Enable vite legacy build (IE11). Legacy build is used in production (except if set to "disabled").
# You might want to enable it in other environements for testing. Build time will be greatly impacted.
VITE_LEGACY=""

# around july 2022, we changed the duree_conservation_dossiers_dans_ds, allow instances to choose their own duration
NEW_MAX_DUREE_CONSERVATION=12

Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
delete 'delete', on: :member
post 'resend_confirmation_instructions', on: :member
post 'resend_reset_password_instructions', on: :member
post 'unblock_mails', on: :member
put 'enable_feature', on: :member
get 'emails', on: :member
put 'unblock_email'
Expand Down
41 changes: 17 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"@coldwired/actions": "^0.11.2",
"@coldwired/turbo-stream": "^0.11.1",
"@coldwired/utils": "^0.11.4",
"@frsource/autoresize-textarea": "^2.0.53",
"@frsource/autoresize-textarea": "^2.0.75",
"@gouvfr/dsfr": "^1.11.2",
"@graphiql/plugin-explorer": "^1.0.3",
"@graphiql/plugin-explorer": "^3.0.2",
"@graphiql/toolkit": "^0.9.1",
"@headlessui/react": "^1.6.6",
"@heroicons/react": "^1.0.6",
Expand All @@ -19,8 +19,7 @@
"@rails/ujs": "^7.1.3-2",
"@reach/combobox": "^0.17.0",
"@reach/slider": "^0.17.0",
"@sentry/browser": "7.107.0",
"@stimulus/polyfills": "^2.0.0",
"@sentry/browser": "8.7.0",
"@tiptap/core": "^2.2.4",
"@tiptap/extension-bold": "^2.2.4",
"@tiptap/extension-bullet-list": "^2.2.4",
Expand All @@ -44,37 +43,32 @@
"@tiptap/suggestion": "^2.2.4",
"@tmcw/togeojson": "^5.6.0",
"chartkick": "^5.0.1",
"core-js": "^3.31.0",
"core-js": "^3.37.1",
"date-fns": "^2.30.0",
"debounce": "^1.2.1",
"dom4": "^2.1.6",
"email-butler": "^1.0.13",
"geojson": "^0.5.0",
"graphiql": "^3.1.1",
"graphiql": "^3.2.3",
"graphql": "^16.8.1",
"highcharts": "^10.3.3",
"intersection-observer": "^0.12.2",
"is-hotkey": "^0.2.0",
"lightgallery": "^2.7.2",
"maplibre-gl": "^1.15.2",
"match-sorter": "^6.3.4",
"ol": "^8.1.0",
"patch-package": "^7.0.0",
"patch-package": "^8.0.0",
"react": "^18.2.0",
"react-coordinate-input": "^1.0.0",
"react-dom": "^18.2.0",
"react-popper": "^2.3.0",
"react-query": "^3.39.3",
"spectaql": "^2.3.1",
"stimulus-use": "^0.52.2",
"terser": "^5.29.2",
"terser": "^5.31.0",
"tiny-invariant": "^1.3.3",
"tippy.js": "^6.3.7",
"trix": "^1.2.3",
"turbo-polyfills": "^0.5.0",
"use-debounce": "^9.0.4",
"whatwg-fetch": "^3.6.20",
"yet-another-abortcontroller-polyfill": "^0.0.4",
"zod": "^3.20.2"
},
"devDependencies": {
Expand All @@ -93,26 +87,25 @@
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@types/sortablejs": "^1.15.8",
"@typescript-eslint/eslint-plugin": "^6.13.1",
"@typescript-eslint/parser": "^6.13.1",
"@vitejs/plugin-legacy": "^5.2.0",
"@vitejs/plugin-react": "^4.2.0",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"@vitejs/plugin-react": "^4.3.0",
"autoprefixer": "^10.4.19",
"axe-core": "^4.8.4",
"del-cli": "^5.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"jsdom": "^22.1.0",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"typescript": "^5.4.3",
"vite": "^5.0.12",
"prettier": "^3.3.0",
"typescript": "^5.4.5",
"vite": "^5.2.12",
"vite-plugin-full-reload": "^1.1.0",
"vite-plugin-ruby": "^5.0.0",
"vitest": "^0.34.6"
"vitest": "^1.6.0"
},
"scripts": {
"clean": "del tmp public/graphql && bin/vite clobber",
Expand Down
25 changes: 25 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,29 @@
it { is_expected.to eq("") }
end
end
describe '#acronymize' do
it 'returns the acronym of a given string' do
expect(helper.acronymize('Application Name')).to eq('AN')
expect(helper.acronymize('Hello World')).to eq('HW')
expect(helper.acronymize('Demarches Simplifiees')).to eq('DS')
end

it 'handles single word input' do
expect(helper.acronymize('Word')).to eq('W')
end

it 'returns an empty string for empty input' do
expect(helper.acronymize('')).to eq('')
end

it 'handles strings with extensions' do
expect(helper.acronymize('file_name.txt')).to eq('FN')
expect(helper.acronymize('example.pdf')).to eq('E')
end

it 'handles strings with various word separators' do
expect(helper.acronymize('multi-word_string')).to eq('MWS')
expect(helper.acronymize('another_example-test')).to eq('AET')
end
end
end
2 changes: 1 addition & 1 deletion spec/system/outdated_browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

scenario 'a banner is displayed' do
visit new_user_session_path
expect(page).to have_content('1 juin 2024')
expect(page).to have_content('Il n’est plus compatible avec')
expect(page).to have_content('Votre navigateur internet, Internet Explorer 10, est malheureusement trop ancien')
end
end
Expand Down
40 changes: 1 addition & 39 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { defineConfig } from 'vite';
import ViteReact from '@vitejs/plugin-react';
import ViteLegacy from '@vitejs/plugin-legacy';
import FullReload from 'vite-plugin-full-reload';
import RubyPlugin from 'vite-plugin-ruby';
import FullReload from 'vite-plugin-full-reload';

const plugins = [
RubyPlugin(),
Expand All @@ -13,45 +12,8 @@ const plugins = [
)
];

if (shouldBuildLegacy()) {
plugins.push(
ViteLegacy({
targets: [
'defaults',
'Chrome >= 50',
'Edge >= 14',
'Firefox >= 50',
'Opera >= 40',
'Safari >= 8',
'iOS >= 8',
'IE >= 11'
],
additionalLegacyPolyfills: [
'dom4',
'core-js/stable',
'@stimulus/polyfills',
'turbo-polyfills',
'intersection-observer',
'regenerator-runtime/runtime',
'whatwg-fetch',
'yet-another-abortcontroller-polyfill'
]
})
);
}

export default defineConfig({
resolve: { alias: { '@utils': '/shared/utils.ts' } },
build: { sourcemap: true, assetsInlineLimit: 0 },
plugins
});

function shouldBuildLegacy() {
if (process.env.VITE_LEGACY == 'disabled') {
return false;
}
return (
process.env.RAILS_ENV == 'production' ||
process.env.VITE_LEGACY == 'enabled'
);
}

0 comments on commit 8e66cc9

Please sign in to comment.