signal-desktop/ts/components/ToastManager.stories.tsx

353 lines
7.3 KiB
TypeScript
Raw Normal View History

// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Meta, Story } from '@storybook/react';
import React from 'react';
import type { PropsType } from './ToastManager';
import enMessages from '../../_locales/en/messages.json';
import { ToastManager } from './ToastManager';
import { ToastType } from '../types/Toast';
import { setupI18n } from '../util/setupI18n';
const i18n = setupI18n('en', enMessages);
export default {
title: 'Components/ToastManager',
component: ToastManager,
argTypes: {
hideToast: { action: true },
openFileInFolder: { action: true },
onUndoArchive: { action: true },
i18n: {
defaultValue: i18n,
},
toast: {
defaultValue: undefined,
},
2023-01-18 23:31:10 +00:00
OS: {
defaultValue: 'macOS',
},
},
} as Meta;
2022-11-18 00:45:19 +00:00
// eslint-disable-next-line react/function-component-definition
const Template: Story<PropsType> = args => <ToastManager {...args} />;
export const UndefinedToast = Template.bind({});
UndefinedToast.args = {};
export const InvalidToast = Template.bind({});
InvalidToast.args = {
toast: {
toastType: 'this is a toast that does not exist' as ToastType,
},
};
2022-12-07 01:00:02 +00:00
export const AddingUserToGroup = Template.bind({});
AddingUserToGroup.args = {
toast: {
toastType: ToastType.AddingUserToGroup,
parameters: {
contact: 'Sam Mirete',
},
},
};
2022-12-22 03:07:45 +00:00
export const AlreadyGroupMember = Template.bind({});
AlreadyGroupMember.args = {
toast: {
toastType: ToastType.AlreadyGroupMember,
},
};
export const AlreadyRequestedToJoin = Template.bind({});
AlreadyRequestedToJoin.args = {
toast: {
toastType: ToastType.AlreadyRequestedToJoin,
},
};
2022-12-08 07:43:48 +00:00
export const Blocked = Template.bind({});
Blocked.args = {
toast: {
toastType: ToastType.Blocked,
},
};
export const BlockedGroup = Template.bind({});
BlockedGroup.args = {
toast: {
toastType: ToastType.BlockedGroup,
},
};
export const CannotMixMultiAndNonMultiAttachments = Template.bind({});
CannotMixMultiAndNonMultiAttachments.args = {
toast: {
toastType: ToastType.CannotMixMultiAndNonMultiAttachments,
},
};
export const CannotOpenGiftBadgeIncoming = Template.bind({});
CannotOpenGiftBadgeIncoming.args = {
toast: {
toastType: ToastType.CannotOpenGiftBadgeIncoming,
},
};
export const CannotOpenGiftBadgeOutgoing = Template.bind({});
CannotOpenGiftBadgeOutgoing.args = {
toast: {
toastType: ToastType.CannotOpenGiftBadgeOutgoing,
},
};
2022-12-07 01:00:02 +00:00
export const CannotStartGroupCall = Template.bind({});
CannotStartGroupCall.args = {
toast: {
toastType: ToastType.CannotStartGroupCall,
},
};
export const ConversationArchived = Template.bind({});
ConversationArchived.args = {
toast: {
toastType: ToastType.ConversationArchived,
parameters: {
conversationId: 'some-conversation-id',
},
},
};
export const ConversationMarkedUnread = Template.bind({});
ConversationMarkedUnread.args = {
toast: {
toastType: ToastType.ConversationMarkedUnread,
},
};
2023-04-05 20:48:00 +00:00
export const ConversationRemoved = Template.bind({});
ConversationRemoved.args = {
toast: {
toastType: ToastType.ConversationRemoved,
parameters: {
title: 'Alice',
},
},
};
export const ConversationUnarchived = Template.bind({});
ConversationUnarchived.args = {
toast: {
toastType: ToastType.ConversationUnarchived,
},
};
2022-12-07 01:00:02 +00:00
export const CopiedUsername = Template.bind({});
CopiedUsername.args = {
toast: {
toastType: ToastType.CopiedUsername,
},
};
export const CopiedUsernameLink = Template.bind({});
CopiedUsernameLink.args = {
toast: {
toastType: ToastType.CopiedUsernameLink,
},
};
export const DangerousFileType = Template.bind({});
DangerousFileType.args = {
toast: {
toastType: ToastType.DangerousFileType,
},
};
2022-12-07 01:00:02 +00:00
export const DeleteForEveryoneFailed = Template.bind({});
DeleteForEveryoneFailed.args = {
toast: {
toastType: ToastType.DeleteForEveryoneFailed,
},
};
export const Error = Template.bind({});
Error.args = {
toast: {
toastType: ToastType.Error,
},
};
2022-12-08 07:43:48 +00:00
export const Expired = Template.bind({});
Expired.args = {
toast: {
toastType: ToastType.Expired,
},
};
2022-12-07 01:00:02 +00:00
export const FailedToDeleteUsername = Template.bind({});
FailedToDeleteUsername.args = {
toast: {
toastType: ToastType.FailedToDeleteUsername,
},
};
2022-12-14 18:12:04 +00:00
export const FileSaved = Template.bind({});
FileSaved.args = {
toast: {
toastType: ToastType.FileSaved,
parameters: {
fullPath: '/image.png',
},
},
};
export const FileSize = Template.bind({});
FileSize.args = {
toast: {
toastType: ToastType.FileSize,
parameters: {
limit: '100',
units: 'MB',
},
},
};
2022-12-08 07:43:48 +00:00
export const InvalidConversation = Template.bind({});
InvalidConversation.args = {
toast: {
toastType: ToastType.InvalidConversation,
},
};
export const LeftGroup = Template.bind({});
LeftGroup.args = {
toast: {
toastType: ToastType.LeftGroup,
},
};
export const MaxAttachments = Template.bind({});
MaxAttachments.args = {
toast: {
toastType: ToastType.MaxAttachments,
},
};
export const OriginalMessageNotFound = Template.bind({});
OriginalMessageNotFound.args = {
toast: {
toastType: ToastType.OriginalMessageNotFound,
},
};
2022-12-07 01:00:02 +00:00
export const MessageBodyTooLong = Template.bind({});
MessageBodyTooLong.args = {
toast: {
toastType: ToastType.MessageBodyTooLong,
},
};
export const PinnedConversationsFull = Template.bind({});
PinnedConversationsFull.args = {
toast: {
toastType: ToastType.PinnedConversationsFull,
},
};
export const ReactionFailed = Template.bind({});
ReactionFailed.args = {
toast: {
toastType: ToastType.ReactionFailed,
},
};
export const ReportedSpamAndBlocked = Template.bind({});
ReportedSpamAndBlocked.args = {
2022-12-07 01:00:02 +00:00
toast: {
toastType: ToastType.ReportedSpamAndBlocked,
2022-12-07 01:00:02 +00:00
},
};
export const StoryMuted = Template.bind({});
StoryMuted.args = {
2022-12-07 01:00:02 +00:00
toast: {
toastType: ToastType.StoryMuted,
2022-12-07 01:00:02 +00:00
},
};
export const StoryReact = Template.bind({});
StoryReact.args = {
toast: {
toastType: ToastType.StoryReact,
},
};
export const StoryReply = Template.bind({});
StoryReply.args = {
toast: {
toastType: ToastType.StoryReply,
},
};
2022-12-07 01:00:02 +00:00
export const StoryVideoError = Template.bind({});
StoryVideoError.args = {
toast: {
2022-12-07 01:00:02 +00:00
toastType: ToastType.StoryVideoError,
},
};
export const StoryVideoUnsupported = Template.bind({});
StoryVideoUnsupported.args = {
toast: {
toastType: ToastType.StoryVideoUnsupported,
},
};
export const TapToViewExpiredIncoming = Template.bind({});
TapToViewExpiredIncoming.args = {
toast: {
toastType: ToastType.TapToViewExpiredIncoming,
},
};
export const TapToViewExpiredOutgoing = Template.bind({});
TapToViewExpiredOutgoing.args = {
toast: {
toastType: ToastType.TapToViewExpiredOutgoing,
},
};
export const UnableToLoadAttachment = Template.bind({});
UnableToLoadAttachment.args = {
toast: {
toastType: ToastType.UnableToLoadAttachment,
},
};
export const UnsupportedMultiAttachment = Template.bind({});
UnsupportedMultiAttachment.args = {
toast: {
toastType: ToastType.UnsupportedMultiAttachment,
},
};
2023-01-18 23:31:10 +00:00
export const UnsupportedOS = Template.bind({});
UnsupportedOS.args = {
toast: {
toastType: ToastType.UnsupportedOS,
},
};
2022-12-07 01:00:02 +00:00
export const UserAddedToGroup = Template.bind({});
UserAddedToGroup.args = {
toast: {
2022-12-07 01:00:02 +00:00
toastType: ToastType.UserAddedToGroup,
parameters: {
contact: 'Sam Mirete',
group: 'Hike Group 🏔',
},
2022-12-06 19:03:09 +00:00
},
};