2024-08-06 19:29:13 +00:00
|
|
|
// Copyright 2024 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import React from 'react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
import type { ComponentMeta } from '../storybook/types';
|
|
|
|
import type { CallLinkDetailsProps } from './CallLinkDetails';
|
|
|
|
import { CallLinkDetails } from './CallLinkDetails';
|
|
|
|
import { setupI18n } from '../util/setupI18n';
|
|
|
|
import enMessages from '../../_locales/en/messages.json';
|
|
|
|
import {
|
|
|
|
FAKE_CALL_LINK,
|
|
|
|
FAKE_CALL_LINK_WITH_ADMIN_KEY,
|
|
|
|
} from '../test-both/helpers/fakeCallLink';
|
|
|
|
import { getFakeCallLinkHistoryGroup } from '../test-both/helpers/getFakeCallHistoryGroup';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Components/CallLinkDetails',
|
|
|
|
component: CallLinkDetails,
|
|
|
|
argTypes: {},
|
|
|
|
args: {
|
|
|
|
i18n,
|
|
|
|
callHistoryGroup: getFakeCallLinkHistoryGroup(),
|
|
|
|
callLink: FAKE_CALL_LINK_WITH_ADMIN_KEY,
|
2024-09-09 22:09:57 +00:00
|
|
|
isAnybodyInCall: false,
|
2024-10-18 20:19:45 +00:00
|
|
|
isCallActiveOnServer: false,
|
2024-09-09 22:09:57 +00:00
|
|
|
isInCall: false,
|
|
|
|
isInAnotherCall: false,
|
2024-08-06 19:29:13 +00:00
|
|
|
onDeleteCallLink: action('onDeleteCallLink'),
|
|
|
|
onOpenCallLinkAddNameModal: action('onOpenCallLinkAddNameModal'),
|
|
|
|
onStartCallLinkLobby: action('onStartCallLinkLobby'),
|
|
|
|
onShareCallLinkViaSignal: action('onShareCallLinkViaSignal'),
|
|
|
|
onUpdateCallLinkRestrictions: action('onUpdateCallLinkRestrictions'),
|
|
|
|
},
|
|
|
|
} satisfies ComponentMeta<CallLinkDetailsProps>;
|
|
|
|
|
|
|
|
export function Admin(args: CallLinkDetailsProps): JSX.Element {
|
|
|
|
return <CallLinkDetails {...args} />;
|
|
|
|
}
|
|
|
|
|
2024-09-09 22:09:57 +00:00
|
|
|
export function AdminAndCallActive(args: CallLinkDetailsProps): JSX.Element {
|
2024-10-18 20:19:45 +00:00
|
|
|
return <CallLinkDetails {...args} isAnybodyInCall isCallActiveOnServer />;
|
2024-09-09 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function AdminAndInCall(args: CallLinkDetailsProps): JSX.Element {
|
2024-10-18 20:19:45 +00:00
|
|
|
return (
|
|
|
|
<CallLinkDetails {...args} isAnybodyInCall isCallActiveOnServer isInCall />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function AdminRecentlyEndedCall(
|
|
|
|
args: CallLinkDetailsProps
|
|
|
|
): JSX.Element {
|
|
|
|
return <CallLinkDetails {...args} isCallActiveOnServer />;
|
2024-09-09 22:09:57 +00:00
|
|
|
}
|
|
|
|
|
2024-08-06 19:29:13 +00:00
|
|
|
export function NonAdmin(args: CallLinkDetailsProps): JSX.Element {
|
|
|
|
return <CallLinkDetails {...args} callLink={FAKE_CALL_LINK} />;
|
|
|
|
}
|
2024-08-26 20:48:41 +00:00
|
|
|
|
2024-09-09 22:09:57 +00:00
|
|
|
export function NonAdminAndCallActive(args: CallLinkDetailsProps): JSX.Element {
|
|
|
|
return (
|
2024-10-18 20:19:45 +00:00
|
|
|
<CallLinkDetails
|
|
|
|
{...args}
|
|
|
|
callLink={FAKE_CALL_LINK}
|
|
|
|
isAnybodyInCall
|
|
|
|
isCallActiveOnServer
|
|
|
|
/>
|
2024-09-09 22:09:57 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-08-26 20:48:41 +00:00
|
|
|
export function InAnotherCall(args: CallLinkDetailsProps): JSX.Element {
|
2024-09-09 22:09:57 +00:00
|
|
|
return (
|
2024-10-18 20:19:45 +00:00
|
|
|
<CallLinkDetails
|
|
|
|
{...args}
|
|
|
|
callLink={FAKE_CALL_LINK}
|
|
|
|
isInAnotherCall
|
|
|
|
isCallActiveOnServer
|
|
|
|
/>
|
2024-09-09 22:09:57 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function InAnotherCallAndCallActive(
|
|
|
|
args: CallLinkDetailsProps
|
|
|
|
): JSX.Element {
|
|
|
|
return (
|
|
|
|
<CallLinkDetails
|
|
|
|
{...args}
|
|
|
|
callLink={FAKE_CALL_LINK}
|
|
|
|
isAnybodyInCall
|
2024-10-18 20:19:45 +00:00
|
|
|
isCallActiveOnServer
|
2024-09-09 22:09:57 +00:00
|
|
|
isInAnotherCall
|
|
|
|
/>
|
|
|
|
);
|
2024-08-26 20:48:41 +00:00
|
|
|
}
|
2024-10-16 17:01:09 +00:00
|
|
|
|
|
|
|
export function MissingCallLink(args: CallLinkDetailsProps): JSX.Element {
|
|
|
|
return <CallLinkDetails {...args} callLink={undefined} />;
|
|
|
|
}
|