Skip to content

Commit 7a4c271

Browse files
christianalfoniCompuIves
authored andcommitted
SandboxGrid: refactor away observer for sandbox grid (codesandbox#3185)
* refactor away observer for sandbox grid * Performance improvements * Convert to TS
1 parent b13c788 commit 7a4c271

File tree

10 files changed

+223
-149
lines changed

10 files changed

+223
-149
lines changed

.graphqlconfig.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ projects:
33
schemaPath: packages/app/src/app/graphql/schema.graphql
44
extensions:
55
endpoints:
6-
default: 'https://codesandbox.io/api/graphql'
6+
prod: 'https://codesandbox.io/api/graphql'
77
staging: 'https://codesandbox.stream/api/graphql'
88
dev: 'http://localhost:4000/api/graphql'

packages/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"build": "cross-env NODE_ENV=production NODE_OPTIONS=\"--max-old-space-size=4096\" node scripts/build.js",
1313
"build:stats": "cross-env NODE_ENV=production NODE_OPTIONS=\"--max-old-space-size=4096\" webpack --env production --config config/webpack.prod.js --json --profile --progress > stats.json && node scripts/stats",
1414
"build:clean": "rimraf www",
15-
"graphql:replace-schema": "sed -i'' 's/RootQueryType/RootQuery/g' ./src/app/graphql/schema.graphql && sed -i'' 's/RootMutationType/RootMutation/g' ./src/app/graphql/schema.graphql",
16-
"generate:graphql": "graphql get-schema --project app && yarn graphql:replace-schema && graphql-codegen --config ./scripts/codegen.js",
15+
"graphql:replace-schema": "sed -i '' 's/RootQueryType/RootQuery/g' ./src/app/graphql/schema.graphql && sed -i '' 's/RootMutationType/RootMutation/g' ./src/app/graphql/schema.graphql",
16+
"generate:graphql": "graphql get-schema -e prod --project app && yarn graphql:replace-schema && graphql-codegen --config ./scripts/codegen.js",
1717
"generate:graphql:staging": "graphql get-schema -e staging --project app && yarn graphql:replace-schema && graphql-codegen --config ./scripts/codegen.js --staging",
1818
"build:embed": "cross-env NODE_ENV=production webpack --config config/webpack.embed.js",
1919
"build:sandbox": "cross-env NODE_ENV=production SANDBOX_ONLY=true node scripts/build.js && yarn copy-assets",

packages/app/src/app/components/CreateNewSandbox/queries.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
UnmakeSandboxesTemplateMutationVariables,
1414
ListTemplatesQueryVariables,
1515
ListTemplatesQuery,
16-
Collection,
1716
PathedSandboxesQuery,
1817
PathedSandboxesFoldersQueryVariables,
1918
} from 'app/graphql/types';
@@ -191,7 +190,7 @@ export function unmakeTemplates(selectedSandboxes: string[], teamId?: string) {
191190
export function makeTemplates(
192191
selectedSandboxes: string[],
193192
teamId?: string,
194-
collections?: Collection[]
193+
collections?: { teamId: string | null }[]
195194
) {
196195
const unpackedSelectedSandboxes: string[] =
197196
// @ts-ignore

packages/app/src/app/graphql/schema.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# source: https://codesandbox.stream/api/graphql
2-
# timestamp: Tue Dec 03 2019 21:41:27 GMT+0100 (Central European Standard Time)
1+
# source: https://codesandbox.io/api/graphql
2+
# timestamp: Wed Dec 11 2019 16:37:29 GMT+0100 (Central European Standard Time)
33

44
schema {
55
query: RootQuery

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ export type SandboxFragment = { __typename?: 'Sandbox' } & Pick<
506506
| 'description'
507507
| 'insertedAt'
508508
| 'updatedAt'
509+
| 'removedAt'
509510
| 'privacy'
510511
| 'screenshotUrl'
511512
| 'screenshotOutdated'
@@ -730,12 +731,7 @@ export type DeletedSandboxesQuery = { __typename?: 'RootQueryType' } & {
730731
me: Maybe<
731732
{ __typename?: 'CurrentUser' } & {
732733
sandboxes: Maybe<
733-
Array<
734-
Maybe<
735-
{ __typename?: 'Sandbox' } & Pick<Sandbox, 'removedAt'> &
736-
SandboxFragment
737-
>
738-
>
734+
Array<Maybe<{ __typename?: 'Sandbox' } & SandboxFragment>>
739735
>;
740736
}
741737
>;

packages/app/src/app/pages/Dashboard/Content/SandboxCard/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import theme from '@codesandbox/common/lib/theme';
1717
import track from '@codesandbox/common/lib/utils/analytics';
1818

1919
import { ESC, ENTER } from '@codesandbox/common/lib/utils/keycodes';
20-
import { Sandbox } from '@codesandbox/common/lib/types';
20+
import { SandboxFragment } from 'app/graphql/types';
2121
import { RENAME_SANDBOX_MUTATION } from '../../queries';
2222

2323
import {
@@ -50,12 +50,12 @@ type Props = {
5050
selectedCount: number;
5151
collectionPath: string; // eslint-disable-line react/no-unused-prop-types
5252
collectionTeamId: string | undefined;
53-
sandbox: Sandbox;
53+
sandbox: SandboxFragment;
5454
page: string | undefined;
5555
privacy: number;
5656
isPatron: boolean;
5757
isScrolling: () => boolean;
58-
removedAt?: number;
58+
removedAt?: string;
5959
style?: React.CSSProperties;
6060
alias: string | undefined;
6161

@@ -293,7 +293,7 @@ class SandboxItemComponent extends React.PureComponent<Props, State> {
293293
{
294294
title: 'Fork Sandbox',
295295
action: () => {
296-
this.props.forkSandbox(this.props.sandbox.id);
296+
this.props.forkSandbox(this.props.id);
297297
return true;
298298
},
299299
},

0 commit comments

Comments
 (0)