Upgrade Storybook
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
8c966dfbd8
commit
502ea174ab
328 changed files with 10863 additions and 12432 deletions
|
@ -1,17 +1,17 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Meta, Story } from '@storybook/react';
|
||||
import type { Meta, StoryFn } from '@storybook/react';
|
||||
import React from 'react';
|
||||
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import enMessages from '../../_locales/en/messages.json';
|
||||
import type { PropsDataType, PropsType } from './Preferences';
|
||||
import type { PropsType } from './Preferences';
|
||||
import { Preferences } from './Preferences';
|
||||
import { setupI18n } from '../util/setupI18n';
|
||||
import { DEFAULT_CONVERSATION_COLOR } from '../types/Colors';
|
||||
import { PhoneNumberSharingMode } from '../util/phoneNumberSharingMode';
|
||||
import { PhoneNumberDiscoverability } from '../util/phoneNumberDiscoverability';
|
||||
import { objectMap } from '../util/objectMap';
|
||||
import { DurationInSeconds } from '../util/durations';
|
||||
|
||||
const i18n = setupI18n('en', enMessages);
|
||||
|
@ -44,145 +44,144 @@ const availableSpeakers = [
|
|||
},
|
||||
];
|
||||
|
||||
const getDefaultArgs = (): PropsDataType => ({
|
||||
availableCameras: [
|
||||
{
|
||||
deviceId:
|
||||
'dfbe6effe70b0611ba0fdc2a9ea3f39f6cb110e6687948f7e5f016c111b7329c',
|
||||
groupId:
|
||||
'63ee218d2446869e40adfc958ff98263e51f74382b0143328ee4826f20a76f47',
|
||||
kind: 'videoinput' as MediaDeviceKind,
|
||||
label: 'FaceTime HD Camera (Built-in) (9fba:bced)',
|
||||
},
|
||||
{
|
||||
deviceId:
|
||||
'e2db196a31d50ff9b135299dc0beea67f65b1a25a06d8a4ce76976751bb7a08d',
|
||||
groupId:
|
||||
'218ba7f00d7b1239cca15b9116769e5e7d30cc01104ebf84d667643661e0ecf9',
|
||||
kind: 'videoinput' as MediaDeviceKind,
|
||||
label: 'Logitech Webcam (4e72:9058)',
|
||||
},
|
||||
],
|
||||
availableMicrophones,
|
||||
availableSpeakers,
|
||||
blockedCount: 0,
|
||||
customColors: {},
|
||||
defaultConversationColor: DEFAULT_CONVERSATION_COLOR,
|
||||
deviceName: 'Work Windows ME',
|
||||
hasAudioNotifications: true,
|
||||
hasAutoDownloadUpdate: true,
|
||||
hasAutoLaunch: true,
|
||||
hasCallNotifications: true,
|
||||
hasCallRingtoneNotification: false,
|
||||
hasCountMutedConversations: false,
|
||||
hasCustomTitleBar: true,
|
||||
hasHideMenuBar: false,
|
||||
hasIncomingCallNotifications: true,
|
||||
hasLinkPreviews: true,
|
||||
hasMediaCameraPermissions: true,
|
||||
hasMediaPermissions: true,
|
||||
hasMessageAudio: true,
|
||||
hasMinimizeToAndStartInSystemTray: true,
|
||||
hasMinimizeToSystemTray: true,
|
||||
hasNotificationAttention: false,
|
||||
hasNotifications: true,
|
||||
hasReadReceipts: true,
|
||||
hasRelayCalls: false,
|
||||
hasSpellCheck: true,
|
||||
hasStoriesDisabled: false,
|
||||
hasTextFormatting: true,
|
||||
hasTypingIndicators: true,
|
||||
initialSpellCheckSetting: true,
|
||||
isAutoDownloadUpdatesSupported: true,
|
||||
isAutoLaunchSupported: true,
|
||||
isFormattingFlagEnabled: true,
|
||||
isHideMenuBarSupported: true,
|
||||
isNotificationAttentionSupported: true,
|
||||
isPhoneNumberSharingSupported: true,
|
||||
isSyncSupported: true,
|
||||
isSystemTraySupported: true,
|
||||
isMinimizeToAndStartInSystemTraySupported: true,
|
||||
lastSyncTime: Date.now(),
|
||||
notificationContent: 'name',
|
||||
selectedCamera:
|
||||
'dfbe6effe70b0611ba0fdc2a9ea3f39f6cb110e6687948f7e5f016c111b7329c',
|
||||
selectedMicrophone: availableMicrophones[0],
|
||||
selectedSpeaker: availableSpeakers[1],
|
||||
shouldShowStoriesSettings: true,
|
||||
sentMediaQualitySetting: 'standard',
|
||||
themeSetting: 'system',
|
||||
universalExpireTimer: DurationInSeconds.HOUR,
|
||||
whoCanFindMe: PhoneNumberDiscoverability.Discoverable,
|
||||
whoCanSeeMe: PhoneNumberSharingMode.Everybody,
|
||||
zoomFactor: 1,
|
||||
});
|
||||
|
||||
const defaultArgTypes: Record<string, { defaultValue: unknown }> = {};
|
||||
objectMap(getDefaultArgs(), (key, defaultValue) => {
|
||||
defaultArgTypes[key] = { defaultValue };
|
||||
});
|
||||
|
||||
export default {
|
||||
title: 'Components/Preferences',
|
||||
component: Preferences,
|
||||
argTypes: {
|
||||
// ...defaultArgTypes,
|
||||
args: {
|
||||
i18n,
|
||||
|
||||
i18n: {
|
||||
defaultValue: i18n,
|
||||
},
|
||||
availableCameras: [
|
||||
{
|
||||
deviceId:
|
||||
'dfbe6effe70b0611ba0fdc2a9ea3f39f6cb110e6687948f7e5f016c111b7329c',
|
||||
groupId:
|
||||
'63ee218d2446869e40adfc958ff98263e51f74382b0143328ee4826f20a76f47',
|
||||
kind: 'videoinput' as MediaDeviceKind,
|
||||
label: 'FaceTime HD Camera (Built-in) (9fba:bced)',
|
||||
},
|
||||
{
|
||||
deviceId:
|
||||
'e2db196a31d50ff9b135299dc0beea67f65b1a25a06d8a4ce76976751bb7a08d',
|
||||
groupId:
|
||||
'218ba7f00d7b1239cca15b9116769e5e7d30cc01104ebf84d667643661e0ecf9',
|
||||
kind: 'videoinput' as MediaDeviceKind,
|
||||
label: 'Logitech Webcam (4e72:9058)',
|
||||
},
|
||||
],
|
||||
availableMicrophones,
|
||||
availableSpeakers,
|
||||
blockedCount: 0,
|
||||
customColors: {},
|
||||
defaultConversationColor: DEFAULT_CONVERSATION_COLOR,
|
||||
deviceName: 'Work Windows ME',
|
||||
hasAudioNotifications: true,
|
||||
hasAutoDownloadUpdate: true,
|
||||
hasAutoLaunch: true,
|
||||
hasCallNotifications: true,
|
||||
hasCallRingtoneNotification: false,
|
||||
hasCountMutedConversations: false,
|
||||
hasCustomTitleBar: true,
|
||||
hasHideMenuBar: false,
|
||||
hasIncomingCallNotifications: true,
|
||||
hasLinkPreviews: true,
|
||||
hasMediaCameraPermissions: true,
|
||||
hasMediaPermissions: true,
|
||||
hasMessageAudio: true,
|
||||
hasMinimizeToAndStartInSystemTray: true,
|
||||
hasMinimizeToSystemTray: true,
|
||||
hasNotificationAttention: false,
|
||||
hasNotifications: true,
|
||||
hasReadReceipts: true,
|
||||
hasRelayCalls: false,
|
||||
hasSpellCheck: true,
|
||||
hasStoriesDisabled: false,
|
||||
hasTextFormatting: true,
|
||||
hasTypingIndicators: true,
|
||||
initialSpellCheckSetting: true,
|
||||
isAutoDownloadUpdatesSupported: true,
|
||||
isAutoLaunchSupported: true,
|
||||
isFormattingFlagEnabled: true,
|
||||
isHideMenuBarSupported: true,
|
||||
isNotificationAttentionSupported: true,
|
||||
isPhoneNumberSharingSupported: true,
|
||||
isSyncSupported: true,
|
||||
isSystemTraySupported: true,
|
||||
isMinimizeToAndStartInSystemTraySupported: true,
|
||||
lastSyncTime: Date.now(),
|
||||
notificationContent: 'name',
|
||||
selectedCamera:
|
||||
'dfbe6effe70b0611ba0fdc2a9ea3f39f6cb110e6687948f7e5f016c111b7329c',
|
||||
selectedMicrophone: availableMicrophones[0],
|
||||
selectedSpeaker: availableSpeakers[1],
|
||||
shouldShowStoriesSettings: true,
|
||||
sentMediaQualitySetting: 'standard',
|
||||
themeSetting: 'system',
|
||||
universalExpireTimer: DurationInSeconds.HOUR,
|
||||
whoCanFindMe: PhoneNumberDiscoverability.Discoverable,
|
||||
whoCanSeeMe: PhoneNumberSharingMode.Everybody,
|
||||
zoomFactor: 1,
|
||||
|
||||
addCustomColor: { action: true },
|
||||
closeSettings: { action: true },
|
||||
doDeleteAllData: { action: true },
|
||||
doneRendering: { action: true },
|
||||
editCustomColor: { action: true },
|
||||
executeMenuRole: { action: true },
|
||||
getConversationsWithCustomColor: { action: true },
|
||||
makeSyncRequest: { action: true },
|
||||
onAudioNotificationsChange: { action: true },
|
||||
onAutoDownloadUpdateChange: { action: true },
|
||||
onAutoLaunchChange: { action: true },
|
||||
onCallNotificationsChange: { action: true },
|
||||
onCallRingtoneNotificationChange: { action: true },
|
||||
onCountMutedConversationsChange: { action: true },
|
||||
onHasStoriesDisabledChanged: { action: true },
|
||||
onHideMenuBarChange: { action: true },
|
||||
onIncomingCallNotificationsChange: { action: true },
|
||||
onLastSyncTimeChange: { action: true },
|
||||
onMediaCameraPermissionsChange: { action: true },
|
||||
onMediaPermissionsChange: { action: true },
|
||||
onMessageAudioChange: { action: true },
|
||||
onMinimizeToAndStartInSystemTrayChange: { action: true },
|
||||
onMinimizeToSystemTrayChange: { action: true },
|
||||
onNotificationAttentionChange: { action: true },
|
||||
onNotificationContentChange: { action: true },
|
||||
onNotificationsChange: { action: true },
|
||||
onRelayCallsChange: { action: true },
|
||||
onSelectedCameraChange: { action: true },
|
||||
onSelectedMicrophoneChange: { action: true },
|
||||
onSelectedSpeakerChange: { action: true },
|
||||
onSentMediaQualityChange: { action: true },
|
||||
onSpellCheckChange: { action: true },
|
||||
onTextFormattingChange: { action: true },
|
||||
onThemeChange: { action: true },
|
||||
onUniversalExpireTimerChange: { action: true },
|
||||
onWhoCanSeeMeChange: { action: true },
|
||||
onWhoCanFindMeChange: { action: true },
|
||||
onZoomFactorChange: { action: true },
|
||||
removeCustomColor: { action: true },
|
||||
removeCustomColorOnConversations: { action: true },
|
||||
resetAllChatColors: { action: true },
|
||||
resetDefaultChatColor: { action: true },
|
||||
setGlobalDefaultConversationColor: { action: true },
|
||||
},
|
||||
} as Meta;
|
||||
getConversationsWithCustomColor: () => Promise.resolve([]),
|
||||
|
||||
addCustomColor: action('addCustomColor'),
|
||||
closeSettings: action('closeSettings'),
|
||||
doDeleteAllData: action('doDeleteAllData'),
|
||||
doneRendering: action('doneRendering'),
|
||||
editCustomColor: action('editCustomColor'),
|
||||
executeMenuRole: action('executeMenuRole'),
|
||||
makeSyncRequest: action('makeSyncRequest'),
|
||||
onAudioNotificationsChange: action('onAudioNotificationsChange'),
|
||||
onAutoDownloadUpdateChange: action('onAutoDownloadUpdateChange'),
|
||||
onAutoLaunchChange: action('onAutoLaunchChange'),
|
||||
onCallNotificationsChange: action('onCallNotificationsChange'),
|
||||
onCallRingtoneNotificationChange: action(
|
||||
'onCallRingtoneNotificationChange'
|
||||
),
|
||||
onCountMutedConversationsChange: action('onCountMutedConversationsChange'),
|
||||
onHasStoriesDisabledChanged: action('onHasStoriesDisabledChanged'),
|
||||
onHideMenuBarChange: action('onHideMenuBarChange'),
|
||||
onIncomingCallNotificationsChange: action(
|
||||
'onIncomingCallNotificationsChange'
|
||||
),
|
||||
onLastSyncTimeChange: action('onLastSyncTimeChange'),
|
||||
onMediaCameraPermissionsChange: action('onMediaCameraPermissionsChange'),
|
||||
onMediaPermissionsChange: action('onMediaPermissionsChange'),
|
||||
onMessageAudioChange: action('onMessageAudioChange'),
|
||||
onMinimizeToAndStartInSystemTrayChange: action(
|
||||
'onMinimizeToAndStartInSystemTrayChange'
|
||||
),
|
||||
onMinimizeToSystemTrayChange: action('onMinimizeToSystemTrayChange'),
|
||||
onNotificationAttentionChange: action('onNotificationAttentionChange'),
|
||||
onNotificationContentChange: action('onNotificationContentChange'),
|
||||
onNotificationsChange: action('onNotificationsChange'),
|
||||
onRelayCallsChange: action('onRelayCallsChange'),
|
||||
onSelectedCameraChange: action('onSelectedCameraChange'),
|
||||
onSelectedMicrophoneChange: action('onSelectedMicrophoneChange'),
|
||||
onSelectedSpeakerChange: action('onSelectedSpeakerChange'),
|
||||
onSentMediaQualityChange: action('onSentMediaQualityChange'),
|
||||
onSpellCheckChange: action('onSpellCheckChange'),
|
||||
onTextFormattingChange: action('onTextFormattingChange'),
|
||||
onThemeChange: action('onThemeChange'),
|
||||
onUniversalExpireTimerChange: action('onUniversalExpireTimerChange'),
|
||||
onWhoCanSeeMeChange: action('onWhoCanSeeMeChange'),
|
||||
onWhoCanFindMeChange: action('onWhoCanFindMeChange'),
|
||||
onZoomFactorChange: action('onZoomFactorChange'),
|
||||
removeCustomColor: action('removeCustomColor'),
|
||||
removeCustomColorOnConversations: action(
|
||||
'removeCustomColorOnConversations'
|
||||
),
|
||||
resetAllChatColors: action('resetAllChatColors'),
|
||||
resetDefaultChatColor: action('resetDefaultChatColor'),
|
||||
setGlobalDefaultConversationColor: action(
|
||||
'setGlobalDefaultConversationColor'
|
||||
),
|
||||
} satisfies PropsType,
|
||||
} satisfies Meta<PropsType>;
|
||||
|
||||
// eslint-disable-next-line react/function-component-definition
|
||||
const Template: Story<PropsType> = args => <Preferences {...args} />;
|
||||
const Template: StoryFn<PropsType> = args => <Preferences {...args} />;
|
||||
|
||||
export const _Preferences = Template.bind({});
|
||||
_Preferences.args = getDefaultArgs();
|
||||
|
||||
export const Blocked1 = Template.bind({});
|
||||
Blocked1.args = {
|
||||
|
@ -198,9 +197,6 @@ export const CustomUniversalExpireTimer = Template.bind({});
|
|||
CustomUniversalExpireTimer.args = {
|
||||
universalExpireTimer: DurationInSeconds.fromSeconds(9000),
|
||||
};
|
||||
CustomUniversalExpireTimer.story = {
|
||||
name: 'Custom universalExpireTimer',
|
||||
};
|
||||
|
||||
export const PNPSharingDisabled = Template.bind({});
|
||||
PNPSharingDisabled.args = {
|
||||
|
@ -208,9 +204,6 @@ PNPSharingDisabled.args = {
|
|||
whoCanFindMe: PhoneNumberDiscoverability.Discoverable,
|
||||
isPhoneNumberSharingSupported: true,
|
||||
};
|
||||
PNPSharingDisabled.story = {
|
||||
name: 'PNP Sharing Disabled',
|
||||
};
|
||||
|
||||
export const PNPDiscoverabilityDisabled = Template.bind({});
|
||||
PNPDiscoverabilityDisabled.args = {
|
||||
|
@ -218,9 +211,6 @@ PNPDiscoverabilityDisabled.args = {
|
|||
whoCanFindMe: PhoneNumberDiscoverability.NotDiscoverable,
|
||||
isPhoneNumberSharingSupported: true,
|
||||
};
|
||||
PNPDiscoverabilityDisabled.story = {
|
||||
name: 'PNP Discoverability Disabled',
|
||||
};
|
||||
|
||||
export const FormattingDisabled = Template.bind({});
|
||||
FormattingDisabled.args = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue