2022-07-12 16:41:41 +00:00
|
|
|
// 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';
|
2022-12-15 00:48:36 +00:00
|
|
|
import { ToastType } from '../types/Toast';
|
2022-07-12 16:41:41 +00:00
|
|
|
import { setupI18n } from '../util/setupI18n';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Components/ToastManager',
|
|
|
|
component: ToastManager,
|
|
|
|
argTypes: {
|
|
|
|
hideToast: { action: true },
|
2022-12-21 03:25:10 +00:00
|
|
|
openFileInFolder: { action: true },
|
|
|
|
onUndoArchive: { action: true },
|
2022-07-12 16:41:41 +00:00
|
|
|
i18n: {
|
|
|
|
defaultValue: i18n,
|
|
|
|
},
|
2022-09-26 16:24:52 +00:00
|
|
|
toast: {
|
2022-07-12 16:41:41 +00:00
|
|
|
defaultValue: undefined,
|
|
|
|
},
|
2023-01-18 23:31:10 +00:00
|
|
|
OS: {
|
|
|
|
defaultValue: 'macOS',
|
|
|
|
},
|
2022-07-12 16:41:41 +00:00
|
|
|
},
|
|
|
|
} as Meta;
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
// eslint-disable-next-line react/function-component-definition
|
2022-07-12 16:41:41 +00:00
|
|
|
const Template: Story<PropsType> = args => <ToastManager {...args} />;
|
|
|
|
|
|
|
|
export const UndefinedToast = Template.bind({});
|
|
|
|
UndefinedToast.args = {};
|
|
|
|
|
|
|
|
export const InvalidToast = Template.bind({});
|
|
|
|
InvalidToast.args = {
|
2022-09-26 16:24:52 +00:00
|
|
|
toast: {
|
|
|
|
toastType: 'this is a toast that does not exist' as ToastType,
|
|
|
|
},
|
2022-07-12 16:41:41 +00:00
|
|
|
};
|
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-08 01:26:59 +00:00
|
|
|
export const CannotMixMultiAndNonMultiAttachments = Template.bind({});
|
|
|
|
CannotMixMultiAndNonMultiAttachments.args = {
|
|
|
|
toast: {
|
|
|
|
toastType: ToastType.CannotMixMultiAndNonMultiAttachments,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-20 01:04:47 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-21 03:25:10 +00:00
|
|
|
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',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-21 03:25:10 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-08 01:26:59 +00:00
|
|
|
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',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-08 01:26:59 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-08 01:26:59 +00:00
|
|
|
export const MaxAttachments = Template.bind({});
|
|
|
|
MaxAttachments.args = {
|
|
|
|
toast: {
|
|
|
|
toastType: ToastType.MaxAttachments,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-21 03:25:10 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-20 01:04:47 +00:00
|
|
|
export const ReactionFailed = Template.bind({});
|
|
|
|
ReactionFailed.args = {
|
|
|
|
toast: {
|
|
|
|
toastType: ToastType.ReactionFailed,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-08 01:26:59 +00:00
|
|
|
export const ReportedSpamAndBlocked = Template.bind({});
|
|
|
|
ReportedSpamAndBlocked.args = {
|
2022-12-07 01:00:02 +00:00
|
|
|
toast: {
|
2022-12-08 01:26:59 +00:00
|
|
|
toastType: ToastType.ReportedSpamAndBlocked,
|
2022-12-07 01:00:02 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-08 01:26:59 +00:00
|
|
|
export const StoryMuted = Template.bind({});
|
|
|
|
StoryMuted.args = {
|
2022-12-07 01:00:02 +00:00
|
|
|
toast: {
|
2022-12-08 01:26:59 +00:00
|
|
|
toastType: ToastType.StoryMuted,
|
2022-12-07 01:00:02 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-07-12 16:41:41 +00:00
|
|
|
export const StoryReact = Template.bind({});
|
|
|
|
StoryReact.args = {
|
2022-09-26 16:24:52 +00:00
|
|
|
toast: {
|
|
|
|
toastType: ToastType.StoryReact,
|
|
|
|
},
|
2022-07-12 16:41:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const StoryReply = Template.bind({});
|
|
|
|
StoryReply.args = {
|
2022-09-26 16:24:52 +00:00
|
|
|
toast: {
|
|
|
|
toastType: ToastType.StoryReply,
|
|
|
|
},
|
2022-07-12 16:41:41 +00:00
|
|
|
};
|
|
|
|
|
2022-12-07 01:00:02 +00:00
|
|
|
export const StoryVideoError = Template.bind({});
|
|
|
|
StoryVideoError.args = {
|
2022-09-26 16:24:52 +00:00
|
|
|
toast: {
|
2022-12-07 01:00:02 +00:00
|
|
|
toastType: ToastType.StoryVideoError,
|
2022-09-26 16:24:52 +00:00
|
|
|
},
|
2022-07-12 16:41:41 +00:00
|
|
|
};
|
2022-08-12 23:44:10 +00:00
|
|
|
|
|
|
|
export const StoryVideoUnsupported = Template.bind({});
|
|
|
|
StoryVideoUnsupported.args = {
|
2022-09-26 16:24:52 +00:00
|
|
|
toast: {
|
|
|
|
toastType: ToastType.StoryVideoUnsupported,
|
|
|
|
},
|
2022-08-12 23:44:10 +00:00
|
|
|
};
|
|
|
|
|
2022-12-20 01:04:47 +00:00
|
|
|
export const TapToViewExpiredIncoming = Template.bind({});
|
|
|
|
TapToViewExpiredIncoming.args = {
|
|
|
|
toast: {
|
|
|
|
toastType: ToastType.TapToViewExpiredIncoming,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const TapToViewExpiredOutgoing = Template.bind({});
|
|
|
|
TapToViewExpiredOutgoing.args = {
|
|
|
|
toast: {
|
|
|
|
toastType: ToastType.TapToViewExpiredOutgoing,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-12-08 01:26:59 +00:00
|
|
|
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 = {
|
2022-09-26 16:24:52 +00:00
|
|
|
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
|
|
|
},
|
|
|
|
};
|