Use standard Tabs component for PendingInvites

This commit is contained in:
Josh Perez 2023-05-04 22:48:48 -04:00
parent ed539c31b8
commit f69c533d23
3 changed files with 49 additions and 87 deletions

View file

@ -118,24 +118,8 @@
} }
&__tabs { &__tabs {
display: flex; &#{&} {
justify-content: space-around; border-bottom: none;
}
&__tab {
@include font-body-1;
cursor: pointer;
padding: 15px;
&:focus {
@include mouse-mode {
outline: none;
}
}
&--selected {
@include font-body-1-bold;
border-bottom: 2px solid $color-black;
} }
} }

View file

@ -2,7 +2,6 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import React from 'react'; import React from 'react';
import classNames from 'classnames';
import _ from 'lodash'; import _ from 'lodash';
import type { ConversationType } from '../../../state/ducks/conversations'; import type { ConversationType } from '../../../state/ducks/conversations';
@ -15,6 +14,7 @@ import { PanelSection } from './PanelSection';
import { PanelRow } from './PanelRow'; import { PanelRow } from './PanelRow';
import { ConversationDetailsIcon, IconType } from './ConversationDetailsIcon'; import { ConversationDetailsIcon, IconType } from './ConversationDetailsIcon';
import { isAccessControlEnabled } from '../../../groups/util'; import { isAccessControlEnabled } from '../../../groups/util';
import { Tabs } from '../../Tabs';
import { assertDev } from '../../../util/assert'; import { assertDev } from '../../../util/assert';
export type PropsDataType = { export type PropsDataType = {
@ -84,56 +84,31 @@ export function PendingInvites({
); );
} }
const [selectedTab, setSelectedTab] = React.useState(Tab.Requests);
const [stagedMemberships, setStagedMemberships] = const [stagedMemberships, setStagedMemberships] =
React.useState<Array<StagedMembershipType> | null>(null); React.useState<Array<StagedMembershipType> | null>(null);
return ( return (
<div className="conversation-details-panel"> <div className="conversation-details-panel">
<div className="ConversationDetails__tabs"> <Tabs
<div moduleClassName="ConversationDetails__tabs"
className={classNames({ initialSelectedTab={Tab.Requests}
ConversationDetails__tab: true, tabs={[
'ConversationDetails__tab--selected': selectedTab === Tab.Requests, {
})} id: Tab.Requests,
onClick={() => { label: i18n('icu:PendingInvites--tab-requests', {
setSelectedTab(Tab.Requests);
}}
onKeyUp={(e: React.KeyboardEvent) => {
if (e.target === e.currentTarget && e.keyCode === 13) {
setSelectedTab(Tab.Requests);
}
}}
role="tab"
tabIndex={0}
>
{i18n('icu:PendingInvites--tab-requests', {
count: pendingApprovalMemberships.length, count: pendingApprovalMemberships.length,
})} }),
</div> },
{
<div id: Tab.Pending,
className={classNames({ label: i18n('icu:PendingInvites--tab-invites', {
ConversationDetails__tab: true,
'ConversationDetails__tab--selected': selectedTab === Tab.Pending,
})}
onClick={() => {
setSelectedTab(Tab.Pending);
}}
onKeyUp={(e: React.KeyboardEvent) => {
if (e.target === e.currentTarget && e.keyCode === 13) {
setSelectedTab(Tab.Pending);
}
}}
role="tab"
tabIndex={0}
>
{i18n('icu:PendingInvites--tab-invites', {
count: pendingMemberships.length, count: pendingMemberships.length,
})} }),
</div> },
</div> ]}
>
{({ selectedTab }) => (
<>
{selectedTab === Tab.Requests ? ( {selectedTab === Tab.Requests ? (
<MembersPendingAdminApproval <MembersPendingAdminApproval
conversation={conversation} conversation={conversation}
@ -156,6 +131,9 @@ export function PendingInvites({
theme={theme} theme={theme}
/> />
) : null} ) : null}
</>
)}
</Tabs>
{stagedMemberships && stagedMemberships.length && ( {stagedMemberships && stagedMemberships.length && (
<MembershipActionConfirmation <MembershipActionConfirmation

View file

@ -216,7 +216,7 @@ describe('pnp/accept gv2 invite', function needsName() {
) )
.click(); .click();
await conversationStack await conversationStack
.locator('.ConversationDetails__tab >> text=Invites (1)') .locator('.ConversationDetails__tabs__tab >> text=Invites (1)')
.click(); .click();
await conversationStack await conversationStack
.locator( .locator(