Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amp 3469 menu bvn #550

Merged
merged 3 commits into from
Dec 2, 2024
Merged
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
8 changes: 7 additions & 1 deletion src/components/navigation/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
>
<b-nav-item
:id="menu.url"
@click="routeTo(menu)"
@click.prevent="routeTo(menu)"
:class="{
'd-none': resolvePermissions(menu.permissionKey)
}"
Expand Down Expand Up @@ -121,6 +121,7 @@ export default {
"Workflow editor session is active. Please click on done button before leaving the page."
);
} else {
console.log("routing to home");
self.$router.push("/");
}
},
Expand All @@ -135,6 +136,7 @@ export default {
self.$router.push(`${menu.url}/${data.id}`);
}
} else {
console.log("routing to menu");
self.$router.push(`${menu.url}`).catch(error => {
if (error.name !== 'NavigationDuplicated') {
throw error;
Expand All @@ -144,15 +146,19 @@ export default {
},
resolvePermissions(keys) {
if(this.acIsAdmin) {
console.log("resolvePermissions: is Admin", keys);
return false;
} else {
if(Array.isArray(keys) && keys.length > 0) {
console.log("resolvePermissions: keys is array", keys);
return keys.map(key => {
return this.acActions.indexOf(key) < 0;
}).reduce((acc, current) => acc && current, true);
} else if(typeof keys === "string") {
console.log("resolvePermissions: keys is string", keys);
return this.acActions.indexOf(keys) < 0;
} else {
console.log("resolvePermissions: permission denied", keys);
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import router from "./router";
import { store } from "./store/amp-store";
// import { VuePlugin } from "vuera";
import VueFilterDateFormat from "@vuejs-community/vue-filter-date-format";
import {createBootstrap} from "bootstrap-vue-next/plugins";
import moment from "moment";
import {createBootstrap} from "bootstrap-vue-next/plugins";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-vue-next/dist/bootstrap-vue-next.css";

Expand Down
10 changes: 5 additions & 5 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,11 @@ router.beforeEach(async (to, from, next) => {
const { authorize } = to.meta;
const currentUser = accountService.currentUserValue;

console.log("from: ", from, "\nto: ", to, "\nnext: ", next);
console.log("currentUser: ", currentUser);
console.log("router: from: ", from, "\nto: ", to, "\nnext: ", next);
console.log("router: currentUser: ", currentUser);

if (env.getDisableAuth() == "true" || !authorize) {
console.log("router: No auth needed.")
console.log("router: No auth needed.")
return next();
} else if (!currentUser) {
console.log("router: Current user not logged in yet.");
Expand All @@ -469,11 +469,11 @@ router.beforeEach(async (to, from, next) => {
// below API call is to validate the auth token before new page is loaded, in case the current login has expired;
// there should be better way to achieve this without making such extra API call
var success = await accountService.validate();
console.log("success = " + success);
if (!success) {
// return next();
store.state.isAuthenticated = false;
store.commit("isAuthenticated");
console.log("router: Auth token invalid!")
console.log("router: Auth token invalid! routing to login page.")
return next({ path: "/account/login", query: { returnUrl: to.path } });
} else {
store.state.isAuthenticated = true;
Expand Down
Loading