@bufferapp/nav-sidebar
Advanced tools
Comparing version 1.74.1 to 1.75.2
@@ -1,10 +0,13 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import styled from 'styled-components'; | ||
import { curiousBlue, shuttleGray } from '@bufferapp/components/style/color'; | ||
import { Link, ClockIcon, Text } from '@bufferapp/components'; | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import styled from "styled-components"; | ||
import { curiousBlue, shuttleGray } from "@bufferapp/components/style/color"; | ||
import { Link, ClockIcon, Text } from "@bufferapp/components"; | ||
import SidebarListItem from "@bufferapp/ui/SidebarListItem"; | ||
import { Gear } from "@bufferapp/ui/Icon"; | ||
import { channelsRedirectUrl, SHARED_CHANNELS } from "@bufferapp/analyze-account" | ||
import { useUser } from '@bufferapp/app-shell'; | ||
import { | ||
channelsRedirectUrl, | ||
SHARED_CHANNELS, | ||
} from "@bufferapp/analyze-account"; | ||
import { useUser } from "@bufferapp/app-shell"; | ||
@@ -20,3 +23,3 @@ const Wrapper = styled.span` | ||
const TextWrapper = styled.span` | ||
margin-left: .5rem; | ||
margin-left: 0.5rem; | ||
margin-right: auto; | ||
@@ -32,14 +35,31 @@ display: inline-flex; | ||
const hasSharedChannels = user => user && user.featureFlips && user.featureFlips.some(flag => flag === SHARED_CHANNELS) | ||
const hasSharedChannels = (user) => | ||
user && | ||
user.featureFlips && | ||
user.featureFlips.some((flag) => flag === SHARED_CHANNELS); | ||
const AccountManagementLink = ({ isGlobalUser, isOwner, organizationId, children, user }) => { | ||
const AccountManagementLink = ({ | ||
isGlobalUser, | ||
isOwner, | ||
organizationId, | ||
children, | ||
}) => { | ||
if (isGlobalUser) { | ||
return <Link unstyled href={`${channelsRedirectUrl(user)}`}>{ children }</Link>; | ||
return ( | ||
<Link unstyled href={`${channelsRedirectUrl()}`}> | ||
{children} | ||
</Link> | ||
); | ||
} | ||
if (isOwner) { | ||
return <Link unstyled href={`https://buffer.com/manage/${organizationId}/analyze`}>{ children }</Link>; | ||
return ( | ||
<Link | ||
unstyled | ||
href={`https://buffer.com/manage/${organizationId}/analyze`} | ||
> | ||
{children} | ||
</Link> | ||
); | ||
} | ||
return (<span> | ||
{ children } | ||
</span>); | ||
return <span>{children}</span>; | ||
}; | ||
@@ -58,41 +78,66 @@ | ||
const AccountManagement = ({ onTrial, daysRemaining, organizationId, isOwner, isGlobalUser }) => { | ||
const AccountManagement = ({ | ||
onTrial, | ||
daysRemaining, | ||
organizationId, | ||
isOwner, | ||
isGlobalUser, | ||
}) => { | ||
const user = useUser(); | ||
return (<div> | ||
{onTrial && <Wrapper> | ||
<IconWrapper><ClockIcon size={{ width: '13px', height: '13px' }} color={curiousBlue} /></IconWrapper> | ||
<TextWrapper> | ||
<AccountManagementLink isOwner={isOwner} isGlobalUser={isGlobalUser} organizationId={organizationId}> | ||
<Text size="small" color="curiousBlue">Trial ends {daysRemaining}</Text> | ||
return ( | ||
<div> | ||
{onTrial && ( | ||
<Wrapper> | ||
<IconWrapper> | ||
<ClockIcon | ||
size={{ width: "13px", height: "13px" }} | ||
color={curiousBlue} | ||
/> | ||
</IconWrapper> | ||
<TextWrapper> | ||
<AccountManagementLink | ||
isOwner={isOwner} | ||
isGlobalUser={isGlobalUser} | ||
organizationId={organizationId} | ||
> | ||
<Text size="small" color="curiousBlue"> | ||
Trial ends {daysRemaining} | ||
</Text> | ||
</AccountManagementLink> | ||
</TextWrapper> | ||
</Wrapper> | ||
)} | ||
{isGlobalUser && !hasSharedChannels(user) && ( | ||
<AccountManagementLink | ||
isGlobalUser={isGlobalUser} | ||
user={user} | ||
organizationId={organizationId} | ||
> | ||
<SidebarListItem | ||
id={"manage-accounts"} | ||
title={"Manage Channels"} | ||
icon={<Gear />} | ||
onItemClick={() => {}} | ||
/> | ||
</AccountManagementLink> | ||
</TextWrapper> | ||
</Wrapper>} | ||
{isGlobalUser && !hasSharedChannels(user) && | ||
<AccountManagementLink isGlobalUser={isGlobalUser} user={user} organizationId={organizationId}> | ||
<SidebarListItem | ||
id={'manage-accounts'} | ||
title={"Manage Channels"} | ||
icon={<Gear />} | ||
onItemClick={() => {}} | ||
/> | ||
</AccountManagementLink> | ||
} | ||
{isOwner && | ||
<AccountManagementLink isOwner={isOwner} organizationId={organizationId}> | ||
<SidebarListItem | ||
id={'settings'} | ||
title={"Settings"} | ||
icon={<Gear />} | ||
onItemClick={() => {}} | ||
/> | ||
</AccountManagementLink> | ||
} | ||
</div>); | ||
} | ||
)} | ||
{isOwner && ( | ||
<AccountManagementLink | ||
isOwner={isOwner} | ||
organizationId={organizationId} | ||
> | ||
<SidebarListItem | ||
id={"settings"} | ||
title={"Settings"} | ||
icon={<Gear />} | ||
onItemClick={() => {}} | ||
/> | ||
</AccountManagementLink> | ||
)} | ||
</div> | ||
); | ||
}; | ||
AccountManagement.propTypes = { | ||
daysRemaining: PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.number | ||
]), | ||
daysRemaining: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
onTrial: PropTypes.bool, | ||
@@ -111,2 +156,1 @@ isOwner: PropTypes.bool, | ||
export default AccountManagement; | ||
{ | ||
"name": "@bufferapp/nav-sidebar", | ||
"version": "1.74.1", | ||
"version": "1.75.2", | ||
"description": "Nav sidebar for Analyze", | ||
@@ -13,5 +13,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"@bufferapp/analyze-profile-selector": "^1.74.0", | ||
"@bufferapp/analyze-profile-selector": "^1.75.2", | ||
"@bufferapp/components": "3.2.1", | ||
"@bufferapp/report-list": "^1.74.1" | ||
"@bufferapp/report-list": "^1.75.2" | ||
}, | ||
@@ -23,3 +23,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "b4c7c64f1287f4b33ecc792471af2d2f4978d595" | ||
"gitHead": "ac8e89fc28e8498c6e90f2c14a68fcceccfebf69" | ||
} |
208699
40
1454