From d8dbae078179fbe1f1273871421cc656338750be Mon Sep 17 00:00:00 2001 From: hetpatel33 Date: Sat, 12 Oct 2019 16:10:31 +0530 Subject: [PATCH 1/2] Refactor Editor/Workspace/items/Deployment/Netlify/SiteInfo : convert to ts and replace Cerebral with Overmind --- .../Deployment/Netlify/SiteInfo/SiteInfo.tsx | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx index 11fd66e6561..c72f0deecdc 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx @@ -1,9 +1,10 @@ import React from 'react'; -import { inject, hooksObserver } from 'app/componentConnectors'; +import { useOvermind } from 'app/overmind'; import getNetlifyConfig from 'app/utils/getNetlifyConfig'; import { resolveDirectory } from '@codesandbox/common/lib/sandbox/modules'; +import { Sandbox, Directory, Module } from '@codesandbox/common/lib/types'; import { WorkspaceInputContainer, @@ -17,7 +18,7 @@ import { SiteInfoWrapper } from './elements'; import { Functions } from './Functions'; import { ViewLogsButton } from './ViewLogsButton'; -const getFunctionDir = sandbox => { +const getFunctionDir = (sandbox: Sandbox): Directory | undefined => { try { return resolveDirectory( getNetlifyConfig(sandbox).functions, @@ -29,43 +30,40 @@ const getFunctionDir = sandbox => { } }; -export const SiteInfo = inject('store')( - hooksObserver( - ({ - store: { - deployment: { building, netlifyLogs, netlifySite }, - editor: { currentSandbox }, - }, - }) => { - const functionDirectory = getFunctionDir(currentSandbox); - const functions = functionDirectory - ? currentSandbox.modules.filter( - ({ directoryShortid }) => - directoryShortid === functionDirectory.shortid - ) - : []; +export const SiteInfo: React.FC = () => { + const { + state: { + deployment: { building, netlifyLogs, netlifySite }, + editor: { currentSandbox }, + }, + } = useOvermind(); - return ( - - Sandbox Site + const functionDirectory: Directory = getFunctionDir(currentSandbox); + const functions: Module[] = functionDirectory + ? currentSandbox.modules.filter( + ({ directoryShortid }) => directoryShortid === functionDirectory.shortid + ) + : []; - - - - {netlifySite.name} + return ( + + Sandbox Site - {!building &&
Building
} + + + + {netlifySite.name} - {functions.length ? : null} + {!building &&
Building
} - + {functions.length ? : null} - {netlifyLogs ? : null} -
-
-
-
- ); - } - ) -); + + + {netlifyLogs ? : null} +
+
+
+
+ ); +}; From 4dda899e19b7923bf7140e20427081972b7f2eb3 Mon Sep 17 00:00:00 2001 From: hetpatel33 Date: Sat, 12 Oct 2019 16:22:51 +0530 Subject: [PATCH 2/2] Refactor Editor/Workspace/items/Deployment/Netlify/SiteInfo : typecheck --- .../items/Deployment/Netlify/SiteInfo/SiteInfo.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx index c72f0deecdc..3c88b90ae28 100644 --- a/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx +++ b/packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/SiteInfo.tsx @@ -33,7 +33,11 @@ const getFunctionDir = (sandbox: Sandbox): Directory | undefined => { export const SiteInfo: React.FC = () => { const { state: { - deployment: { building, netlifyLogs, netlifySite }, + deployment: { + building, + netlifyLogs, + netlifySite: { id, name }, + }, editor: { currentSandbox }, }, } = useOvermind(); @@ -51,8 +55,8 @@ export const SiteInfo: React.FC = () => { - - {netlifySite.name} + + {name} {!building &&
Building
}