oceanhelm 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,13 +52,17 @@ const S = (s, t) => {
52
52
  return this.customClasses;
53
53
  },
54
54
  filteredMenuItems() {
55
- return this.menuItems.filter((s) => this.hasPermission(s));
55
+ return this.menuItems.filter((s) => this.hasPermission(s) ? s.type === "dropdown" && s.children ? s.children.some((t) => this.hasPermission(t)) : !0 : !1);
56
56
  }
57
57
  },
58
58
  mounted() {
59
59
  this.responsive && this.initializeResponsiveBehavior();
60
60
  },
61
61
  methods: {
62
+ // Get filtered children for dropdown items
63
+ getFilteredChildren(s) {
64
+ return s.children ? s.children.filter((t) => this.hasPermission(t)) : [];
65
+ },
62
66
  // Permission checking
63
67
  hasPermission(s) {
64
68
  return this.permissionChecker ? this.permissionChecker(s, this.userProfile) : !s.roles || s.roles.length === 0 ? !0 : s.roles.includes(this.userProfile.role);
@@ -149,7 +153,7 @@ function Y(s, t, u, b, n, a) {
149
153
  _(" " + r(i.label), 1)
150
154
  ]),
151
155
  e("div", J, [
152
- (o(!0), l(p, null, h(i.children, (y, A) => (o(), l("a", {
156
+ (o(!0), l(p, null, h(a.getFilteredChildren(i), (y, A) => (o(), l("a", {
153
157
  key: A,
154
158
  class: "dropdown-item black",
155
159
  onClick: D((q) => a.handleAction(y), ["prevent"]),
@@ -236,7 +240,7 @@ const X = {
236
240
  id: s.registrationNumber,
237
241
  name: s.name
238
242
  };
239
- this.currentRoute === "dashboard" ? this.$emit("vessel-click", s) : this.$emit("vessel-navigate", t);
243
+ this.grantAccess(s) ? this.currentRoute === "dashboard" ? this.$emit("vessel-click", s) : this.$emit("vessel-navigate", t) : this.handleAccessDenied("this protected route");
240
244
  },
241
245
  handleDeleteVessel(s) {
242
246
  if (!this.grantAccess(s)) {
@@ -1682,14 +1686,15 @@ const ti = {
1682
1686
  methods: {
1683
1687
  // Permission checking
1684
1688
  hasPermission(s) {
1685
- var b;
1686
- const { role: t } = this.userProfile;
1687
- return ((b = {
1689
+ const { role: t, vessel: u } = this.userProfile, b = u === this.vesselName;
1690
+ let a = {
1688
1691
  owner: ["add", "edit", "delete", "assign", "view"],
1689
1692
  staff: ["add", "edit", "assign", "view"],
1690
1693
  captain: ["assign", "view"],
1694
+ // default for captain
1691
1695
  viewer: ["view"]
1692
- }[t]) == null ? void 0 : b.includes(s)) || !1;
1696
+ }[t] || [];
1697
+ return t === "captain" && b && (a = [...a, "add"]), a.includes(s);
1693
1698
  },
1694
1699
  // Event handlers
1695
1700
  handleToggleAddForm() {