Skip to content

Commit 8135aa4

Browse files
feat: add slimmed-down fragment for recently accessed sandboxes (#8840)
1 parent 3eaa712 commit 8135aa4

File tree

5 files changed

+82
-33
lines changed

5 files changed

+82
-33
lines changed

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

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4807,6 +4807,37 @@ export type _SearchTeamSandboxesQuery = {
48074807
} | null;
48084808
};
48094809

4810+
export type RecentlyAccessedSandboxFragment = {
4811+
__typename?: 'Sandbox';
4812+
id: string;
4813+
alias: string | null;
4814+
title: string | null;
4815+
lastAccessedAt: any;
4816+
privacy: number;
4817+
restricted: boolean;
4818+
draft: boolean;
4819+
isV2: boolean;
4820+
screenshotUrl: string | null;
4821+
source: { __typename?: 'Source'; template: string | null };
4822+
customTemplate: {
4823+
__typename?: 'Template';
4824+
id: any | null;
4825+
iconUrl: string | null;
4826+
} | null;
4827+
forkedTemplate: {
4828+
__typename?: 'Template';
4829+
id: any | null;
4830+
color: string | null;
4831+
iconUrl: string | null;
4832+
} | null;
4833+
collection: {
4834+
__typename?: 'Collection';
4835+
path: string;
4836+
id: any | null;
4837+
} | null;
4838+
author: { __typename?: 'User'; username: string } | null;
4839+
};
4840+
48104841
export type RecentlyAccessedSandboxesLegacyQueryVariables = Exact<{
48114842
limit: Scalars['Int'];
48124843
teamId: InputMaybe<Scalars['UUID4']>;
@@ -4822,21 +4853,12 @@ export type RecentlyAccessedSandboxesLegacyQuery = {
48224853
id: string;
48234854
alias: string | null;
48244855
title: string | null;
4825-
description: string | null;
48264856
lastAccessedAt: any;
4827-
insertedAt: string;
4828-
updatedAt: string;
4829-
removedAt: string | null;
48304857
privacy: number;
4831-
isFrozen: boolean;
4832-
screenshotUrl: string | null;
4833-
viewCount: number;
4834-
likeCount: number;
4835-
isV2: boolean;
4836-
draft: boolean;
48374858
restricted: boolean;
4838-
authorId: any | null;
4839-
teamId: any | null;
4859+
draft: boolean;
4860+
isV2: boolean;
4861+
screenshotUrl: string | null;
48404862
source: { __typename?: 'Source'; template: string | null };
48414863
customTemplate: {
48424864
__typename?: 'Template';
@@ -4855,11 +4877,6 @@ export type RecentlyAccessedSandboxesLegacyQuery = {
48554877
id: any | null;
48564878
} | null;
48574879
author: { __typename?: 'User'; username: string } | null;
4858-
permissions: {
4859-
__typename?: 'SandboxProtectionSettings';
4860-
preventSandboxLeaving: boolean;
4861-
preventSandboxExport: boolean;
4862-
} | null;
48634880
}>;
48644881
} | null;
48654882
};

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

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import {
4747
import { gql, Query } from 'overmind-graphql';
4848

4949
import {
50-
sandboxFragmentDashboard,
5150
sidebarCollectionDashboard,
5251
templateFragmentDashboard,
5352
repoFragmentDashboard,
@@ -355,11 +354,44 @@ export const searchTeamSandboxes: Query<
355354
${SEARCH_TEAM_SANDBOX_FRAGMENT}
356355
`;
357356

358-
/**
359-
* @deprecated This query is being replaced by Apollo queries in the Recent page.
360-
* Will be removed once migration is complete.
361-
* See: packages/app/src/app/pages/Dashboard/Content/routes/Recent/queries.ts
362-
*/
357+
const RECENTLY_ACCESSED_SANDBOX_FRAGMENT = gql`
358+
fragment recentlyAccessedSandbox on Sandbox {
359+
id
360+
alias
361+
title
362+
lastAccessedAt
363+
privacy
364+
restricted
365+
draft
366+
isV2
367+
screenshotUrl
368+
369+
source {
370+
template
371+
}
372+
373+
customTemplate {
374+
id
375+
iconUrl
376+
}
377+
378+
forkedTemplate {
379+
id
380+
color
381+
iconUrl
382+
}
383+
384+
collection {
385+
path
386+
id
387+
}
388+
389+
author {
390+
username
391+
}
392+
}
393+
`;
394+
363395
export const recentlyAccessedSandboxes: Query<
364396
RecentlyAccessedSandboxesLegacyQuery,
365397
RecentlyAccessedSandboxesLegacyQueryVariables
@@ -369,18 +401,13 @@ export const recentlyAccessedSandboxes: Query<
369401
id
370402
371403
recentlyAccessedSandboxes(limit: $limit, teamId: $teamId) {
372-
...sandboxFragmentDashboard
404+
...recentlyAccessedSandbox
373405
}
374406
}
375407
}
376-
${sandboxFragmentDashboard}
408+
${RECENTLY_ACCESSED_SANDBOX_FRAGMENT}
377409
`;
378410

379-
/**
380-
* @deprecated This query is being replaced by Apollo queries in the Recent page.
381-
* Will be removed once migration is complete.
382-
* See: packages/app/src/app/pages/Dashboard/Content/routes/Recent/queries.ts
383-
*/
384411
export const recentlyAccessedBranches: Query<
385412
RecentlyAccessedBranchesLegacyQuery,
386413
RecentlyAccessedBranchesLegacyQueryVariables

packages/app/src/app/overmind/namespaces/dashboard/state.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
RecentlyDeletedTeamSandboxesFragment,
1212
SearchTeamSandboxFragment,
1313
CollaboratorSandboxFragment,
14+
RecentlyAccessedSandboxFragment,
1415
} from 'app/graphql/types';
1516
import isSameWeek from 'date-fns/isSameWeek';
1617
import { sortBy } from 'lodash-es';
@@ -23,7 +24,7 @@ export type DashboardSandboxStructure = {
2324
DRAFTS: DraftSandboxFragment[] | null;
2425
TEMPLATES: Template[] | null;
2526
DELETED: RecentlyDeletedTeamSandboxesFragment[] | null;
26-
RECENT_SANDBOXES: (Sandbox | DraftSandboxFragment)[] | null;
27+
RECENT_SANDBOXES: (RecentlyAccessedSandboxFragment | DraftSandboxFragment)[] | null;
2728
RECENT_BRANCHES: Branch[] | null;
2829
SEARCH: (Sandbox | DraftSandboxFragment | SearchTeamSandboxFragment)[] | null;
2930
TEMPLATE_HOME: Template[] | null;

packages/app/src/app/overmind/namespaces/dashboard/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import {
55
DraftSandboxFragment,
66
SearchTeamSandboxFragment,
77
CollaboratorSandboxFragment,
8+
RecentlyAccessedSandboxFragment,
89
} from 'app/graphql/types';
910

1011
export type DashboardSandboxFragment =
1112
| SandboxFragmentDashboardFragment
1213
| SandboxByPathFragment
1314
| DraftSandboxFragment
1415
| SearchTeamSandboxFragment
15-
| CollaboratorSandboxFragment;
16+
| CollaboratorSandboxFragment
17+
| RecentlyAccessedSandboxFragment;
1618

1719
export type PageTypes =
1820
| 'search'

packages/app/src/app/pages/Dashboard/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ProjectFragment as Repository,
77
RecentlyDeletedTeamSandboxesFragment,
88
DraftSandboxFragment,
9+
RecentlyAccessedSandboxFragment,
910
} from 'app/graphql/types';
1011
import { Context } from 'app/overmind';
1112
import {
@@ -29,7 +30,8 @@ export type DashboardSandbox = {
2930
originalGit?: RepoFragmentDashboardFragment['originalGit'];
3031
})
3132
| RecentlyDeletedTeamSandboxesFragment
32-
| DraftSandboxFragment;
33+
| DraftSandboxFragment
34+
| RecentlyAccessedSandboxFragment;
3335
noDrag?: boolean;
3436
};
3537

0 commit comments

Comments
 (0)