Skip to content

Commit c9f0a5f

Browse files
authored
feat(context-menu): different options for repositories (#7025)
* feat(context-menu): different options for repositories * fix: typeerror
1 parent e5ea808 commit c9f0a5f

File tree

5 files changed

+40
-84
lines changed

5 files changed

+40
-84
lines changed

packages/app/src/app/graphql/types.ts

Lines changed: 11 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export type CurrentUser = {
186186
collections: Array<Collection>;
187187
deletionRequested: Scalars['Boolean'];
188188
email: Scalars['String'];
189-
/** Get enabled feature flags for all teams user is in */
189+
/** @deprecated Field no longer supported */
190190
featureFlags: Array<FeatureFlag>;
191191
/** Get all of the current user's GitHub organizations */
192192
githubOrganizations: Maybe<Array<GithubOrganization>>;
@@ -297,6 +297,7 @@ export type FeatureFlag = {
297297
enabled: Scalars['Boolean'];
298298
id: Scalars['UUID4'];
299299
name: Scalars['String'];
300+
/** @deprecated Field no longer supported */
300301
teams: Array<Team>;
301302
};
302303

@@ -596,9 +597,11 @@ export enum ProviderName {
596597

597598
export type PullRequest = {
598599
__typename?: 'PullRequest';
600+
baseRepository: Repository;
599601
creator: Maybe<User>;
600602
creatorUsername: Scalars['String'];
601603
draft: Scalars['Boolean'];
604+
htmlUrl: Scalars['String'];
602605
number: Scalars['Int'];
603606
prClosedAt: Maybe<Scalars['DateTime']>;
604607
prCreatedAt: Maybe<Scalars['DateTime']>;
@@ -671,7 +674,7 @@ export type RootMutationType = {
671674
/** Create a collection */
672675
createCollection: Collection;
673676
createComment: Comment;
674-
/** Create a feature flag */
677+
/** @deprecated Field no longer supported */
675678
createFeatureFlag: FeatureFlag;
676679
/** Create or Update a private registry */
677680
createOrUpdatePrivateNpmRegistry: PrivateRegistry;
@@ -691,13 +694,13 @@ export type RootMutationType = {
691694
/** Delete sandboxes */
692695
deleteSandboxes: Array<Sandbox>;
693696
deleteWorkspace: Scalars['String'];
694-
/** Disable a feature flag globally */
697+
/** @deprecated Field no longer supported */
695698
disableFeatureFlag: FeatureFlag;
696-
/** Disable a feature flag for a team */
699+
/** @deprecated Field no longer supported */
697700
disableFeatureFlagForTeam: TeamsFeatureFlag;
698-
/** Enable a feature flag globally */
701+
/** @deprecated Field no longer supported */
699702
enableFeatureFlag: FeatureFlag;
700-
/** Enable a feature flag for a team */
703+
/** @deprecated Field no longer supported */
701704
enableFeatureFlagForTeam: TeamsFeatureFlag;
702705
/** Enable beta-access for team and all members */
703706
enableTeamBetaAccess: Team;
@@ -1163,7 +1166,7 @@ export type RootQueryType = {
11631166
album: Maybe<Album>;
11641167
albums: Array<Album>;
11651168
curatedAlbums: Array<Album>;
1166-
/** Get all feature flags */
1169+
/** @deprecated Field no longer supported */
11671170
featureFlags: Array<FeatureFlag>;
11681171
/** Get git repo and related V1 sandboxes */
11691172
git: Maybe<Git>;
@@ -1621,46 +1624,6 @@ export type ListPersonalTemplatesQuery = { __typename?: 'RootQueryType' } & {
16211624
>;
16221625
};
16231626

1624-
export type ListTemplatesQueryVariables = Exact<{
1625-
showAll: Maybe<Scalars['Boolean']>;
1626-
}>;
1627-
1628-
export type ListTemplatesQuery = { __typename?: 'RootQueryType' } & {
1629-
me: Maybe<
1630-
{ __typename?: 'CurrentUser' } & {
1631-
templates: Array<{ __typename?: 'Template' } & TemplateFragment>;
1632-
teams: Array<
1633-
{ __typename?: 'Team' } & Pick<Team, 'id' | 'name'> & {
1634-
templates: Array<{ __typename?: 'Template' } & TemplateFragment>;
1635-
}
1636-
>;
1637-
}
1638-
>;
1639-
};
1640-
1641-
export type ListPersonalBookmarkedTemplatesQueryVariables = Exact<{
1642-
[key: string]: never;
1643-
}>;
1644-
1645-
export type ListPersonalBookmarkedTemplatesQuery = {
1646-
__typename?: 'RootQueryType';
1647-
} & {
1648-
me: Maybe<
1649-
{ __typename?: 'CurrentUser' } & {
1650-
teams: Array<
1651-
{ __typename?: 'Team' } & Pick<Team, 'id' | 'name'> & {
1652-
bookmarkedTemplates: Array<
1653-
{ __typename?: 'Template' } & TemplateFragment
1654-
>;
1655-
}
1656-
>;
1657-
bookmarkedTemplates: Array<
1658-
{ __typename?: 'Template' } & TemplateFragment
1659-
>;
1660-
}
1661-
>;
1662-
};
1663-
16641627
export type GetGithubRepoQueryVariables = Exact<{
16651628
owner: Scalars['String'];
16661629
name: Scalars['String'];
@@ -1705,30 +1668,6 @@ export type GetGithubOrganizationsQuery = { __typename?: 'RootQueryType' } & {
17051668
>;
17061669
};
17071670

1708-
export type MakeSandboxesTemplateMutationVariables = Exact<{
1709-
sandboxIds: Array<Scalars['ID']>;
1710-
}>;
1711-
1712-
export type MakeSandboxesTemplateMutation = {
1713-
__typename?: 'RootMutationType';
1714-
} & {
1715-
makeSandboxesTemplates: Array<
1716-
{ __typename?: 'Template' } & Pick<Template, 'id'>
1717-
>;
1718-
};
1719-
1720-
export type UnmakeSandboxesTemplateMutationVariables = Exact<{
1721-
sandboxIds: Array<Scalars['ID']>;
1722-
}>;
1723-
1724-
export type UnmakeSandboxesTemplateMutation = {
1725-
__typename?: 'RootMutationType';
1726-
} & {
1727-
unmakeSandboxesTemplates: Array<
1728-
{ __typename?: 'Template' } & Pick<Template, 'id'>
1729-
>;
1730-
};
1731-
17321671
export type CollaboratorFragment = { __typename?: 'Collaborator' } & Pick<
17331672
Collaborator,
17341673
'id' | 'authorization' | 'lastSeenAt' | 'warning'
@@ -2360,7 +2299,7 @@ export type ProjectFragment = { __typename?: 'Project' } & {
23602299
branches: Array<{ __typename?: 'Branch' } & BranchFragment>;
23612300
repository: { __typename?: 'GitHubRepository' } & Pick<
23622301
GitHubRepository,
2363-
'owner' | 'name'
2302+
'owner' | 'name' | 'defaultBranch'
23642303
>;
23652304
};
23662305

packages/app/src/app/overmind/effects/gql/dashboard/fragments.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export const projectFragment = gql`
242242
... on GitHubRepository {
243243
owner
244244
name
245+
defaultBranch
245246
}
246247
}
247248
}

packages/app/src/app/overmind/effects/gql/dashboard/mutations.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
UnmakeSandboxesTemplateMutation,
3-
UnmakeSandboxesTemplateMutationVariables,
2+
_UnmakeSandboxesTemplateMutation,
3+
_UnmakeSandboxesTemplateMutationVariables,
44
RenameFolderMutation,
55
DeleteFolderMutation,
66
DeleteFolderMutationVariables,
@@ -35,8 +35,8 @@ import {
3535
_CreateTeamMutationVariables,
3636
_RenameSandboxMutation,
3737
_RenameSandboxMutationVariables,
38-
MakeSandboxesTemplateMutation,
39-
MakeSandboxesTemplateMutationVariables,
38+
_MakeSandboxesTemplateMutation,
39+
_MakeSandboxesTemplateMutationVariables,
4040
CreateFolderMutation,
4141
CreateFolderMutationVariables,
4242
SetTeamNameMutation,
@@ -335,8 +335,8 @@ export const setTeamDescription: Query<
335335
`;
336336

337337
export const unmakeSandboxesTemplate: Query<
338-
UnmakeSandboxesTemplateMutation,
339-
UnmakeSandboxesTemplateMutationVariables
338+
_UnmakeSandboxesTemplateMutation,
339+
_UnmakeSandboxesTemplateMutationVariables
340340
> = gql`
341341
mutation _UnmakeSandboxesTemplate($sandboxIds: [ID!]!) {
342342
unmakeSandboxesTemplates(sandboxIds: $sandboxIds) {
@@ -346,8 +346,8 @@ export const unmakeSandboxesTemplate: Query<
346346
`;
347347

348348
export const makeSandboxesTemplate: Query<
349-
MakeSandboxesTemplateMutation,
350-
MakeSandboxesTemplateMutationVariables
349+
_MakeSandboxesTemplateMutation,
350+
_MakeSandboxesTemplateMutationVariables
351351
> = gql`
352352
mutation _MakeSandboxesTemplate($sandboxIds: [ID!]!) {
353353
makeSandboxesTemplates(sandboxIds: $sandboxIds) {

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { Menu } from '@codesandbox/components';
44
import { ProjectFragment as Repository } from 'app/graphql/types';
55
import {
66
dashboard,
7+
v2DefaultBranchUrl,
78
v2DraftBranchUrl,
89
} from '@codesandbox/common/lib/utils/url-generator';
910
import { useActions, useAppState } from 'app/overmind';
11+
import { quotes } from 'app/utils/quotes';
1012
import { Context, MenuItem } from '../ContextMenu';
1113

1214
type RepositoryMenuProps = {
@@ -38,6 +40,10 @@ export const RepositoryMenu: React.FC<RepositoryMenuProps> = ({
3840
providerRepository.owner,
3941
providerRepository.name
4042
);
43+
const defaultBranchUrl = v2DefaultBranchUrl(
44+
providerRepository.owner,
45+
providerRepository.name
46+
);
4147

4248
const repositoryIsStarred = state.dashboard.starredRepos.find(
4349
repo =>
@@ -54,19 +60,28 @@ export const RepositoryMenu: React.FC<RepositoryMenuProps> = ({
5460
position={position}
5561
style={{ width: 120 }}
5662
>
57-
<MenuItem onSelect={() => history.push(repositoryUrl)}>
58-
Open repository
63+
<MenuItem
64+
onSelect={() => {
65+
window.location.href = defaultBranchUrl;
66+
}}
67+
>
68+
Open {quotes(providerRepository.defaultBranch)} branch
5969
</MenuItem>
60-
<MenuItem onSelect={() => window.open(repositoryUrl, '_blank')}>
61-
Open repository in a new tab
70+
<MenuItem onSelect={() => window.open(defaultBranchUrl, '_blank')}>
71+
Open {quotes(providerRepository.defaultBranch)} in a new tab
6272
</MenuItem>
6373
<MenuItem onSelect={() => window.open(githubUrl, '_blank')}>
6474
Open on GitHub
6575
</MenuItem>
76+
6677
<Menu.Divider />
78+
6779
<MenuItem onSelect={() => window.open(branchFromDefaultUrl, '_blank')}>
6880
Create branch
6981
</MenuItem>
82+
<MenuItem onSelect={() => history.push(repositoryUrl)}>
83+
See all branches
84+
</MenuItem>
7085

7186
{experimentalMode && (
7287
<MenuItem

packages/app/src/app/utils/quotes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const quotes = (value: string): string => `“${value}”`;

0 commit comments

Comments
 (0)