Skip to content

Commit

Permalink
Merge pull request #1864 from aziontech/add-new-links-to-sidebar-menu
Browse files Browse the repository at this point in the history
[UXE-5544] feat: added marketplace products to sidebar menu with flag
  • Loading branch information
peterpaulo-azion authored Oct 31, 2024
2 parents 37710e5 + 87366c4 commit d88de1e
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 143 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { menus } from './menus'
import { getMenuItens } from './menus'

export const listSidebarMenusService = () => {
export const listSidebarMenusService = (showMarketplaceProductsItens) => {
const menus = getMenuItens(showMarketplaceProductsItens)
return adapt(menus)
}

Expand Down
320 changes: 192 additions & 128 deletions src/services/sidebar-menus-services/menus.js
Original file line number Diff line number Diff line change
@@ -1,141 +1,205 @@
export const menus = [
{
function createHomeItem() {
return {
label: 'Home',
icon: 'ai ai-home',
to: '/',
id: 'home'
},
{
}
}

function createMarketplaceItem() {
return {
label: 'Marketplace',
icon: 'ai ai-marketplace',
to: '/marketplace',
id: 'marketplace'
},
{
}
}

function createDomainsItem() {
return {
label: 'Domains',
icon: 'ai ai-domains',
to: '/domains',
id: 'domains'
},
{
label: 'Build',
items: [
{
label: 'Edge Application',
icon: 'ai ai-edge-application',
to: '/edge-applications',
id: 'edge-application'
},
{
label: 'Variables',
to: '/variables',
icon: 'ai ai-variables',
id: 'variables'
}
]
},
{
label: 'Secure',
items: [
{
label: 'Edge Firewall',
to: '/edge-firewall',
icon: 'ai ai-edge-firewall',
id: 'edge-firewall'
},
{
label: 'Edge DNS',
to: '/edge-dns',
icon: 'ai ai-edge-dns',
id: 'edge-dns'
}
]
},
{
label: 'Deploy',
items: [
{
label: 'Edge Nodes',
icon: 'ai ai-edge-nodes',
to: '/edge-node',
id: 'edge-nodes'
}
]
},
{
label: 'Observe',
items: [
{
label: 'Data Stream',
to: '/data-stream',
icon: 'ai ai-data-stream',
id: 'data-stream'
},
{
label: 'Edge Pulse',
to: '/edge-pulse',
icon: 'ai ai-edge-pulse',
id: 'edge-pulse'
},
{
label: 'Real-Time Metrics',
to: '/real-time-metrics',
icon: 'ai ai-real-time-metrics',
id: 'real-time-metrics'
},
{
label: 'Real-Time Events',
to: '/real-time-events',
icon: 'ai ai-real-time-events',
tag: 'Preview',
id: 'real-time-events'
}
]
},
{
label: 'Tools',
items: [
{
label: 'Real-Time Purge',
to: '/real-time-purge',
icon: 'ai ai-real-time-purge',
id: 'real-time-purge'
}
]
},
{
label: 'Edge Libraries ',
items: [
{
label: 'Edge Functions',
to: '/edge-functions',
icon: 'ai ai-edge-functions',
id: 'edge-functions'
},
{
label: 'Edge Services',
to: '/edge-services',
icon: 'ai ai-edge-services',
id: 'edge-services'
},
{
label: 'Digital Certificates',
to: '/digital-certificates',
icon: 'ai ai-digital-certificates',
id: 'digital-certificates'
},
{
label: 'Network Lists',
to: '/network-lists',
icon: 'ai ai-network-lists',
id: 'network-lists'
},
{
label: 'WAF Rules',
to: '/waf',
icon: 'ai ai-waf-rules',
id: 'waf-rules'
}
]
}
]
}

function createBuildItems() {
return [
{
label: 'Edge Application',
icon: 'ai ai-edge-application',
to: '/edge-applications',
id: 'edge-application'
},
{
label: 'Variables',
to: '/variables',
icon: 'ai ai-variables',
id: 'variables'
}
]
}

function createSecureItems() {
return [
{
label: 'Edge Firewall',
to: '/edge-firewall',
icon: 'ai ai-edge-firewall',
id: 'edge-firewall'
},
{
label: 'Edge DNS',
to: '/edge-dns',
icon: 'ai ai-edge-dns',
id: 'edge-dns'
}
]
}

function createDeployItems() {
return [
{
label: 'Edge Nodes',
icon: 'ai ai-edge-nodes',
to: '/edge-node',
id: 'edge-nodes'
}
]
}

function createObserveItems() {
return [
{
label: 'Data Stream',
to: '/data-stream',
icon: 'ai ai-data-stream',
id: 'data-stream'
},
{
label: 'Edge Pulse',
to: '/edge-pulse',
icon: 'ai ai-edge-pulse',
id: 'edge-pulse'
},
{
label: 'Real-Time Metrics',
to: '/real-time-metrics',
icon: 'ai ai-real-time-metrics',
id: 'real-time-metrics'
},
{
label: 'Real-Time Events',
to: '/real-time-events',
icon: 'ai ai-real-time-events',
tag: 'Preview',
id: 'real-time-events'
}
]
}

function createToolsItems() {
return [
{
label: 'Real-Time Purge',
to: '/real-time-purge',
icon: 'ai ai-real-time-purge',
id: 'real-time-purge'
}
]
}

function createEdgeLibrariesItems() {
return [
{
label: 'Edge Functions',
to: '/edge-functions',
icon: 'ai ai-edge-functions',
id: 'edge-functions'
},
{
label: 'Edge Services',
to: '/edge-services',
icon: 'ai ai-edge-services',
id: 'edge-services'
},
{
label: 'Digital Certificates',
to: '/digital-certificates',
icon: 'ai ai-digital-certificates',
id: 'digital-certificates'
},
{
label: 'Network Lists',
to: '/network-lists',
icon: 'ai ai-network-lists',
id: 'network-lists'
},
{
label: 'WAF Rules',
to: '/waf',
icon: 'ai ai-waf-rules',
id: 'waf-rules'
}
]
}

function createMarketplaceProductsItems() {
return [
{
label: 'Bot Manager',
icon: 'pi pi-wrench',
to: 'https://portal.radwarebotmanager.com/account/login',
id: 'bot-manager',
external: true
},
{
label: 'SIEM',
to: 'https://f0semqqgv4.map.azionedge.net/login',
icon: 'pi pi-chart-bar',
id: 'siem',
external: true
}
]
}

export function getMenuItens(showMarketplaceProductsItens) {
const menus = [
createHomeItem(),
createMarketplaceItem(),
createDomainsItem(),
{
label: 'Build',
items: createBuildItems()
},
{
label: 'Secure',
items: createSecureItems()
},
{
label: 'Deploy',
items: createDeployItems()
},
{
label: 'Observe',
items: createObserveItems()
},
{
label: 'Tools',
items: createToolsItems()
},
{
label: 'Edge Libraries',
items: createEdgeLibrariesItems()
},
{
label: 'Marketplace Products',
visible: showMarketplaceProductsItens,
items: createMarketplaceProductsItems()
}
]

return menus
}
7 changes: 6 additions & 1 deletion src/stores/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const useAccountStore = defineStore({
flags: {
RESTRICT_ACCESS_TO_METRICS_ONLY: 'allow_only_metrics_on_console',
FULL_CONSOLE_ACCESS: 'allow_console',
SSO_MANAGEMENT: 'federated_auth'
SSO_MANAGEMENT: 'federated_auth',
MARKETPLACE_PRODUCTS: 'marketplace_products'
}
}),
getters: {
Expand Down Expand Up @@ -82,6 +83,10 @@ export const useAccountStore = defineStore({
return [state.accountStatuses.BLOCKED, state.accountStatuses.DEFAULTING].includes(
state.account?.status
)
},
hasAccessToMarketplaceProducts(state) {
const { flags, account } = state
return account?.client_flags?.includes(flags.MARKETPLACE_PRODUCTS)
}
},
actions: {
Expand Down
Loading

0 comments on commit d88de1e

Please sign in to comment.