commit
25a26afeef
11 changed files with 66 additions and 47 deletions
|
@ -1,7 +1,12 @@
|
|||
import { ajax, fire, timeoutable } from '@utils';
|
||||
|
||||
// Manages a queue of Autosave operations,
|
||||
// and sends `autosave:*` events to indicate the state of the requests.
|
||||
// and sends `autosave:*` events to indicate the state of the requests:
|
||||
//
|
||||
// - autosave:enqueue () when an autosave request has been enqueued
|
||||
// - autosave:end ({ response, statusText, xhr }) when an autosave request finished successfully
|
||||
// - autosave:failure (Error) when an autosave request failed
|
||||
//
|
||||
export default class AutoSaveController {
|
||||
constructor() {
|
||||
this.timeoutDelay = 60000; // 1mn
|
||||
|
|
|
@ -29,7 +29,7 @@ const FORM_SELECTOR = 'form#dossier-edit-form.autosave-enabled';
|
|||
const INPUTS_SELECTOR = `${FORM_SELECTOR} input:not([type=file]), ${FORM_SELECTOR} select, ${FORM_SELECTOR} textarea`;
|
||||
const RETRY_BUTTON_SELECTOR = '.autosave-retry';
|
||||
|
||||
// When an autosave is requested programatically, auto-save the form immediately
|
||||
// When an autosave is requested programmatically, auto-save the form immediately
|
||||
addEventListener('autosave:trigger', (event) => {
|
||||
const form = event.target.closest('form');
|
||||
if (form && form.classList.contains('autosave-enabled')) {
|
||||
|
@ -73,7 +73,11 @@ addEventListener('autosave:error', (event) => {
|
|||
|
||||
enable(document.querySelector('button.autosave-retry'));
|
||||
setState('failed');
|
||||
logError(event.detail);
|
||||
|
||||
const shouldLogError = !error.xhr || error.xhr.status != 0; // ignore timeout errors
|
||||
if (shouldLogError) {
|
||||
logError(error);
|
||||
}
|
||||
});
|
||||
|
||||
function setState(state) {
|
||||
|
|
|
@ -11,6 +11,7 @@ import '../shared/safari-11-file-xhr-workaround';
|
|||
import '../shared/remote-input';
|
||||
import '../shared/franceconnect';
|
||||
import '../shared/toggle-target';
|
||||
import '../shared/ujs-error-handling';
|
||||
|
||||
import '../new_design/chartkick';
|
||||
import '../new_design/dropdown';
|
||||
|
|
|
@ -10,7 +10,8 @@ if (enabled && key) {
|
|||
ignoreErrors: [
|
||||
// Ignore errors generated by a Microsoft crawler.
|
||||
// See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062
|
||||
'Non-error promise rejection captured with keys'
|
||||
'Non-error promise rejection captured with keys',
|
||||
'Non-Error promise rejection captured with value'
|
||||
]
|
||||
});
|
||||
|
||||
|
|
8
app/javascript/shared/ujs-error-handling.js
Normal file
8
app/javascript/shared/ujs-error-handling.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
// For links and requests done through rails-ujs (mostly data-remote links),
|
||||
// redirect to the sign-in page when the server responds '401 Unauthorized'.
|
||||
document.body.addEventListener('ajax:error', (event) => {
|
||||
const [, , xhr] = event.detail;
|
||||
if (xhr && xhr.status == 401) {
|
||||
location.reload(); // reload whole page so Devise will redirect to sign-in
|
||||
}
|
||||
});
|
|
@ -382,7 +382,7 @@ class Dossier < ApplicationRecord
|
|||
validates :groupe_instructeur, presence: true, if: -> { !brouillon? }
|
||||
|
||||
def user_deleted?
|
||||
user_id.nil?
|
||||
persisted? && user_id.nil?
|
||||
end
|
||||
|
||||
def user_email_for(use)
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
%p= t(:hello, scope: [:views, :shared, :greetings])
|
||||
|
||||
- if !@dossier.brouillon?
|
||||
%p= t('.body', libelle_demarche: @dossier.procedure.libelle)
|
||||
%p= t('.body_html', libelle_demarche: @dossier.procedure.libelle)
|
||||
%p= t('.link')
|
||||
= round_button(t('.access_message'), messagerie_dossier_url(@dossier), :primary)
|
||||
- else
|
||||
%p= t('.body_draft', libelle_demarche: @dossier.procedure.libelle)
|
||||
%p= t('.body_draft_html', libelle_demarche: @dossier.procedure.libelle)
|
||||
%p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 14px;" }
|
||||
= @body
|
||||
%p= t('.contact')
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
%p= t(:hello, scope: [:views, :shared, :greetings])
|
||||
|
||||
%p= t('.body', libelle_demarche: @dossier.procedure.libelle)
|
||||
%p= t('.link')
|
||||
%p= t('.body_html', libelle_demarche: @dossier.procedure.libelle)
|
||||
%p= t('.link_html')
|
||||
= round_button(t('.access_file'), dossier_url(@dossier), :primary)
|
||||
|
||||
- if @dossier.procedure.auto_archive_on
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
%p= t(:hello, scope: [:views, :shared, :greetings])
|
||||
|
||||
%p
|
||||
= t('.body', dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle)
|
||||
= t('.body_html', dossier_id: @dossier.id, libelle_demarche: @dossier.procedure.libelle)
|
||||
= link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener'
|
||||
- if @dossier.procedure.service.present?
|
||||
%p
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
"@reach/combobox": "^0.13.0",
|
||||
"@reach/slider": "^0.15.0",
|
||||
"@reach/visually-hidden": "^0.15.2",
|
||||
"@sentry/browser": "6.11.0",
|
||||
"@sentry/browser": "6.12.0",
|
||||
"@tmcw/togeojson": "^4.3.0",
|
||||
"babel-plugin-macros": "^2.8.0",
|
||||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
||||
|
|
72
yarn.lock
72
yarn.lock
|
@ -1779,56 +1779,56 @@
|
|||
prop-types "^15.7.2"
|
||||
tslib "^2.3.0"
|
||||
|
||||
"@sentry/browser@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.11.0.tgz#9e90bbc0488ebcdd1e67937d8d5b4f13c3f6dee0"
|
||||
integrity sha512-Qr2QRA0t5/S9QQqxzYKvM9W8prvmiWuldfwRX4hubovXzcXLgUi4WK0/H612wSbYZ4dNAEcQbtlxFWJNN4wxdg==
|
||||
"@sentry/browser@6.12.0":
|
||||
version "6.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.12.0.tgz#970cd68fa117a1e1336fdb373e3b1fa76cd63e2d"
|
||||
integrity sha512-wsJi1NLOmfwtPNYxEC50dpDcVY7sdYckzwfqz1/zHrede1mtxpqSw+7iP4bHADOJXuF+ObYYTHND0v38GSXznQ==
|
||||
dependencies:
|
||||
"@sentry/core" "6.11.0"
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/utils" "6.11.0"
|
||||
"@sentry/core" "6.12.0"
|
||||
"@sentry/types" "6.12.0"
|
||||
"@sentry/utils" "6.12.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/core@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.11.0.tgz#40e94043afcf6407a109be26655c77832c64e740"
|
||||
integrity sha512-09TB+f3pqEq8LFahFWHO6I/4DxHo+NcS52OkbWMDqEi6oNZRD7PhPn3i14LfjsYVv3u3AESU8oxSEGbFrr2UjQ==
|
||||
"@sentry/core@6.12.0":
|
||||
version "6.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.12.0.tgz#bc7c5f0785b6a392d9ad47bd9b1fae3f5389996c"
|
||||
integrity sha512-mU/zdjlzFHzdXDZCPZm8OeCw7c9xsbL49Mq0TrY0KJjLt4CJBkiq5SDTGfRsenBLgTedYhe5Z/J8Z+xVVq+MfQ==
|
||||
dependencies:
|
||||
"@sentry/hub" "6.11.0"
|
||||
"@sentry/minimal" "6.11.0"
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/utils" "6.11.0"
|
||||
"@sentry/hub" "6.12.0"
|
||||
"@sentry/minimal" "6.12.0"
|
||||
"@sentry/types" "6.12.0"
|
||||
"@sentry/utils" "6.12.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/hub@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.11.0.tgz#ddf9ddb0577d1c8290dc02c0242d274fe84d6c16"
|
||||
integrity sha512-pT9hf+ZJfVFpoZopoC+yJmFNclr4NPqPcl2cgguqCHb69DklD1NxgBNWK8D6X05qjnNFDF991U6t1mxP9HrGuw==
|
||||
"@sentry/hub@6.12.0":
|
||||
version "6.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.12.0.tgz#29e323ab6a95e178fb14fffb684aa0e09707197f"
|
||||
integrity sha512-yR/UQVU+ukr42bSYpeqvb989SowIXlKBanU0cqLFDmv5LPCnaQB8PGeXwJAwWhQgx44PARhmB82S6Xor8gYNxg==
|
||||
dependencies:
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/utils" "6.11.0"
|
||||
"@sentry/types" "6.12.0"
|
||||
"@sentry/utils" "6.12.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/minimal@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.11.0.tgz#806d5512658370e40827b3e3663061db708fff33"
|
||||
integrity sha512-XkZ7qrdlGp4IM/gjGxf1Q575yIbl5RvPbg+WFeekpo16Ufvzx37Mr8c2xsZaWosISVyE6eyFpooORjUlzy8EDw==
|
||||
"@sentry/minimal@6.12.0":
|
||||
version "6.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.12.0.tgz#cbe20e95056cedb9709d7d5b2119ef95206a9f8c"
|
||||
integrity sha512-r3C54Q1KN+xIqUvcgX9DlcoWE7ezWvFk2pSu1Ojx9De81hVqR9u5T3sdSAP2Xma+um0zr6coOtDJG4WtYlOtsw==
|
||||
dependencies:
|
||||
"@sentry/hub" "6.11.0"
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/hub" "6.12.0"
|
||||
"@sentry/types" "6.12.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/types@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.11.0.tgz#5122685478d32ddacd3a891cbcf550012df85f7c"
|
||||
integrity sha512-gm5H9eZhL6bsIy/h3T+/Fzzz2vINhHhqd92CjHle3w7uXdTdFV98i2pDpErBGNTSNzbntqOMifYEB5ENtZAvcg==
|
||||
"@sentry/types@6.12.0":
|
||||
version "6.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.12.0.tgz#b7395688a79403c6df8d8bb8d81deb8222519853"
|
||||
integrity sha512-urtgLzE4EDMAYQHYdkgC0Ei9QvLajodK1ntg71bGn0Pm84QUpaqpPDfHRU+i6jLeteyC7kWwa5O5W1m/jrjGXA==
|
||||
|
||||
"@sentry/utils@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.11.0.tgz#d1dee4faf4d9c42c54bba88d5a66fb96b902a14c"
|
||||
integrity sha512-IOvyFHcnbRQxa++jO+ZUzRvFHEJ1cZjrBIQaNVc0IYF0twUOB5PTP6joTcix38ldaLeapaPZ9LGfudbvYvxkdg==
|
||||
"@sentry/utils@6.12.0":
|
||||
version "6.12.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.12.0.tgz#3de261e8d11bdfdc7add64a3065d43517802e975"
|
||||
integrity sha512-oRHQ7TH5TSsJqoP9Gqq25Jvn9LKexXfAh/OoKwjMhYCGKGhqpDNUIZVgl9DWsGw5A5N5xnQyLOxDfyRV5RshdA==
|
||||
dependencies:
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/types" "6.12.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sindresorhus/is@^0.14.0":
|
||||
|
|
Loading…
Reference in a new issue