-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
View history of roles in teams-committees-councils page (#9122)
* View history of roles in teams-committees-councils page * Removed metadata file
- Loading branch information
1 parent
a82e94c
commit f6fe426
Showing
6 changed files
with
66 additions
and
41 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
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<% provide(:title, t("page.teams_committees_councils.title")) %> | ||
|
||
<%= react_component('TeamsCommitteesCouncils') %> | ||
<%= react_component('TeamsCommitteesCouncils', { | ||
canViewPastRoles: current_user&.staff? | ||
}) %> |
57 changes: 20 additions & 37 deletions
57
app/webpacker/components/TeamsCommitteesCouncils/GroupPage.jsx
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 |
---|---|---|
@@ -1,56 +1,39 @@ | ||
import React from 'react'; | ||
import { Table } from 'semantic-ui-react'; | ||
import { Header } from 'semantic-ui-react'; | ||
import EmailButton from '../EmailButton'; | ||
import { apiV0Urls } from '../../lib/requests/routes.js.erb'; | ||
import I18n from '../../lib/i18n'; | ||
import useLoadedData from '../../lib/hooks/useLoadedData'; | ||
import Loading from '../Requests/Loading'; | ||
import Errored from '../Requests/Errored'; | ||
import UserBadge from '../UserBadge'; | ||
import RolesTable from './RolesTable'; | ||
|
||
export default function GroupPage({ group }) { | ||
export default function GroupPage({ group, canViewPastRoles }) { | ||
const { | ||
data: groupMembers, | ||
loading: groupMembersLoading, | ||
error: groupMembersError, | ||
data: activeRoles, | ||
loading: activeRolesLoading, | ||
error: activeRolesError, | ||
} = useLoadedData(apiV0Urls.userRoles.listOfGroup(group.id, 'status,name', { isActive: true })); | ||
const { | ||
data: pastRoles, | ||
loading: pastRolesLoading, | ||
error: pastRolesError, | ||
} = useLoadedData(apiV0Urls.userRoles.listOfGroup(group.id, 'status,name', { isActive: false })); | ||
|
||
if (groupMembersLoading) return <Loading />; | ||
if (groupMembersError) return <Errored />; | ||
if (activeRolesLoading || pastRolesLoading) return <Loading />; | ||
if (activeRolesError || pastRolesError) return <Errored />; | ||
|
||
return ( | ||
<> | ||
<p>{I18n.t(`page.teams_committees_councils.groups_description.${group.metadata.friendly_id}`)}</p> | ||
<EmailButton email={group.metadata.email} /> | ||
<Table unstackable> | ||
<Table.Header> | ||
<Table.Row> | ||
<Table.HeaderCell> | ||
{I18n.t('delegates_page.table.name')} | ||
</Table.HeaderCell> | ||
<Table.HeaderCell> | ||
{I18n.t('delegates_page.table.role')} | ||
</Table.HeaderCell> | ||
</Table.Row> | ||
</Table.Header> | ||
|
||
<Table.Body> | ||
{groupMembers.map((groupMember) => ( | ||
<Table.Row key={groupMember.user.id}> | ||
<Table.Cell> | ||
<UserBadge | ||
user={groupMember.user} | ||
hideBorder | ||
leftAlign | ||
/> | ||
</Table.Cell> | ||
<Table.Cell> | ||
{I18n.t(`enums.user_roles.status.${groupMember.group.group_type}.${groupMember.metadata.status}`)} | ||
</Table.Cell> | ||
</Table.Row> | ||
))} | ||
</Table.Body> | ||
</Table> | ||
<RolesTable roleList={activeRoles} /> | ||
{canViewPastRoles && ( | ||
<> | ||
<Header>Past Roles</Header> | ||
<RolesTable roleList={pastRoles} /> | ||
</> | ||
)} | ||
</> | ||
); | ||
} |
39 changes: 39 additions & 0 deletions
39
app/webpacker/components/TeamsCommitteesCouncils/RolesTable.jsx
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,39 @@ | ||
import React from 'react'; | ||
import { Table } from 'semantic-ui-react'; | ||
import I18n from '../../lib/i18n'; | ||
import UserBadge from '../UserBadge'; | ||
|
||
export default function RolesTable({ roleList }) { | ||
return ( | ||
<Table unstackable> | ||
<Table.Header> | ||
<Table.Row> | ||
<Table.HeaderCell> | ||
{I18n.t('delegates_page.table.name')} | ||
</Table.HeaderCell> | ||
<Table.HeaderCell> | ||
{I18n.t('delegates_page.table.role')} | ||
</Table.HeaderCell> | ||
</Table.Row> | ||
</Table.Header> | ||
|
||
<Table.Body> | ||
{roleList.map((role) => ( | ||
<Table.Row key={role.user.id}> | ||
<Table.Cell> | ||
<UserBadge | ||
user={role.user} | ||
hideBorder | ||
leftAlign | ||
subtexts={[role.end_date ? `${role.start_date} - ${role.end_date}` : '']} | ||
/> | ||
</Table.Cell> | ||
<Table.Cell> | ||
{I18n.t(`enums.user_roles.status.${role.group.group_type}.${role.metadata.status}`)} | ||
</Table.Cell> | ||
</Table.Row> | ||
))} | ||
</Table.Body> | ||
</Table> | ||
); | ||
} |
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