Skip to content

Commit 9233074

Browse files
authored
feat: more context menu options for branch/repo (#6999)
1 parent a26843d commit 9233074

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

packages/app/src/app/pages/Dashboard/Components/Header/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ export const Header = ({
141141
alignItems: 'center',
142142
textDecoration: 'none',
143143
fontSize: 2,
144-
padding: 2,
145144
color: 'mutedForeground',
146145
width: 'auto',
147146
transition: `color ease-in`,

packages/app/src/app/pages/Dashboard/Components/Selection/ContextMenus/BranchMenu.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { BranchFragment as Branch } from 'app/graphql/types';
44
import {
55
githubRepoUrl,
66
v2BranchUrl,
7+
dashboard,
78
} from '@codesandbox/common/lib/utils/url-generator';
9+
import { useHistory } from 'react-router-dom';
810
import { Context, MenuItem } from '../ContextMenu';
911

1012
type BranchMenuProps = {
@@ -15,13 +17,20 @@ export const BranchMenu: React.FC<BranchMenuProps> = ({ branch }) => {
1517

1618
const { name, project, contribution } = branch;
1719
const branchUrl = v2BranchUrl({ name, project });
20+
21+
const { name: repoName, owner } = project.repository;
22+
1823
const githubUrl = githubRepoUrl({
1924
branch: name,
20-
repo: project.repository.name,
21-
username: project.repository.owner,
25+
repo: repoName,
26+
username: owner,
2227
path: '',
2328
});
2429

30+
const repoUrl = dashboard.repository({ owner, name: repoName });
31+
32+
const history = useHistory();
33+
2534
return (
2635
<Menu.ContextMenu
2736
visible={visible}
@@ -44,6 +53,9 @@ export const BranchMenu: React.FC<BranchMenuProps> = ({ branch }) => {
4453
Open on GitHub
4554
</MenuItem>
4655
)}
56+
<MenuItem onSelect={() => history.push(repoUrl)}>
57+
Open repository
58+
</MenuItem>
4759
{/* TODO: Implement remove branch <Menu.Divider />
4860
<Menu.Divider />
4961
<MenuItem

packages/app/src/app/pages/Dashboard/Components/Selection/ContextMenus/MultiItemMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export const MultiMenu = ({ selectedItems, page }: IMultiMenuProps) => {
220220
? [{ label: 'Export Items', fn: exportItems }]
221221
: [];
222222

223-
const DELETE = { label: 'Delete Items', fn: deleteItems };
223+
const DELETE = { label: 'Archive Items', fn: deleteItems };
224224
const RECOVER = {
225225
label: 'Recover Sandboxes',
226226
fn: () => {

packages/app/src/app/pages/Dashboard/Components/Selection/ContextMenus/RepositoryMenu.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import React from 'react';
22
import { Menu } from '@codesandbox/components';
33
import { ProjectFragment as Repository } from 'app/graphql/types';
4-
import { dashboard } from '@codesandbox/common/lib/utils/url-generator';
4+
import {
5+
dashboard,
6+
v2DraftBranchUrl,
7+
} from '@codesandbox/common/lib/utils/url-generator';
58
import { useHistory } from 'react-router-dom';
69
import { Context, MenuItem } from '../ContextMenu';
710

@@ -19,6 +22,11 @@ export const RepositoryMenu: React.FC<RepositoryMenuProps> = ({
1922
owner: providerRepository.owner,
2023
name: providerRepository.name,
2124
});
25+
const branchFromDefaultUrl = v2DraftBranchUrl(
26+
providerRepository.owner,
27+
providerRepository.name
28+
);
29+
2230
const githubUrl = `https://github.com/${providerRepository.owner}/${providerRepository.name}`;
2331

2432
return (
@@ -37,6 +45,10 @@ export const RepositoryMenu: React.FC<RepositoryMenuProps> = ({
3745
<MenuItem onSelect={() => window.open(githubUrl, '_blank')}>
3846
Open on GitHub
3947
</MenuItem>
48+
<Menu.Divider />
49+
<MenuItem onSelect={() => window.open(branchFromDefaultUrl, '_blank')}>
50+
Create branch
51+
</MenuItem>
4052

4153
{/* TODO: Implement remove repository
4254
<Menu.Divider />

0 commit comments

Comments
 (0)