-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #583 from Real-Dev-Squad/feature/sidebar
[Live-Site] - Sidebar peers map according to roles
- Loading branch information
Showing
8 changed files
with
286 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<div data-test-sidebar-body-role class='body__role-user'> | ||
<p | ||
data-test-sidebar-body-role-guest | ||
class='role-user__type guestUsers' | ||
>{{@user}}</p> | ||
<ul> | ||
|
||
{{#if (not-eq @minimumParticipants @role)}} | ||
<li data-test-sidebar-user={{'peer.id'}} class='user'> | ||
<p>No {{@user}} in the stream</p> | ||
</li> | ||
{{else}} | ||
|
||
{{#each @peers as |peer|}} | ||
{{#if (eq peer.roleName @role)}} | ||
<li data-test-sidebar-user={{peer.id}} class='user'> | ||
<p>{{peer.name}}</p> | ||
{{#if | ||
(or | ||
(eq this.liveService.localPeer.roleName this.ROLES.host) | ||
(eq this.liveService.localPeer.roleName this.ROLES.moderator) | ||
) | ||
}} | ||
<button | ||
type='button' | ||
class='user__btn' | ||
{{on 'click' (fn @openKickoutModal peer)}} | ||
> | ||
<IconifyIcon | ||
data-test-icon='remove' | ||
@icon='material-symbols:person-remove' | ||
width='36' | ||
height='36' | ||
color='red' | ||
/> | ||
</button> | ||
{{/if}} | ||
</li> | ||
{{/if}} | ||
{{/each}} | ||
{{/if}} | ||
|
||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Component from '@glimmer/component'; | ||
import { ROLES } from '../constants/live'; | ||
import { getOwner } from '@ember/application'; | ||
|
||
export default class LiveParticipantsComponent extends Component { | ||
ROLES = ROLES; | ||
|
||
get liveService() { | ||
return getOwner(this).lookup('service:live'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
export const hostPeer = [ | ||
{ | ||
id: 1, | ||
name: 'Ankush', | ||
roleName: 'host', | ||
}, | ||
]; | ||
|
||
export const mavenPeerData = [ | ||
{ | ||
id: 1, | ||
name: 'Ankush', | ||
roleName: 'host', | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Maven1', | ||
roleName: 'maven', | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Maven2', | ||
roleName: 'maven', | ||
}, | ||
]; | ||
|
||
export const moderatorData = [ | ||
{ | ||
id: 1, | ||
name: 'Ankush', | ||
roleName: 'host', | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Mod1', | ||
roleName: 'moderator', | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Mod3', | ||
roleName: 'moderator', | ||
}, | ||
]; | ||
|
||
export const guestData = [ | ||
{ | ||
id: 1, | ||
name: 'Ankush', | ||
roleName: 'host', | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Guest1', | ||
roleName: 'guest', | ||
}, | ||
{ | ||
id: 3, | ||
name: 'Guest2', | ||
roleName: 'guest', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'website-www/tests/helpers'; | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { | ||
hostPeer, | ||
mavenPeerData, | ||
moderatorData, | ||
guestData, | ||
} from '../../constants/participants-data'; | ||
|
||
module('Integration | Component | live-participants', function (hooks) { | ||
setupRenderingTest(hooks); | ||
test('renders No Maven In the stream Text', async function (assert) { | ||
this.setProperties({ | ||
peers: hostPeer, | ||
profilePic: 'profilepicurl', | ||
isKickoutModalOpen: true, | ||
}); | ||
this.set('openKickoutModal', () => { | ||
this.isKickoutModalOpen = true; | ||
}); | ||
await render(hbs`<LiveParticipants | ||
@user='Mavens' | ||
@role='maven' | ||
@peers={{this.peers}} | ||
@minimumParticipants="" | ||
@openKickoutModal={{this.openKickoutModal}} | ||
/>`); | ||
assert | ||
.dom('[data-test-sidebar-body-role] .user') | ||
.hasText('No Mavens in the stream'); | ||
}); | ||
|
||
test('renders No Moderators In the stream Text', async function (assert) { | ||
this.setProperties({ | ||
peers: hostPeer, | ||
profilePic: 'profilepicurl', | ||
isKickoutModalOpen: true, | ||
}); | ||
this.set('openKickoutModal', () => { | ||
this.isKickoutModalOpen = true; | ||
}); | ||
await render(hbs` <LiveParticipants | ||
@user='Moderators' | ||
@role='moderator' | ||
@peers={{this.peers}} | ||
@minimumParticipants="" | ||
@openKickoutModal={{this.openKickoutModal}} | ||
/>`); | ||
assert | ||
.dom('[data-test-sidebar-body-role] .user') | ||
.hasText('No Moderators in the stream'); | ||
}); | ||
|
||
test('renders No Guests In the stream Text', async function (assert) { | ||
this.setProperties({ | ||
peers: hostPeer, | ||
profilePic: 'profilepicurl', | ||
isKickoutModalOpen: true, | ||
}); | ||
this.set('openKickoutModal', () => { | ||
this.isKickoutModalOpen = true; | ||
}); | ||
await render(hbs` <LiveParticipants | ||
@user='Guests' | ||
@role='guest' | ||
@peers={{@peers}} | ||
@minimumParticipants="" | ||
@openKickoutModal={{this.openKickoutModal}} | ||
/>`); | ||
assert | ||
.dom('[data-test-sidebar-body-role] .user') | ||
.hasText('No Guests in the stream'); | ||
}); | ||
|
||
test('renders Mavens Lists who joined Stream', async function (assert) { | ||
this.setProperties({ | ||
peers: mavenPeerData, | ||
profilePic: 'profilepicurl', | ||
isKickoutModalOpen: true, | ||
}); | ||
this.set('openKickoutModal', () => { | ||
this.isKickoutModalOpen = true; | ||
}); | ||
await render(hbs`<LiveParticipants | ||
@user='Mavens' | ||
@role='maven' | ||
@peers={{this.peers}} | ||
@minimumParticipants="maven" | ||
@openKickoutModal={{this.openKickoutModal}} | ||
/>`); | ||
assert.dom('[data-test-sidebar-user="2"]').hasText('Maven1'); | ||
}); | ||
|
||
test('renders Moderators Lists who joined Stream', async function (assert) { | ||
this.setProperties({ | ||
peers: moderatorData, | ||
profilePic: 'profilepicurl', | ||
isKickoutModalOpen: true, | ||
}); | ||
this.set('openKickoutModal', () => { | ||
this.isKickoutModalOpen = true; | ||
}); | ||
await render(hbs`<LiveParticipants | ||
@user='Moderator' | ||
@role='moderator' | ||
@peers={{this.peers}} | ||
@minimumParticipants="moderator" | ||
@openKickoutModal={{this.openKickoutModal}} | ||
/>`); | ||
assert.dom('[data-test-sidebar-user="3"]').hasText('Mod3'); | ||
}); | ||
|
||
test('renders Guests Lists who joined Stream', async function (assert) { | ||
this.setProperties({ | ||
peers: guestData, | ||
profilePic: 'profilepicurl', | ||
isKickoutModalOpen: true, | ||
}); | ||
this.set('openKickoutModal', () => { | ||
this.isKickoutModalOpen = true; | ||
}); | ||
await render(hbs`<LiveParticipants | ||
@user='Guest' | ||
@role='guest' | ||
@peers={{this.peers}} | ||
@minimumParticipants="guest" | ||
@openKickoutModal={{this.openKickoutModal}} | ||
/>`); | ||
assert.dom('[data-test-sidebar-user="3"]').hasText('Guest2'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters