From 96ccc666411738efa6bc1315b22437ff8138017c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 2 Apr 2022 13:03:12 -0500 Subject: [PATCH] Convert DropdownMenu to typescript --- .../{dropdown_menu.js => dropdown_menu.tsx} | Bin 9046 -> 10841 bytes app/soapbox/components/status_action_bar.tsx | 15 +++---- .../components/ui/icon-button/icon-button.tsx | 7 +--- .../containers/dropdown_menu_container.js | Bin 1099 -> 0 bytes .../containers/dropdown_menu_container.ts | 38 ++++++++++++++++++ 5 files changed, 45 insertions(+), 15 deletions(-) rename app/soapbox/components/{dropdown_menu.js => dropdown_menu.tsx} (56%) delete mode 100644 app/soapbox/containers/dropdown_menu_container.js create mode 100644 app/soapbox/containers/dropdown_menu_container.ts diff --git a/app/soapbox/components/dropdown_menu.js b/app/soapbox/components/dropdown_menu.tsx similarity index 56% rename from app/soapbox/components/dropdown_menu.js rename to app/soapbox/components/dropdown_menu.tsx index c471ac27b85fdcc1fdc3c4cd3a9071457a59c373..7d13d6829f105f2d8b8201a67cbdbb7bdef3732d 100644 GIT binary patch literal 10841 zcmd5?ZEqX75&oWE!9#<4z*Y<->a+<^`;x>tc*w^0SP$ZO=vKCqG3j1QmRrKHc z%nZ3C*OH?EMbUh4*5q(FoHx!qbh=s>Wv%9!uBx|sWh%8OiwxlI}`zdfS+=T{ToUKMtQLohM4qFsPOqKdvrS zViswh62r)hbJ?+T^CZV7`@_ z?(vqVU~OGwtm?8cIM!G#bXJ+49%ZIhX@a#UP?!14zM1Aw_Cn8%dSmkDyf!Pfd88B^ z2=b5Bdvc{AyW%TYJu~G*hW>8uW`!;jo>E^d;hUnV#Bomt;Ic{+EP0Wo^G{D7;MG}G zo6q%FRW#DHmoqu!X1 zaNBB!jYW!q(w>#2zMHgK`l9kC%TCGhS{0t3!Aq0kHs>WchRKs^rz4Y&Qz*L{v))PM zB7cz;6#}q-q^76prbrVSuIjstq!YEjxV)rDFeSMMO|LW9ZUu({iQE018zTZ;mc{MG zVo{m;w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0Q!~`WNF{qpSZf+i|U2l(%rcwr%;wsv$qDYc?H_n;6EicQ71tT7u(h21v z(<#>Gx1u`w6yca?VHL;2jx`ur`#l0tVYEKyHEv6`yh0(^6uMwts4WbI4GaSXb7cdI zm?x)*!4ZYZqHsoB@pwd$afxGDw9;^j=`+to^Mg4`v0iaI|Bytfln!Awg>D*{BBjfg z5p75%47r5~LzDOD7*DG^R2dS#fn@GP(N#%CDWq|C9LB9aI0Ex>vN(}QFvQ1D;xMup z(f12Rbflp{Wg1JDQ94c}s<@SLLR9C{Bxan@wA+|ZdNl$MLam1%k0`8QC;d^PM7>RxT;tGs;ma`u` z?+ak#*a9Rgrr~czHSnrhsHyy6@1IuH*!wqCk4=piHml0vdG%0Xmxw#F%{8}$Bf&F4 zSU>)&P%~5&9(lv|BKz4pbHrKoH1r5fXvv;21tlay<)V8iUiwZSI21C`-0g5b5u@^c zrbEsW!2Nh_FHl;&JB7Kx#JV2cjJ zq+l=3A&O)|w;;gmDnm3z3^{2|th);q3r_x+jT1#uC(PM%3#_~Hutc}1+O7L9R0qQc z{^rI^o?&vy-^X60a1I9l2l%0Z%CN#X<_Qn9??u07wJ!;se1 z(p$Y6u?R{^nxY~*T(559?KAr$EJ+Qd2fabhquY!(a8 z0?QC>orU$bHu%_j)Lc)3r=kLA+l(7M!2@Bx4_=*o0PiXr%FVx?m_+9tdLN$pQ^@c# fg0=Qb*`Mum0t|NeJl09yiuIkH?3fbZN$1^vnw1>= diff --git a/app/soapbox/components/status_action_bar.tsx b/app/soapbox/components/status_action_bar.tsx index b98f017a95..558d96bb78 100644 --- a/app/soapbox/components/status_action_bar.tsx +++ b/app/soapbox/components/status_action_bar.tsx @@ -24,6 +24,7 @@ import { IconButton, Hoverable } from './ui'; import type { History } from 'history'; import type { AnyAction, Dispatch } from 'redux'; +import type { Menu } from 'soapbox/components/dropdown_menu'; import type { RootState } from 'soapbox/store'; import type { Status } from 'soapbox/types/entities'; import type { Features } from 'soapbox/utils/features'; @@ -367,7 +368,7 @@ class StatusActionBar extends ImmutablePureComponent event.stopPropagation(), + action: (event) => event.stopPropagation(), }); menu.push({ text: intl.formatMessage(messages.admin_status), href: `/pleroma/admin/#/statuses/${status.get('id')}/`, icon: require('@tabler/icons/icons/pencil.svg'), - action: (event: Event) => event.stopPropagation(), + action: (event) => event.stopPropagation(), }); } @@ -607,13 +608,11 @@ class StatusActionBar extends ImmutablePureComponent ); @@ -714,11 +713,9 @@ class StatusActionBar extends ImmutablePureComponent diff --git a/app/soapbox/components/ui/icon-button/icon-button.tsx b/app/soapbox/components/ui/icon-button/icon-button.tsx index 2d8c27b7f3..291b0b4f8a 100644 --- a/app/soapbox/components/ui/icon-button/icon-button.tsx +++ b/app/soapbox/components/ui/icon-button/icon-button.tsx @@ -4,15 +4,10 @@ import InlineSVG from 'react-inlinesvg'; import Text from '../text/text'; -interface IIconButton { - alt?: string, - className?: string, +interface IIconButton extends React.ButtonHTMLAttributes { iconClassName?: string, - disabled?: boolean, src: string, - onClick?: React.EventHandler, text?: string, - title?: string, transparent?: boolean } diff --git a/app/soapbox/containers/dropdown_menu_container.js b/app/soapbox/containers/dropdown_menu_container.js deleted file mode 100644 index 57f4d5468b54fda0ac24c31f8a863bf248c556f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1099 zcmah}O>f&U487-9@Kj5H=H63eL)Tu6q8~uhU524hCAJl6i-skmU&wzSrPzs+469GJ z#P|64NZK_mbrC+nkoRaJtl+Vu28s@~iQhW3{abM|o4GNLTJ+}~wU%D}CHh{0sVU&} zXv0yK$4uhLhhsZH?i?<$-_V1rF_p}Ygb0mpZ=;U5q#G_Fzyd=0gvECdpECd#vf^vDWez`yYSdoj zkn#zmC;A^+AD)*aTR~jn(9n%feX& ({ + isModalOpen: Boolean(state.modals.size && state.modals.last().modalType === 'ACTIONS'), + dropdownPlacement: state.dropdown_menu.get('placement'), + openDropdownId: state.dropdown_menu.get('openId'), + openedViaKeyboard: state.dropdown_menu.get('keyboard'), +}); + +const mapDispatchToProps = (dispatch: Dispatch, { status, items }: Partial) => ({ + onOpen( + id: number, + onItemClick: React.EventHandler, + dropdownPlacement: DropdownPlacement, + keyboard: boolean, + ) { + dispatch(isUserTouching() ? openModal('ACTIONS', { + status, + actions: items, + onClick: onItemClick, + }) : openDropdownMenu(id, dropdownPlacement, keyboard)); + }, + onClose(id: number) { + dispatch(closeModal('ACTIONS')); + dispatch(closeDropdownMenu(id)); + }, +}); + +export default connect(mapStateToProps, mapDispatchToProps)(DropdownMenu);