2021-09-16 16:15:43 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-03-26 21:47:35 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../../util/setupI18n';
|
2020-03-26 21:47:35 +00:00
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
|
|
|
import { GroupNotification, Props } from './GroupNotification';
|
2021-09-17 20:57:54 +00:00
|
|
|
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
|
2020-03-26 21:47:35 +00:00
|
|
|
|
|
|
|
const book = storiesOf('Components/Conversation', module);
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
type GroupNotificationStory = [string, Array<Props>];
|
|
|
|
|
2021-09-02 21:23:27 +00:00
|
|
|
const longName = '🍷🐓🥶'.repeat(50);
|
|
|
|
|
2020-03-26 21:47:35 +00:00
|
|
|
const stories: Array<GroupNotificationStory> = [
|
|
|
|
[
|
|
|
|
'Combo',
|
|
|
|
[
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mrs. Ice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1001',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1002',
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Ms. Earth',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{ type: 'name', newName: 'Fishing Stories' },
|
|
|
|
{ type: 'avatar' },
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mrs. Ice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1001',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Ms. Earth',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1002',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{ type: 'name', newName: 'Fishing Stories' },
|
|
|
|
{ type: 'avatar' },
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Joined group',
|
|
|
|
[
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: '(202) 555-1000',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mrs. Ice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1001',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Ms. Earth',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1002',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: '(202) 555-1000',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mrs. Ice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1001',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Ms. Earth',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1002',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mr. Fire',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mr. Fire',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mr. Fire',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
2020-06-25 22:36:24 +00:00
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-06-25 22:36:24 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-06-25 22:36:24 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'add',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mr. Fire',
|
2020-06-25 22:36:24 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mrs. Ice',
|
2020-06-25 22:36:24 +00:00
|
|
|
phoneNumber: '(202) 555-1001',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-06-25 22:36:24 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Left group',
|
|
|
|
[
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'remove',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mr. Fire',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mrs. Ice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1001',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Ms. Earth',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1002',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'remove',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Mr. Fire',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'remove',
|
|
|
|
contacts: [
|
2021-09-17 20:57:54 +00:00
|
|
|
getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Title changed',
|
|
|
|
[
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'name',
|
|
|
|
newName: 'New Group Name',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'name',
|
|
|
|
newName: 'New Group Name',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Avatar changed',
|
|
|
|
[
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'avatar',
|
|
|
|
newName: 'New Group Name',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
|
|
|
isMe: true,
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'avatar',
|
|
|
|
newName: 'New Group Name',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'Generic group update',
|
|
|
|
[
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2020-07-24 01:35:32 +00:00
|
|
|
title: 'Alice',
|
2020-03-26 21:47:35 +00:00
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2020-03-26 21:47:35 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'general',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
2021-09-02 21:23:27 +00:00
|
|
|
[
|
|
|
|
'Long name',
|
|
|
|
[
|
|
|
|
{
|
2021-09-17 20:57:54 +00:00
|
|
|
from: getDefaultConversation({
|
2021-09-02 21:23:27 +00:00
|
|
|
title: longName,
|
|
|
|
phoneNumber: '(202) 555-1000',
|
2021-09-17 20:57:54 +00:00
|
|
|
}),
|
2021-09-02 21:23:27 +00:00
|
|
|
changes: [
|
|
|
|
{
|
|
|
|
type: 'general',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
i18n,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
2020-03-26 21:47:35 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
book.add('GroupNotification', () =>
|
|
|
|
stories.map(([title, propsArray]) => (
|
|
|
|
<>
|
|
|
|
<h3>{title}</h3>
|
|
|
|
{propsArray.map((props, i) => {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div key={i} className="module-message-container">
|
|
|
|
<div className="module-inline-notification-wrapper">
|
|
|
|
<GroupNotification {...props} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</>
|
|
|
|
))
|
|
|
|
);
|