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

217 lines
7.5 KiB
TypeScript
Raw Normal View History

2021-08-18 20:08:14 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { Meta, StoryFn } from '@storybook/react';
2021-08-18 20:08:14 +00:00
import React from 'react';
import { action } from '@storybook/addon-actions';
2021-08-18 20:08:14 +00:00
import enMessages from '../../_locales/en/messages.json';
import type { PropsType } from './Preferences';
import { Preferences } from './Preferences';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../util/setupI18n';
2021-08-18 20:08:14 +00:00
import { DEFAULT_CONVERSATION_COLOR } from '../types/Colors';
import { PhoneNumberSharingMode } from '../util/phoneNumberSharingMode';
import { PhoneNumberDiscoverability } from '../util/phoneNumberDiscoverability';
2022-11-16 20:18:02 +00:00
import { DurationInSeconds } from '../util/durations';
2021-08-18 20:08:14 +00:00
const i18n = setupI18n('en', enMessages);
const availableMicrophones = [
{
name: 'DefAuLt (Headphones)',
index: 0,
uniqueId: 'Default',
i18nKey: 'default_communication_device',
},
];
const availableSpeakers = [
{
name: 'Default',
index: 0,
uniqueId: 'Default',
i18nKey: 'default_communication_device',
},
{
name: "Natalie's Airpods (Bluetooth)",
index: 1,
uniqueId: 'aa',
},
{
name: 'UE Boom (Bluetooth)',
index: 2,
uniqueId: 'bb',
},
];
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Preferences',
2022-07-20 00:47:05 +00:00
component: Preferences,
args: {
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)',
},
],
2023-11-06 21:19:23 +00:00
availableLocales: ['en'],
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,
isHideMenuBarSupported: true,
isNotificationAttentionSupported: true,
isPhoneNumberSharingSupported: true,
isSyncSupported: true,
isSystemTraySupported: true,
isMinimizeToAndStartInSystemTraySupported: true,
lastSyncTime: Date.now(),
2023-11-06 21:19:23 +00:00
localeOverride: null,
notificationContent: 'name',
2023-11-06 21:19:23 +00:00
preferredSystemLocales: ['en'],
resolvedLocale: 'en',
selectedCamera:
'dfbe6effe70b0611ba0fdc2a9ea3f39f6cb110e6687948f7e5f016c111b7329c',
selectedMicrophone: availableMicrophones[0],
selectedSpeaker: availableSpeakers[1],
sentMediaQualitySetting: 'standard',
themeSetting: 'system',
universalExpireTimer: DurationInSeconds.HOUR,
whoCanFindMe: PhoneNumberDiscoverability.Discoverable,
whoCanSeeMe: PhoneNumberSharingMode.Everybody,
zoomFactor: 1,
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'
),
2023-11-06 21:19:23 +00:00
onLocaleChange: action('onLocaleChange'),
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>;
2021-08-18 20:08:14 +00:00
2022-11-18 00:45:19 +00:00
// eslint-disable-next-line react/function-component-definition
const Template: StoryFn<PropsType> = args => <Preferences {...args} />;
2021-08-18 20:08:14 +00:00
2022-07-20 00:47:05 +00:00
export const _Preferences = Template.bind({});
2021-08-18 20:08:14 +00:00
2022-07-20 00:47:05 +00:00
export const Blocked1 = Template.bind({});
Blocked1.args = {
blockedCount: 1,
};
2021-08-18 20:08:14 +00:00
2022-07-20 00:47:05 +00:00
export const BlockedMany = Template.bind({});
BlockedMany.args = {
blockedCount: 55,
};
2022-06-07 00:48:02 +00:00
2022-07-20 00:47:05 +00:00
export const CustomUniversalExpireTimer = Template.bind({});
CustomUniversalExpireTimer.args = {
2022-11-16 20:18:02 +00:00
universalExpireTimer: DurationInSeconds.fromSeconds(9000),
2022-07-20 00:47:05 +00:00
};
2023-02-23 21:32:19 +00:00
export const PNPSharingDisabled = Template.bind({});
PNPSharingDisabled.args = {
whoCanSeeMe: PhoneNumberSharingMode.Nobody,
whoCanFindMe: PhoneNumberDiscoverability.Discoverable,
isPhoneNumberSharingSupported: true,
};
export const PNPDiscoverabilityDisabled = Template.bind({});
PNPDiscoverabilityDisabled.args = {
whoCanSeeMe: PhoneNumberSharingMode.Nobody,
whoCanFindMe: PhoneNumberDiscoverability.NotDiscoverable,
isPhoneNumberSharingSupported: true,
};