-
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
Conversation
|
Nice! If you go to https://pr2164.build.csb.dev/s/new and click on the "Deployment" icon, you get an "An unknown error occurred when connecting to ZEIT" error. |
|
Good catch! Fixed it by refactoring to hooks and making the check use the same condition. |
|
Nice one @CompuIves! 👊 Will interfere with #1969 (which is here already some time) tho, so maybe that one should be merged first? 🤔 |
|
Good point! Let's merge the other one first. Did you test all the deployment flows in the PR? |
MichaelDeBoey
left a comment
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.
Did a small review on the non-Deployment part 🙂
| } | ||
|
|
||
| const items = [PROJECT, FILES]; | ||
| const isCustomTemplate = !!store.editor.currentSandbox.customTemplate; |
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.
| const isCustomTemplate = !!store.editor.currentSandbox.customTemplate; | |
| const isCustomTemplate = Boolean(store.editor.currentSandbox.customTemplate); |
|
|
||
| interface IconProps { | ||
| item: INavigationItem; | ||
| store: any; |
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.
store isn't a prop, since you get it from the useStore hook
| store: any; |
| item: INavigationItem; | ||
| store: any; | ||
| isDisabled?: boolean; | ||
| setWorkspaceHidden: (params: { hidden: boolean }) => void; |
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.
We can just get setWorkspaceHidden from the useSignals hook instead, since we're just passing it from there in the parent component (Navigation).
| setWorkspaceHidden: (params: { hidden: boolean }) => void; |
| store: any; | ||
| isDisabled?: boolean; | ||
| setWorkspaceHidden: (params: { hidden: boolean }) => void; | ||
| setWorkspaceItem: (params: { item: string }) => void; |
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.
We can just get setWorkspaceItem from the useSignals hook instead, since we're just passing it from there in the parent component (Navigation).
| setWorkspaceItem: (params: { item: string }) => void; |
| } | ||
|
|
||
| const IconComponent = observer( | ||
| ({ item, isDisabled, setWorkspaceHidden, setWorkspaceItem }: IconProps) => { |
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.
| ({ item, isDisabled, setWorkspaceHidden, setWorkspaceItem }: IconProps) => { | |
| ({ item, isDisabled }: IconProps) => { |
| ({ item, isDisabled, setWorkspaceHidden, setWorkspaceItem }: IconProps) => { | ||
| const { id, name } = item; | ||
| const store = useStore(); | ||
|
|
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.
| const { | |
| workspace: { setWorkspaceHidden, setWorkspaceItem }, | |
| } = useSignals(); | |
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.
Thank you! Much cleaner!
| }; | ||
|
|
||
| export default function getItems(store) { | ||
| export function getDisabledItems(store: any): INavigationItem[] { |
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.
Maybe create a custom hook instead of passing the store? 🤔
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.
This one is used in multiple places, to make it reusable outside of React I think the store given is a nice solution.
| return []; | ||
| } | ||
|
|
||
| export default function getItems(store: any): INavigationItem[] { |
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.
Maybe create a custom hook instead of passing the store? 🤔
| <IconComponent | ||
| key={item.id} | ||
| item={item} | ||
| store={store} |
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.
store, setWorkspaceHidden & setWorkspaceItem can be deleted here (see above).
People often don't know what you can do with CodeSandbox because they're not signed in or they don't own the sandbox. This change is an experiment that should increase the discoverability of these features by showing a "disabled" version of the button if necessary:
When clicking on it they see this: