From 016ef8af79e6178de0bb7ef81f612c7ffd0c4eaa Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 3 Jun 2021 18:12:23 -0400 Subject: [PATCH] Use the new Select component everywhere --- ts/components/Select.tsx | 4 +- .../GroupLinkManagement.tsx | 63 ++++++++++--------- .../GroupV2Permissions.tsx | 47 +++++--------- ts/util/getAccessControlOptions.ts | 6 +- 4 files changed, 53 insertions(+), 67 deletions(-) diff --git a/ts/components/Select.tsx b/ts/components/Select.tsx index b47578adf3d..7ca39008b4b 100644 --- a/ts/components/Select.tsx +++ b/ts/components/Select.tsx @@ -1,7 +1,7 @@ // Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -import React from 'react'; +import React, { ChangeEvent } from 'react'; import classNames from 'classnames'; export type Option = Readonly<{ @@ -19,7 +19,7 @@ export type PropsType = Readonly<{ export function Select(props: PropsType): JSX.Element { const { moduleClassName, value, options, onChange } = props; - const onSelectChange = (event: React.ChangeEvent) => { + const onSelectChange = (event: ChangeEvent) => { onChange(event.target.value); }; diff --git a/ts/components/conversation/conversation-details/GroupLinkManagement.tsx b/ts/components/conversation/conversation-details/GroupLinkManagement.tsx index de1e65188b2..bb2d07f2383 100644 --- a/ts/components/conversation/conversation-details/GroupLinkManagement.tsx +++ b/ts/components/conversation/conversation-details/GroupLinkManagement.tsx @@ -9,6 +9,7 @@ import { LocalizerType } from '../../../types/Util'; import { PanelRow } from './PanelRow'; import { PanelSection } from './PanelSection'; import { AccessControlClass } from '../../../textsecure.d'; +import { Select } from '../../Select'; export type PropsType = { accessEnum: typeof AccessControlClass.AccessRequired; @@ -36,8 +37,8 @@ export const GroupLinkManagement: React.ComponentType = ({ } const createEventHandler = (handleEvent: (x: boolean) => void) => { - return (event: React.ChangeEvent) => { - handleEvent(event.target.value === 'true'); + return (value: string) => { + handleEvent(value === 'true'); }; }; @@ -57,19 +58,20 @@ export const GroupLinkManagement: React.ComponentType = ({ label={i18n('ConversationDetails--group-link')} right={ isAdmin ? ( -
- -
+ - - - - + - {accessControlOptions.map(({ name, value }) => ( - - ))} - - + - {accessControlOptions.map(({ name, value }) => ( - - ))} - - +