Fix auth modal story not rendering. Closes #2254
This commit is contained in:
@@ -1,13 +1,30 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||||
import { RecoilRoot } from 'recoil';
|
import { RecoilRoot, useSetRecoilState } from 'recoil';
|
||||||
import { AuthModal } from './AuthModal';
|
import { AuthModal } from './AuthModal';
|
||||||
|
import { currentUserAtom } from '../../stores/ClientConfigStore';
|
||||||
|
import { CurrentUser } from '../../../interfaces/current-user';
|
||||||
|
|
||||||
const Example = () => (
|
const Example = () => {
|
||||||
<div>
|
const setCurrentUser = useSetRecoilState<CurrentUser>(currentUserAtom);
|
||||||
<AuthModal />
|
|
||||||
</div>
|
useEffect(
|
||||||
);
|
() =>
|
||||||
|
setCurrentUser({
|
||||||
|
id: '1',
|
||||||
|
displayName: 'Test User',
|
||||||
|
displayColor: 3,
|
||||||
|
isModerator: false,
|
||||||
|
}),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<AuthModal />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'owncast/Modals/Auth',
|
title: 'owncast/Modals/Auth',
|
||||||
@@ -15,8 +32,7 @@ export default {
|
|||||||
parameters: {},
|
parameters: {},
|
||||||
} as ComponentMeta<typeof AuthModal>;
|
} as ComponentMeta<typeof AuthModal>;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
const Template: ComponentStory<typeof AuthModal> = () => (
|
||||||
const Template: ComponentStory<typeof AuthModal> = args => (
|
|
||||||
<RecoilRoot>
|
<RecoilRoot>
|
||||||
<Example />
|
<Example />
|
||||||
</RecoilRoot>
|
</RecoilRoot>
|
||||||
|
|||||||
@@ -15,22 +15,23 @@ import {
|
|||||||
} from '../../stores/ClientConfigStore';
|
} from '../../stores/ClientConfigStore';
|
||||||
|
|
||||||
export const AuthModal: FC = () => {
|
export const AuthModal: FC = () => {
|
||||||
|
const authenticated = useRecoilValue<boolean>(chatAuthenticatedAtom);
|
||||||
|
const accessToken = useRecoilValue<string>(accessTokenAtom);
|
||||||
const currentUser = useRecoilValue(currentUserAtom);
|
const currentUser = useRecoilValue(currentUserAtom);
|
||||||
if (!currentUser) {
|
if (!currentUser) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const authenticated = useRecoilValue<boolean>(chatAuthenticatedAtom);
|
|
||||||
const accessToken = useRecoilValue<string>(accessTokenAtom);
|
|
||||||
const federationEnabled = true;
|
|
||||||
const { displayName } = currentUser;
|
const { displayName } = currentUser;
|
||||||
|
|
||||||
|
const federationEnabled = true;
|
||||||
|
|
||||||
const indieAuthTabTitle = (
|
const indieAuthTabTitle = (
|
||||||
<span className={styles.tabContent}>
|
<span className={styles.tabContent}>
|
||||||
<img className={styles.icon} src={IndieAuthIcon.src} alt="IndieAuth" />
|
<img className={styles.icon} src={IndieAuthIcon.src} alt="IndieAuth" />
|
||||||
IndieAuth
|
IndieAuth
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
const indieAuthTab = (
|
const indieAuthTab = (
|
||||||
<IndieAuthModal
|
<IndieAuthModal
|
||||||
authenticated={authenticated}
|
authenticated={authenticated}
|
||||||
@@ -45,6 +46,7 @@ export const AuthModal: FC = () => {
|
|||||||
FediAuth
|
FediAuth
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
const fediAuthTab = (
|
const fediAuthTab = (
|
||||||
<FediAuthModal
|
<FediAuthModal
|
||||||
authenticated={authenticated}
|
authenticated={authenticated}
|
||||||
|
|||||||
Reference in New Issue
Block a user