Skip to content
Snippets Groups Projects
Commit 3a5e6979 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

Merge branch 'develop' into redmine-issues/19728

parents f5413c52 a80700b9
No related branches found
No related tags found
1 merge request!816REDMINE_ISSUE-19728 | Ajouter un nouveau type de notification : Notification de publication d’un document clé
...@@ -81,4 +81,4 @@ sonarqube-check: ...@@ -81,4 +81,4 @@ sonarqube-check:
- develop - develop
stage: Static analysis stage: Static analysis
script: script:
- sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.projectKey=id-$CI_PROJECT_ID -Dsonar.projectName="$CI_PROJECT_PATH" -Dsonar.projectVersion=$CI_COMMIT_BRANCH - sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.projectKey=id-$CI_PROJECT_ID -Dsonar.projectName="$CI_PROJECT_PATH" -Dsonar.projectVersion=$CI_COMMIT_BRANCH -Dsonar.coverage.exclusions=**/src/**/*
...@@ -121,15 +121,26 @@ const routes = [ ...@@ -121,15 +121,26 @@ const routes = [
path: `/${projectBase}/:slug/type-signalement/:slug_type_signal/signalement/:slug_signal`, path: `/${projectBase}/:slug/type-signalement/:slug_type_signal/signalement/:slug_signal`,
name: 'details-signalement', name: 'details-signalement',
component: () => import('../views/Feature/FeatureDetail.vue'), component: () => import('../views/Feature/FeatureDetail.vue'),
/**
* Handles routing logic before entering the details-signalement route.
* This function manages access and navigation based on user permissions and feature data.
*/
beforeEnter: async (to, from, next) => { beforeEnter: async (to, from, next) => {
try { try {
const { slug, slug_type_signal, slug_signal } = to.params; const { slug, slug_type_signal, slug_signal } = to.params;
// Retrieve the project details from the store
const project = await store.dispatch('projects/GET_PROJECT', slug); const project = await store.dispatch('projects/GET_PROJECT', slug);
// Prepare query based on the project settings for feature browsing
const query = { ordering: project.feature_browsing_default_sort }; const query = { ordering: project.feature_browsing_default_sort };
if (project.feature_browsing_default_filter) { // when feature_type is the default filter of the project, // Check if the default filter of the project is set to feature_type and apply it
if (project.feature_browsing_default_filter) { // when feature_type is the default filter of the project,
query['feature_type_slug'] = slug_type_signal; // set feature_type slug in query query['feature_type_slug'] = slug_type_signal; // set feature_type slug in query
} }
// Get the feature's position based on the feature slug and query settings
const offset = await featureAPI.getFeaturePosition(slug, slug_signal, query); const offset = await featureAPI.getFeaturePosition(slug, slug_signal, query);
// Decide next routing based on the offset result
if (offset >= 0) { if (offset >= 0) {
next({ next({
name: 'details-signalement-filtre', name: 'details-signalement-filtre',
...@@ -137,16 +148,27 @@ const routes = [ ...@@ -137,16 +148,27 @@ const routes = [
query: { ...query, offset } query: { ...query, offset }
}); });
} else if (offset === 'No Content') { } else if (offset === 'No Content') {
store.commit('CLEAR_MESSAGES'); // Remove other messages to avoid displaying twice that the user is not connected // API return no content when user is not allowed to see the feature or isn't connected
store.commit('DISPLAY_MESSAGE', { comment: `Vous n'avez pas accès à ce signalement ${store.state.user ? 'avec cet utilisateur' : 'hors connexion, veuillez-vous connecter au préalable'}`, level: 'negative' }); if (store.state.user) {
console.log('store', store); // If the user is connected, display information that he's not allowed to view the feature
console.log('store.state.configuration.VUE_APP_LOGIN_URL', store.state.configuration.VUE_APP_LOGIN_URL); store.commit('DISPLAY_MESSAGE', { comment: 'Vous n\'avez pas accès à ce signalement avec cet utilisateur', level: 'negative' });
if (store.state.configuration.VUE_APP_LOGIN_URL) { // and redirect to main page
setTimeout(() => { // delay to allow the message to be read by user next({ path: '/' });
window.open(store.state.configuration.VUE_APP_LOGIN_URL);
}, 1500);
} else { } else {
next({ name: 'login' }); // If the user is not connected, remove other messages to avoid displaying twice that the user is not connected
store.commit('CLEAR_MESSAGES');
// display information that user need to be connected
store.commit('DISPLAY_MESSAGE', { comment: 'Vous n\'avez pas accès à ce signalement hors connexion, veuillez-vous connecter au préalable', level: 'negative' });
// Then redirect to login page
if (store.state.configuration.VUE_APP_LOGIN_URL) {
// If the login is through SSO, redirect to external login page (if the instance accepts a redirect_url it would be caught before when requesting user_info with GET_USER_INFO)
setTimeout(() => { // delay switching page to allow the info message to be read by user
window.open(store.state.configuration.VUE_APP_LOGIN_URL);
}, 1500);
} else {
// In a classic installation, redirect to the login page of this application
next({ name: 'login' });
}
} }
} else { } else {
store.commit('DISPLAY_MESSAGE', { comment: 'Désolé, une erreur est survenue pendant la recherche du signalement', level: 'negative' }); store.commit('DISPLAY_MESSAGE', { comment: 'Désolé, une erreur est survenue pendant la recherche du signalement', level: 'negative' });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment