Skip to content

Commit 50a65ae

Browse files
JonasBanatemoo-regetsantry[bot]
authored
ref(storybook) add useUser story (#83263)
Render the serialized user JSON value --------- Co-authored-by: Nate Moore <[email protected]> Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent 48826bf commit 50a65ae

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
1+
import {Fragment} from 'react';
2+
13
import StructuredEventData from 'sentry/components/structuredEventData';
24
import storyBook from 'sentry/stories/storyBook';
35
import useOrganization from 'sentry/utils/useOrganization';
46

57
export default storyBook('useOrganization', story => {
6-
story('useOrganization - via StructuredEventData', () => {
8+
story('Default', () => {
79
const org = useOrganization();
8-
return <StructuredEventData data={org} />;
10+
11+
// Sort features and access alphabetically for the story use case
12+
org.features.sort((a, b) => a.localeCompare(b));
13+
org.access.sort((a, b) => a.localeCompare(b));
14+
15+
return (
16+
<Fragment>
17+
<p>
18+
<code>useOrganization</code> returns the currently selected organization.
19+
</p>
20+
In the context of the Sentry dashboard, only a single organization can be selected
21+
at a time.
22+
<p>
23+
A common need to use <code>useOrganization</code> is to check for feature flags
24+
via <code>organization.features.includes(feature)</code>. Note that our feature
25+
names are currently not typed, so you need to make sure you pass in the correct
26+
feature name.
27+
</p>
28+
<StructuredEventData data={org} />
29+
</Fragment>
30+
);
931
});
1032
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {Fragment} from 'react';
2+
3+
import StructuredEventData from 'sentry/components/structuredEventData';
4+
import storyBook from 'sentry/stories/storyBook';
5+
6+
import {useUser} from './useUser';
7+
8+
export default storyBook('useUser', story => {
9+
story('useUser', () => {
10+
const user = useUser();
11+
12+
return (
13+
<Fragment>
14+
<p>
15+
<code>useUser</code> returns the currently logged in user.
16+
</p>
17+
<StructuredEventData data={user} />
18+
</Fragment>
19+
);
20+
});
21+
});

0 commit comments

Comments
 (0)