Skip to content

Commit bb819ba

Browse files
authored
feat: Add upgrade option for free users in Dashboard Sidebar (#8388)
* feat: Add upgrade option for free users in Dashboard Sidebar * feat: Add CSSProperties import and update style prop, update Text component to include color prop and update source value and add style prop * style: Change color from #E4FC82 to #BDB1F6 in Sidebar component
1 parent a9311c4 commit bb819ba

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/app/src/app/pages/Dashboard/Sidebar/RowItem.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Link as RouterLink, useHistory, useLocation } from 'react-router-dom';
1212
import { ENTER } from '@codesandbox/common/lib/utils/keycodes';
1313
import css from '@styled-system/css';
1414
import { trackImprovedDashboardEvent } from '@codesandbox/common/lib/utils/analytics';
15+
import { CSSProperties } from 'styled-components';
1516
import { DragItemType, useDrop } from '../utils/dnd';
1617
import {
1718
SidebarContext,
@@ -58,6 +59,7 @@ interface RowItemProps {
5859
setFoldersVisibility?: (val: boolean) => void;
5960
folderPath?: string;
6061
nestingLevel?: number;
62+
style?: CSSProperties;
6163
}
6264

6365
export const RowItem: React.FC<RowItemProps> = ({
@@ -68,6 +70,7 @@ export const RowItem: React.FC<RowItemProps> = ({
6870
page,
6971
icon,
7072
setFoldersVisibility = null,
73+
style = {},
7174
...props
7275
}) => {
7376
const accepts: Array<'sandbox' | 'folder' | 'template'> = [];
@@ -139,6 +142,7 @@ export const RowItem: React.FC<RowItemProps> = ({
139142
color: isCurrentLink ? 'sideBar.foreground' : 'sideBarTitle.foreground',
140143
backgroundColor:
141144
canDrop && isOver ? 'list.hoverBackground' : 'transparent',
145+
...style,
142146
})}
143147
>
144148
{props.children || (
@@ -185,7 +189,7 @@ export const RowItem: React.FC<RowItemProps> = ({
185189
>
186190
<Icon name={icon} />
187191
</Stack>
188-
<Text truncate lineHeight="16px">
192+
<Text truncate lineHeight="16px" color="inherit">
189193
{name}
190194
</Text>
191195
</Link>

packages/app/src/app/pages/Dashboard/Sidebar/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Element, List, Text, Stack } from '@codesandbox/components';
88
import css from '@styled-system/css';
99
import { WorkspaceSelect } from 'app/components/WorkspaceSelect';
1010
import { useWorkspaceAuthorization } from 'app/hooks/useWorkspaceAuthorization';
11+
import { useWorkspaceSubscription } from 'app/hooks/useWorkspaceSubscription';
1112
import { ContextMenu } from './ContextMenu';
1213
import { DashboardBaseFolder } from '../types';
1314
import { Position } from '../Components/Selection';
@@ -81,6 +82,7 @@ export const Sidebar: React.FC<SidebarProps> = ({
8182
const showRespositories = !state.environment.isOnPrem;
8283

8384
const { isPrimarySpace } = useWorkspaceAuthorization();
85+
const { isFree } = useWorkspaceSubscription();
8486

8587
const showTemplates = state.activeTeam
8688
? state.sidebar[state.activeTeam]?.hasTemplates
@@ -170,6 +172,18 @@ export const Sidebar: React.FC<SidebarProps> = ({
170172
path={dashboardUrls.portalVMUsage(activeTeam)}
171173
icon="coins"
172174
/>
175+
{isFree && (
176+
<RowItem
177+
name="Upgrade"
178+
page="external"
179+
path={dashboardUrls.upgradeUrl({
180+
workspaceId: activeTeam,
181+
source: 'sidebar',
182+
})}
183+
icon="proBadge"
184+
style={{ color: '#BDB1F6' }}
185+
/>
186+
)}
173187

174188
{showRespositories && (
175189
<>

0 commit comments

Comments
 (0)