Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 2dc7cb3

Browse files
authored
Merge pull request #4956 from withspectrum/unified-sidebar
Unified community sidebar
2 parents e162f9e + 3ae8899 commit 2dc7cb3

File tree

24 files changed

+263
-537
lines changed

24 files changed

+263
-537
lines changed

cypress/integration/channel/settings/edit_spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ describe('edit a channel', () => {
4040
.click();
4141

4242
cy.visit(`/${community.slug}/${channel.slug}`);
43-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
44-
cy.get('[data-cy="channel-profile-card"]').contains(NEW_NAME);
45-
cy.get('[data-cy="channel-profile-card"]').contains(NEW_DESCRIPTION);
43+
cy.contains(NEW_NAME);
4644
});
4745
});

cypress/integration/channel/view/membership_spec.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ const community = data.communities.find(
88
community => community.id === publicChannel.communityId
99
);
1010

11-
const { userId: ownerInChannelId } = data.usersChannels.find(
12-
({ channelId, isOwner }) => channelId === publicChannel.id && isOwner
13-
);
14-
1511
const { userId: memberInChannelId } = data.usersChannels.find(
1612
({ channelId, isMember, isOwner }) =>
1713
channelId === publicChannel.id && isMember && !isOwner
@@ -33,14 +29,14 @@ const leave = () => {
3329
.last()
3430
.click();
3531

36-
cy.get('[data-cy="channel-join-button"]').contains(`Join channel`);
32+
cy.get('[data-cy="channel-join-button"]').contains(`Join`);
3733
};
3834

3935
const join = () => {
4036
cy.get('[data-cy="channel-join-button"]')
4137
.last()
4238
.should('be.visible')
43-
.contains('Join channel');
39+
.contains('Join');
4440

4541
cy.get('[data-cy="channel-join-button"]')
4642
.last()
@@ -54,8 +50,8 @@ describe('logged out channel membership', () => {
5450
cy.visit(`/${community.slug}/${publicChannel.slug}`);
5551
});
5652

57-
it('should render join button that links to login view', () => {
58-
cy.get('[data-cy="channel-login-join-button"]').should('be.visible');
53+
it('should render community join button that links to login view', () => {
54+
cy.get('[data-cy="profile-join-button"]').should('be.visible');
5955
});
6056
});
6157

@@ -79,23 +75,8 @@ describe('channel profile as non-member', () => {
7975
);
8076
});
8177

82-
it('should render join channel button', () => {
83-
join();
84-
leave();
85-
});
86-
});
87-
88-
describe('channel profile as owner', () => {
89-
beforeEach(() => {
90-
cy.auth(ownerInChannelId).then(() =>
91-
cy.visit(`/${community.slug}/${publicChannel.slug}`)
92-
);
93-
});
94-
95-
it('should render settings button', () => {
96-
cy.get('[data-cy="channel-settings-button"]')
97-
.should('be.visible')
98-
.contains('Settings');
78+
it('should render join community button', () => {
79+
cy.get('[data-cy="profile-join-button"]').should('be.visible');
9980
});
10081
});
10182

cypress/integration/channel/view/notifications_spec.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ describe('channel notification preferences logged out', () => {
1919
it('should not render notifications settings', () => {
2020
cy.get('[data-cy="channel-view"]').should('be.visible');
2121

22-
cy.get('[data-cy="notifications-checkbox"]').should('not.be.visible');
22+
cy.get('[data-cy="channel-notifications-muted"]').should('not.be.visible');
23+
cy.get('[data-cy="channel-notifications-enabled"]').should(
24+
'not.be.visible'
25+
);
2326
});
2427
});
2528

@@ -33,13 +36,21 @@ describe('channel notification preferences as member', () => {
3336
it('should render notification settings', () => {
3437
cy.get('[data-cy="channel-view"]').should('be.visible');
3538

36-
cy.get('[data-cy="notifications-checkbox-checked"]')
37-
.should('be.visible')
38-
.click();
39+
cy.get('[data-cy="channel-notifications-enabled"]').should($p => {
40+
expect($p).to.have.length(2);
41+
});
3942

40-
cy.get('[data-cy="notifications-checkbox-unchecked"]')
41-
.should('be.visible')
43+
cy.get('[data-cy="channel-notifications-enabled"]')
44+
.first()
4245
.click();
46+
47+
cy.get('[data-cy="channel-notifications-enabled"]').should($p => {
48+
expect($p).to.have.length(1);
49+
});
50+
51+
cy.get('[data-cy="channel-notifications-muted"]').should($p => {
52+
expect($p).to.have.length(1);
53+
});
4354
});
4455
});
4556

@@ -53,7 +64,8 @@ describe('channel profile as non-member', () => {
5364
it('should not render notifications settings', () => {
5465
cy.get('[data-cy="channel-view"]').should('be.visible');
5566

56-
cy.get('[data-cy="notifications-checkbox-checked"]').should(
67+
cy.get('[data-cy="channel-notifications-muted"]').should('not.be.visible');
68+
cy.get('[data-cy="channel-notifications-enabled"]').should(
5769
'not.be.visible'
5870
);
5971
});

cypress/integration/channel/view/profile_spec.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ describe('public channel', () => {
3939
it('should render profile', () => {
4040
cy.get('[data-cy="channel-view"]').should('be.visible');
4141
});
42-
43-
it('should contain channel metadata', () => {
44-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
45-
cy.contains(community.name);
46-
cy.contains(publicChannel.description);
47-
cy.contains(publicChannel.name);
48-
});
4942
});
5043

5144
describe('public channel in private community signed out', () => {
@@ -96,11 +89,6 @@ describe('archived channel', () => {
9689
it('should render profile', () => {
9790
cy.get('[data-cy="channel-view"]').should('be.visible');
9891
});
99-
100-
it('should contain archived tag', () => {
101-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
102-
cy.contains('Archived');
103-
});
10492
});
10593

10694
describe('deleted channel', () => {

cypress/integration/thread/view_spec.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ describe('sidebar components on thread view', () => {
4848

4949
// loaded join button which directs to login
5050
cy.get('[data-cy="profile-join-button"]').should('be.visible');
51-
52-
// loaded more conversations component
53-
cy.get('[data-cy="trending-conversations"]')
54-
.scrollIntoView()
55-
.should('be.visible');
5651
});
5752
});
5853

@@ -73,11 +68,6 @@ describe('sidebar components on thread view', () => {
7368
cy.get('[data-cy="profile-join-button"]')
7469
.scrollIntoView()
7570
.should('be.visible');
76-
77-
// loaded more conversations component
78-
cy.get('[data-cy="trending-conversations"]')
79-
.scrollIntoView()
80-
.should('be.visible');
8171
});
8272
});
8373

@@ -98,11 +88,6 @@ describe('sidebar components on thread view', () => {
9888
cy.get('[data-cy="community-profile-card"]')
9989
.scrollIntoView()
10090
.should('be.visible');
101-
102-
// loaded more conversations component
103-
cy.get('[data-cy="trending-conversations"]')
104-
.scrollIntoView()
105-
.should('be.visible');
10691
});
10792
});
10893
});

cypress/integration/user/new_user_spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ describe('post username creation redirects', () => {
9898
setUsernameIsVisible();
9999
saveUsername();
100100
cy.url().should('include', '/spectrum/general');
101-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
102101
});
103102

104103
it('should redirect to previously viewed page 3', () => {
@@ -130,7 +129,6 @@ describe('post username creation redirects', () => {
130129
setUsernameIsVisible();
131130
saveUsername();
132131
cy.url().should('include', '/payments/private');
133-
cy.get('[data-cy="channel-profile-card"]').should('be.visible');
134132
});
135133

136134
it('should take user to explore if no previously viewed page', () => {

cypress/integration/user_spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ const publicAuthoredThreads = threads.filter(thread => {
1414
});
1515

1616
describe('User View', () => {
17-
beforeEach(() => {
18-
cy.visit(`/users/${user.username}`);
19-
});
20-
2117
it('should render', () => {
18+
cy.visit(`/users/${user.username}`);
2219
cy.get('[data-cy="user-view"]').should('be.visible');
2320
cy.contains(user.username);
2421
cy.contains(user.name);
@@ -31,6 +28,8 @@ describe('User View', () => {
3128
});
3229

3330
it('should list the public communities a user is a member of, including their rep in that community', () => {
31+
cy.visit(`/users/${user.username}`);
32+
cy.get('[data-cy="user-view"]').should('be.visible');
3433
const usersCommunities = data.usersCommunities.filter(
3534
({ userId }) => userId === user.id
3635
);

shared/graphql/fragments/channel/channelInfo.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// @flow
22
import gql from 'graphql-tag';
33
import communityInfoFragment from '../community/communityInfo';
4+
import communityMetaFragment from '../community/communityMetaData';
45
import type { CommunityInfoType } from '../community/communityInfo';
6+
import type { CommunityMetaDataType } from '../community/communityMetaData';
57

68
export type ChannelInfoType = {
79
id: string,
@@ -21,6 +23,7 @@ export type ChannelInfoType = {
2123
},
2224
community: {
2325
...$Exact<CommunityInfoType>,
26+
...$Exact<CommunityMetaDataType>,
2427
},
2528
};
2629

@@ -43,7 +46,9 @@ export default gql`
4346
}
4447
community {
4548
...communityInfo
49+
...communityMetaData
4650
}
4751
}
4852
${communityInfoFragment}
53+
${communityMetaFragment}
4954
`;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// @flow
2+
import React from 'react';
3+
import { SidebarSection } from 'src/views/community/style';
4+
import { TeamMembersList } from 'src/views/community/components/teamMembersList';
5+
import { ChannelsList } from 'src/views/community/components/channelsList';
6+
import { CommunityProfileCard } from 'src/components/entities';
7+
import { ErrorBoundary } from 'src/components/error';
8+
9+
type Props = {
10+
community: Object,
11+
};
12+
13+
export default ({ community }: Props) => (
14+
<React.Fragment>
15+
<SidebarSection>
16+
<CommunityProfileCard community={community} />
17+
</SidebarSection>
18+
19+
<ErrorBoundary>
20+
<SidebarSection>
21+
<ChannelsList id={community.id} communitySlug={community.slug} />
22+
</SidebarSection>
23+
</ErrorBoundary>
24+
25+
<ErrorBoundary>
26+
<SidebarSection>
27+
<TeamMembersList
28+
community={community}
29+
id={community.id}
30+
first={100}
31+
filter={{ isModerator: true, isOwner: true }}
32+
/>
33+
</SidebarSection>
34+
</ErrorBoundary>
35+
</React.Fragment>
36+
);

src/components/entities/listItems/channel.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ type Props = {
2020
description?: ?string,
2121
currentUser: ?Object,
2222
children?: React$Node,
23+
isActive?: boolean,
2324
};
2425

2526
const Channel = (props: Props) => {
26-
const { channel, name, description, children, currentUser } = props;
27+
const {
28+
channel,
29+
name,
30+
description,
31+
children,
32+
currentUser,
33+
isActive = false,
34+
} = props;
2735
const [isHoveringNotifications, setIsHoveringNotifications] = useState(false);
2836
if (!channel) return null;
2937

@@ -116,7 +124,7 @@ const Channel = (props: Props) => {
116124
return (
117125
<ErrorBoundary>
118126
<Link to={`/${channel.community.slug}/${channel.slug}`}>
119-
<Row>
127+
<Row isActive={isActive}>
120128
<Content>
121129
{name && (
122130
<Label title={name}>

0 commit comments

Comments
 (0)