Skip to content

Conversation

@CompuIves
Copy link
Member

@CompuIves CompuIves commented Jul 14, 2019

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:

image

When clicking on it they see this:

image

image

image

@lbogdan lbogdan temporarily deployed to pr2164 July 14, 2019 21:13 Inactive
@lbogdan
Copy link
Contributor

lbogdan commented Jul 14, 2019

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.

@CompuIves
Copy link
Member Author

Good catch! Fixed it by refactoring to hooks and making the check use the same condition.

@lbogdan lbogdan temporarily deployed to pr2164 July 14, 2019 21:42 Inactive
@MichaelDeBoey
Copy link
Contributor

Nice one @CompuIves! 👊

Will interfere with #1969 (which is here already some time) tho, so maybe that one should be merged first? 🤔
That one can be rebased too tho, the choice is up to you 🙂

@CompuIves
Copy link
Member Author

Good point! Let's merge the other one first. Did you test all the deployment flows in the PR?

Copy link
Contributor

@MichaelDeBoey MichaelDeBoey left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isCustomTemplate = !!store.editor.currentSandbox.customTemplate;
const isCustomTemplate = Boolean(store.editor.currentSandbox.customTemplate);


interface IconProps {
item: INavigationItem;
store: any;
Copy link
Contributor

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

Suggested change
store: any;

item: INavigationItem;
store: any;
isDisabled?: boolean;
setWorkspaceHidden: (params: { hidden: boolean }) => void;
Copy link
Contributor

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).

Suggested change
setWorkspaceHidden: (params: { hidden: boolean }) => void;

store: any;
isDisabled?: boolean;
setWorkspaceHidden: (params: { hidden: boolean }) => void;
setWorkspaceItem: (params: { item: string }) => void;
Copy link
Contributor

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).

Suggested change
setWorkspaceItem: (params: { item: string }) => void;

}

const IconComponent = observer(
({ item, isDisabled, setWorkspaceHidden, setWorkspaceItem }: IconProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
({ item, isDisabled, setWorkspaceHidden, setWorkspaceItem }: IconProps) => {
({ item, isDisabled }: IconProps) => {

({ item, isDisabled, setWorkspaceHidden, setWorkspaceItem }: IconProps) => {
const { id, name } = item;
const store = useStore();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const {
workspace: { setWorkspaceHidden, setWorkspaceItem },
} = useSignals();

Copy link
Member Author

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[] {
Copy link
Contributor

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? 🤔

Copy link
Member Author

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[] {
Copy link
Contributor

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}
Copy link
Contributor

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).

@CompuIves CompuIves merged commit 74004ee into master Jul 15, 2019
@CompuIves CompuIves deleted the placeholder-icons branch July 15, 2019 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants