-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Show placeholder icons if not signed in or not owned sandbox #2164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/app/src/app/overmind/namespaces/workspace/internalActions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,9 +14,12 @@ import FilesIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/file.svg | |||||||||||
| import RocketIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/rocket.svg'; | ||||||||||||
| // @ts-ignore | ||||||||||||
| import ConfigurationIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/cog.svg'; | ||||||||||||
| import getWorkspaceItems from 'app/store/modules/workspace/items'; | ||||||||||||
| import getWorkspaceItems, { | ||||||||||||
| getDisabledItems, | ||||||||||||
| INavigationItem, | ||||||||||||
| } from 'app/store/modules/workspace/items'; | ||||||||||||
| import { useSignals, useStore } from 'app/store'; | ||||||||||||
| import { Container, IconContainer } from './elements'; | ||||||||||||
| import { Container, IconContainer, Separator } from './elements'; | ||||||||||||
| import ServerIcon from './ServerIcon'; | ||||||||||||
|
|
||||||||||||
| const IDS_TO_ICONS = { | ||||||||||||
|
|
@@ -31,6 +34,42 @@ const IDS_TO_ICONS = { | |||||||||||
| server: ServerIcon, | ||||||||||||
| }; | ||||||||||||
|
|
||||||||||||
| interface IconProps { | ||||||||||||
| item: INavigationItem; | ||||||||||||
| isDisabled?: boolean; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const IconComponent = observer(({ item, isDisabled }: IconProps) => { | ||||||||||||
| const { id, name } = item; | ||||||||||||
| const store = useStore(); | ||||||||||||
| const { | ||||||||||||
| workspace: { setWorkspaceHidden, setWorkspaceItem }, | ||||||||||||
| } = useSignals(); | ||||||||||||
|
|
||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! Much cleaner! |
||||||||||||
| const Icon = IDS_TO_ICONS[id]; | ||||||||||||
| const selected = | ||||||||||||
| !store.workspace.workspaceHidden && | ||||||||||||
| id === store.workspace.openedWorkspaceItem; | ||||||||||||
| return ( | ||||||||||||
| <Tooltip key={id} placement="right" content={name}> | ||||||||||||
| <IconContainer | ||||||||||||
| isDisabled={isDisabled} | ||||||||||||
| selected={selected} | ||||||||||||
| onClick={() => { | ||||||||||||
| if (selected) { | ||||||||||||
| setWorkspaceHidden({ hidden: true }); | ||||||||||||
| } else { | ||||||||||||
| setWorkspaceHidden({ hidden: false }); | ||||||||||||
| setWorkspaceItem({ item: id }); | ||||||||||||
| } | ||||||||||||
| }} | ||||||||||||
| > | ||||||||||||
| <Icon /> | ||||||||||||
| </IconContainer> | ||||||||||||
| </Tooltip> | ||||||||||||
| ); | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| export const Navigation = observer( | ||||||||||||
| ({ | ||||||||||||
| topOffset, | ||||||||||||
|
|
@@ -39,39 +78,22 @@ export const Navigation = observer( | |||||||||||
| topOffset: number; | ||||||||||||
| bottomOffset: number; | ||||||||||||
| }) => { | ||||||||||||
| const { | ||||||||||||
| workspace: { setWorkspaceHidden, setWorkspaceItem }, | ||||||||||||
| } = useSignals(); | ||||||||||||
| const store = useStore(); | ||||||||||||
|
|
||||||||||||
| const shownItems = getWorkspaceItems(store); | ||||||||||||
| const disabledItems = getDisabledItems(store); | ||||||||||||
|
|
||||||||||||
| return ( | ||||||||||||
| <Container topOffset={topOffset} bottomOffset={bottomOffset}> | ||||||||||||
| {getWorkspaceItems(store) | ||||||||||||
| .filter(w => !w.show || w.show(store)) | ||||||||||||
| .map(item => { | ||||||||||||
| const { id, name } = item; | ||||||||||||
| const Icon = IDS_TO_ICONS[id]; | ||||||||||||
| const selected = | ||||||||||||
| !store.workspace.workspaceHidden && | ||||||||||||
| id === store.workspace.openedWorkspaceItem; | ||||||||||||
| return ( | ||||||||||||
| <Tooltip key={id} placement="right" content={name}> | ||||||||||||
| <IconContainer | ||||||||||||
| selected={selected} | ||||||||||||
| onClick={() => { | ||||||||||||
| if (selected) { | ||||||||||||
| setWorkspaceHidden({ hidden: true }); | ||||||||||||
| } else { | ||||||||||||
| setWorkspaceHidden({ hidden: false }); | ||||||||||||
| setWorkspaceItem({ item: id }); | ||||||||||||
| } | ||||||||||||
| }} | ||||||||||||
| > | ||||||||||||
| <Icon /> | ||||||||||||
| </IconContainer> | ||||||||||||
| </Tooltip> | ||||||||||||
| ); | ||||||||||||
| })} | ||||||||||||
| {shownItems.map(item => ( | ||||||||||||
| <IconComponent key={item.id} item={item} /> | ||||||||||||
| ))} | ||||||||||||
|
|
||||||||||||
| <Separator /> | ||||||||||||
|
|
||||||||||||
| {disabledItems.map(item => ( | ||||||||||||
| <IconComponent key={item.id} item={item} isDisabled /> | ||||||||||||
| ))} | ||||||||||||
| </Container> | ||||||||||||
| ); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/index.js
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import React, { useEffect } from 'react'; | ||
| import { observer } from 'mobx-react-lite'; | ||
|
|
||
| import { useStore, useSignals } from 'app/store'; | ||
| import { Description } from '../../elements'; | ||
| import ZeitDeployments from './Zeit'; | ||
| import NetlifyDeployments from './Netlify'; | ||
| import { More } from '../More'; | ||
|
|
||
| const Deployment = observer(() => { | ||
| const store = useStore(); | ||
| const signals = useSignals(); | ||
|
|
||
| const showPlaceholder = | ||
| !store.editor.currentSandbox.owned || !store.isLoggedIn; | ||
|
|
||
| useEffect(() => { | ||
| if (!showPlaceholder) { | ||
| signals.deployment.getDeploys(); | ||
| } | ||
| }, [showPlaceholder, signals]); | ||
|
|
||
| if (showPlaceholder) { | ||
| const message = store.isLoggedIn ? ( | ||
| <> | ||
| You need to own this sandbox to deploy this sandbox to Netlify or ZEIT.{' '} | ||
| <p>Fork this sandbox to make a deploy!</p> | ||
| </> | ||
| ) : ( | ||
| <>You need to be signed in to deploy this sandbox to Netlify or ZEIT.</> | ||
| ); | ||
|
|
||
| return <More message={message} id="github" />; | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <Description> | ||
| You can deploy a production version of your sandbox using one our | ||
| supported providers. | ||
| </Description> | ||
| <ZeitDeployments /> | ||
| <NetlifyDeployments /> | ||
| </div> | ||
| ); | ||
| }); | ||
|
|
||
| export default Deployment; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.