Skip to content

Commit 531ea86

Browse files
authored
Merge pull request #250 from codesandbox/draft/eager-smoke
Add org & storybook docs
2 parents cefecf8 + be1d8db commit 531ea86

File tree

11 files changed

+239
-5
lines changed

11 files changed

+239
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"organizations": "Organizations",
23
"workspace": "Workspaces",
34
"permissions": "User permissions"
45
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Organizations
3+
authors: ['CompuIves']
4+
description:
5+
An organzation is a collection of workspaces under one shared domain.
6+
---
7+
8+
import { Callout } from 'nextra-theme-docs'
9+
10+
# Organizations & domains
11+
12+
![Organization](../images/org-create.png)
13+
14+
Organizations provide a way to group and manage multiple workspaces under a single entity. This is particularly useful for companies, institutions or agencies that need to organize work into distinct teams.
15+
16+
Additionally, organizations make it possible to connect all the employees at a company using CodeSandbox in a single space based on the company's shared email domain.
17+
18+
## Creating an organization
19+
20+
You can create an organization from any active workspace that is not already part of an organzation.
21+
In the _Workspace settings_, open the [Organization tab](https://codesandbox.io/t/org) and enter a name for the organization.
22+
23+
24+
![create org](../images/org-create.png)
25+
26+
To prevent confusion, we recommend that you name your organization so it directly relates to your business’ name.
27+
28+
29+
![name org](../images/org-name.png)
30+
31+
Once you have created an organization, it will automatically be linked to the workspace you created it from. However, you can choose to add additional existing workspaces to that organization.
32+
You can also manage the organization admins.
33+
34+
35+
![edit org](../images/org-edit.png)
36+
37+
The [Organization settings](https://codesandbox.io/t/org) will always be discoverable through the _Workspace settings_.
38+
39+
## Setting an email domain
40+
41+
In the _Organizations settings_, open the `Domain` tab and add your email domain.
42+
The domain must be verified before being approved. This is an automated process that requires no action from you.
43+
44+
45+
![add domain](../images/org-domain-add.png)
46+
47+
Once the domain is approved, users who have CodeSandbox accounts connected to emails with a matching domain will be given the option to join the workspace.
48+
Users may encounter the suggestion to join an eligible workspace when they are attempting to access projects in the workspace or when they log into CodeSandbox for the first time after the email domain has been approved.
49+
50+
Below is an example of the message a user with a matching email domain will see when opening a private Sandbox from a workspace they are not yet part of.
51+
52+
53+
![join ws](../images/org-domain-join-ws.png)
54+
55+
56+
## Accounts and domains
57+
CodeSandbox accounts are tied to individual users. They grant access to shared workspaces and organizations, enabling collaboration with other CodeSandbox users.
58+
59+
With a single CodeSandbox account, users can create or join multiple workspaces and organizations to collaborate with various groups of CodeSandbox users; these workspaces and organizations are separate entities, each with a unique set of members and projects.
60+
61+
Since each workspace and organization are their own separate entities, members cannot see the other workspaces or organizations a user belongs to.
62+
63+
64+
![graph](../images/org-account-graph.png)

packages/projects-docs/pages/learn/access/workspace.mdx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ import { Callout } from 'nextra-theme-docs'
1010

1111
# Workspaces
1212

13-
![Workspaces](../images/workspace-selector.png)
14-
15-
CodeSandbox uses **Workspaces** to provide boundaries for collaboration on CodeSandbox. [Free workspaces](#free-workspace) are available to all users for public development work. [Pro workspaces](#pro-workspace), on the other hand, are reserved for any type of work requiring privacy or collaboration with others.
16-
17-
Every sandbox belongs to a workspace, and every branch of a repository has a separate development environment in each workspace. If you are working on something in one workspace and decide to collaborate with users who are in a different workspace, it may be necessary to transfer (in the case of a sandbox) or re-import (in the case of a repository) into a workspace that your workspace members have access to.
13+
A workspace provides a collaborative space where members can work on various projects. Members of a workspace that is part of an organization will also be members of the organization. Each workspace may have a unique list of members who may have different roles and permissions.
1814

1915
## Getting started with workspaces
2016

Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"github-app": "GitHub App",
3+
"storybook": "Storybook",
34
"tailscale": "Tailscale"
45
}
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
title: Storybook
3+
description: Use the Storybook Addon to seamlessly open a story as a sandbox.
4+
---
5+
6+
import { Callout } from 'nextra-theme-docs'
7+
import Video from '../../../../../shared-components/Video'
8+
9+
# Storybook Addon
10+
11+
The [@codesandbox/storybook-addon](https://github.com/codesandbox/storybook-addon) allows you to open the code from a story in a Sandbox with the click of a button.
12+
13+
This integration allows you to transform design system documentation into interactive example. We have found this incredibly useful for interactive learning and for sharing bug reproductions.
14+
15+
<Video src="https://assets.codesandbox.io/videos/storybook-add-on.mp4" />
16+
17+
## Connecting Storybook to your workspace
18+
19+
All Sandboxes created from the Storybook addon will be created within the workspace that is listed in the [configuration](#configuration).
20+
21+
Anyone opening a Sandbox from the addon will need to be a part of the workspace in order to access the Sandbox.
22+
Luckily organization domains make it very easy for new users to join automatically.
23+
24+
If a workspace has an organzation domain, when a new user opens a Sandbox from a Storybook addon, they will be asked to join the workspace if they have an account with an email that matches the domain of the organization.
25+
26+
You can find a step-by-step guide for setting a domain on the [Organization](/learn/access/organizations#creating-an-organization) documentation.
27+
28+
## Configuration
29+
30+
```js
31+
// .storybook/main.js
32+
33+
module.exports = {
34+
// ...
35+
addons: ['@codesandbox/storybook-addon'],
36+
};
37+
38+
```
39+
40+
<details>
41+
<summary>Storybook configuration (required)</summary>
42+
43+
<br />
44+
45+
To run the addon, you'll need to configure it in your Storybook's `.storybook/preview.js` file.
46+
47+
```js
48+
// .storybook/preview.js
49+
50+
const preview: Preview = {
51+
parameters: {
52+
codesandbox: {
53+
/**
54+
* @required
55+
* Workspace API key from codesandbox.io/t/permissions.
56+
* This sandbox is created inside the given workspace
57+
* and can be shared with team members.
58+
*/
59+
apiToken: <api-token>,
60+
61+
/**
62+
* @required
63+
* Dependencies list to be installed in the sandbox.
64+
*
65+
* @note You cannot use local modules or packages since
66+
* this story runs in an isolated environment (sandbox)
67+
* inside CodeSandbox. As such, the sandbox doesn't have
68+
* access to your file system.
69+
*
70+
* Example:
71+
*/
72+
dependencies: {
73+
"@radix-ui/themes": "latest",
74+
"@myscope/mypackage": "1.0.0",
75+
},
76+
77+
/**
78+
* @required
79+
* CodeSandbox will try to import all components by default from
80+
* the given package, in case `mapComponent` property is not provided.
81+
*
82+
* This property is useful when your components imports are predictable
83+
* and come from a single package and entry point.
84+
*/
85+
fallbackImport: "@radix-ui/themes",
86+
87+
/**
88+
* @optional
89+
* All required providers to run the sandbox properly,
90+
* such as themes, i18n, store, and so on.
91+
*
92+
* @note Remember to use only the dependencies listed above.
93+
*
94+
* Example:
95+
*/
96+
provider: `import { Theme } from "@radix-ui/themes";
97+
import '@radix-ui/themes/styles.css';
98+
99+
export default ThemeProvider = ({ children }) => {
100+
return (
101+
<Theme>
102+
{children}
103+
</Theme>
104+
)
105+
}`,
106+
},
107+
},
108+
};
109+
110+
export default preview;
111+
```
112+
113+
</details>
114+
115+
<details>
116+
<summary>Story configuration (recommended)</summary>
117+
118+
````ts
119+
import type { Meta, StoryObj } from "@storybook/react";
120+
121+
const meta: Meta<typeof Button> = {
122+
title: "Example/Button",
123+
component: Button,
124+
parameters: {
125+
codesandbox: {
126+
/**
127+
* To import all components used within each story in
128+
* CodeSandbox, provide all necessary packages and modules.
129+
*
130+
* Given the following story:
131+
* ```js
132+
* import Provider from "@myscope/mypackage";
133+
* import { Button } from "@radix-ui/themes";
134+
* import "@radix-ui/themes/styles.css";
135+
* ```
136+
*
137+
* You need to map all imports to the following:
138+
*/
139+
mapComponent: {
140+
// Example of default imports
141+
"@myscope/mypackage": "Provider",
142+
143+
// Example of named functions
144+
"@radix-ui/themes": ["Button"],
145+
146+
// Example of static imports
147+
"@radix-ui/themes/styles.css": true,
148+
},
149+
150+
/**
151+
* @note You cannot use local modules or packages since
152+
* this story runs in an isolated environment (sandbox)
153+
* inside CodeSandbox. As such, the sandbox doesn't have
154+
* access to your file system.
155+
*/
156+
},
157+
},
158+
};
159+
````
160+
161+
</details>
162+
163+
<br />
164+
165+
Make sure to provide the necessary values for [`apiToken`](https://codesandbox.io/t/permissions) and any additional dependencies or providers required for your specific setup.
166+
167+
For now, this addon only supports the [Component Story Format (CSF)](https://storybook.js.org/docs/api/csf) stories format.
168+
169+
### Additional Notes
170+
171+
- Ensure that you have proper permissions and access rights to the CodeSandbox workspace specified in the configuration.
172+
- Verify the correctness of the dependencies and providers listed in the configuration to ensure the sandbox runs smoothly.

0 commit comments

Comments
 (0)