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:
- develop
stage: Static analysis
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 = [
path: `/${projectBase}/:slug/type-signalement/:slug_type_signal/signalement/:slug_signal`,
name: 'details-signalement',
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) => {
try {
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);
// Prepare query based on the project settings for feature browsing
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
}
// Get the feature's position based on the feature slug and query settings
const offset = await featureAPI.getFeaturePosition(slug, slug_signal, query);
// Decide next routing based on the offset result
if (offset >= 0) {
next({
name: 'details-signalement-filtre',
......@@ -137,16 +148,27 @@ const routes = [
query: { ...query, offset }
});
} else if (offset === 'No Content') {
store.commit('CLEAR_MESSAGES'); // Remove other messages to avoid displaying twice that the user is not 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' });
console.log('store', store);
console.log('store.state.configuration.VUE_APP_LOGIN_URL', store.state.configuration.VUE_APP_LOGIN_URL);
if (store.state.configuration.VUE_APP_LOGIN_URL) {
setTimeout(() => { // delay to allow the message to be read by user
window.open(store.state.configuration.VUE_APP_LOGIN_URL);
}, 1500);
// API return no content when user is not allowed to see the feature or isn't connected
if (store.state.user) {
// If the user is connected, display information that he's not allowed to view the feature
store.commit('DISPLAY_MESSAGE', { comment: 'Vous n\'avez pas accès à ce signalement avec cet utilisateur', level: 'negative' });
// and redirect to main page
next({ path: '/' });
} 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 {
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