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

fix: signout onclick being triggered on render when there are no orgs #337

Merged
merged 6 commits into from
Jul 23, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.21.1-fix-signout-onclick-trigger.1](https://github.com/mParticle/aquarium/compare/v1.21.0...v1.21.1-fix-signout-onclick-trigger.1) (2024-07-22)

### Bug Fixes

- auto triggering of signout onClick when there are no orgs ([d2645fd](https://github.com/mParticle/aquarium/commit/d2645fd164a37557b0f8b475f093b2f0c6b35058))

# [1.21.0](https://github.com/mParticle/aquarium/compare/v1.20.0...v1.21.0) (2024-07-16)

### Features
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mparticle/aquarium",
"version": "1.21.0",
"version": "1.21.1-fix-signout-onclick-trigger.1",
"description": "mParticle Component Library",
"license": "Apache-2.0",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,12 @@ export const MP: Story = {
orgs: mpOrgs,
minimapOptions: {
overviewHref: '/',
onLinkClick: link => alert(link.href),
onUnauthorizedClick: link => alert(`unauthorized ${link?.href} `),
onLinkClick: link => {
alert(link.href)
},
onUnauthorizedClick: link => {
alert(`unauthorized ${link?.href} `)
},
unauthorizedLinks: ['dataPlatform'],
activeLink: 'oversight',
links: [
Expand Down Expand Up @@ -1015,6 +1019,27 @@ export const Cortex: Story = {
onMpHomeClick: () => {
alert('going to overview map')
},
navigationButtonItemOptions: {
label: 'Sign Out of mParticle',
onClick: () => {
alert('onSignout click')
},
},
minimapOptions: {
overviewHref: '/',
onLinkClick: link => {
if (link.linkId !== 'predictions') alert(link.href)
},
links: [
{ linkId: 'oversight', href: '/oversight' },
{ linkId: 'dataPlatform', href: '/data-platform' },
{ linkId: 'customer360', href: '/customer-360' },
{ linkId: 'predictions', href: '/predictions' },
{ linkId: 'analytics', href: '/analytics' },
{ linkId: 'segmentation', href: '/segmentation' },
],
activeLink: 'predictions',
},
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const GlobalNavigation = ({ showSuiteLogo = true, ...props }: IGlobalNavi
avatarOptions={props.avatarOptions}
/>
) : (
!!props.navigationButtonItemOptions?.onClick() && (
!!props.navigationButtonItemOptions?.onClick && (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix. Everything else is extra :)

<NavigationItem
type="link"
icon={<Icon name="signout" />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ReactNode, type MouseEvent, ReactElement } from 'react'
import { type HrefOptions } from 'src/utils/utils'
import { Icons } from 'src/constants/Icons'
import { type Icons } from 'src/constants/Icons'

export interface IBaseGlobalNavigationItem {
type?: 'menu' | 'link'
Expand Down Expand Up @@ -42,7 +42,7 @@ export interface IMiniMapOptions {
overviewHref: string
links: MiniMapLink[]
onLinkClick: (link: MiniMapLink) => void
onUnauthorizedClick: (link?: MiniMapLink) => void
unauthorizedLinks: MiniMapLinks[]
onUnauthorizedClick?: (link?: MiniMapLink) => void
unauthorizedLinks?: MiniMapLinks[]
activeLink: MiniMapLinks
}
17 changes: 11 additions & 6 deletions src/components/navigation/MiniMap/MiniMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { Button, ConfigProvider } from 'src/components'
import Logo from 'src/assets/svg/mp-logo-wordmark.svg?react'
import { minimap } from './minimap-svg'
import { Flex } from 'src/components/layout/Flex/Flex'
import { ISvgLink, SvgLinker } from 'src/components/navigation/MiniMap/SvgLinker'
import { IMiniMapOptions, MiniMapLinks } from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems'
import { type ISvgLink, SvgLinker } from 'src/components/navigation/MiniMap/SvgLinker'
import {
type IMiniMapOptions,
type MiniMapLinks,
} from 'src/components/navigation/GlobalNavigation/GlobalNavigationItems'

type IMiniMapProps = IMiniMapOptions

Expand All @@ -24,7 +27,7 @@ const Minimap = (props: IMiniMapProps) => {
elementId: elementIdMap[link.linkId],
href: link.href,
variant: 'drop-shadow',
isUnauthorized: props.unauthorizedLinks.includes(link.linkId),
isUnauthorized: props.unauthorizedLinks?.includes(link.linkId),
isActive: props.activeLink === link.linkId,
}))

Expand All @@ -44,10 +47,12 @@ const Minimap = (props: IMiniMapProps) => {
</ConfigProvider>
)
function handleLinkClick(svgLink: ISvgLink): void {
const miniMapLink = props.links.find(link => link.href === svgLink.href)!
const miniMapLink = props.links.find(link => link.href === svgLink.href)

if (svgLink.isUnauthorized) props.onUnauthorizedClick(miniMapLink)
else props.onLinkClick(miniMapLink)
if (miniMapLink) {
if (svgLink.isUnauthorized) props.onUnauthorizedClick?.(miniMapLink)
else props.onLinkClick(miniMapLink)
}
}
}

Expand Down
Loading