Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Added functionality to archive/unarchive teams from system console #8129

Merged
merged 9 commits into from
Jul 16, 2021
4 changes: 4 additions & 0 deletions actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,10 @@ function handleDeleteTeamEvent(msg) {
{type: TeamTypes.UPDATED_TEAM, data: deletedTeam},
]));

if (browserHistory.location?.pathname === `/admin_console/user_management/teams/${deletedTeam.id}`) {
return;
}

if (newTeamId) {
dispatch({type: TeamTypes.SELECT_TEAM, data: newTeamId});
const globalState = getState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,52 @@ exports[`admin_console/team_channel_settings/team/TeamDetails should match snaps
<div
className="admin-console__content"
>
<RemoveConfirmModal
amount={0}
inChannel={false}
onCancel={[Function]}
onConfirm={[Function]}
show={false}
/>
<TeamProfile
isArchived={false}
onToggleArchive={[Function]}
team={
Object {
"allow_open_invite": false,
"allowed_domains": "",
"delete_at": 0,
"display_name": "team",
"group_constrained": false,
"id": "123",
}
}
/>
<ConfirmModal
confirmButtonClass="btn btn-primary"
confirmButtonText={
<FormattedMessage
defaultMessage="Archive"
id="admin.team_settings.team_detail.archive_confirm.button"
/>
}
message={
<FormattedMessage
defaultMessage="Saving will archive the team and make its contents inaccessible for all users. Are you sure you wish to save and archive this team?"
id="admin.team_settings.team_detail.archive_confirm.message"
/>
}
modalClass=""
onCancel={[Function]}
onConfirm={[Function]}
show={false}
title={
<FormattedMessage
defaultMessage="Save and Archive Team"
id="admin.team_settings.team_detail.archive_confirm.title"
/>
}
/>
<RemoveConfirmModal
amount={0}
inChannel={false}
onCancel={[Function]}
onConfirm={[Function]}
show={false}
/>
<TeamModes
allAllowedChecked={false}
allowedDomains=""
Expand All @@ -68,6 +96,7 @@ exports[`admin_console/team_channel_settings/team/TeamDetails should match snaps
Object {
"allow_open_invite": false,
"allowed_domains": "",
"delete_at": 0,
"display_name": "team",
"group_constrained": false,
"id": "123",
Expand All @@ -94,3 +123,78 @@ exports[`admin_console/team_channel_settings/team/TeamDetails should match snaps
/>
</div>
`;

exports[`admin_console/team_channel_settings/team/TeamDetails should match snapshot with isLocalArchived true 1`] = `
<div
className="wrapper--fixed"
>
<div
className="admin-console__header with-back"
>
<div>
<Connect(BlockableLink)
className="fa fa-angle-left back"
to="/admin_console/user_management/teams"
/>
<FormattedMessage
defaultMessage="Team Configuration"
id="admin.team_settings.team_detail.group_configuration"
/>
</div>
</div>
<div
className="admin-console__wrapper"
>
<div
className="admin-console__content"
>
<TeamProfile
isArchived={true}
onToggleArchive={[Function]}
team={
Object {
"allow_open_invite": false,
"allowed_domains": "",
"delete_at": 16465313,
"display_name": "team",
"group_constrained": false,
"id": "123",
}
}
/>
<ConfirmModal
confirmButtonClass="btn btn-primary"
confirmButtonText={
<FormattedMessage
defaultMessage="Archive"
id="admin.team_settings.team_detail.archive_confirm.button"
/>
}
message={
<FormattedMessage
defaultMessage="Saving will archive the team and make its contents inaccessible for all users. Are you sure you wish to save and archive this team?"
id="admin.team_settings.team_detail.archive_confirm.message"
/>
}
modalClass=""
onCancel={[Function]}
onConfirm={[Function]}
show={false}
title={
<FormattedMessage
defaultMessage="Save and Archive Team"
id="admin.team_settings.team_detail.archive_confirm.title"
/>
}
/>
</div>
</div>
<SaveChangesPanel
cancelLink="/admin_console/user_management/teams"
onClick={[Function]}
saveNeeded={false}
saving={false}
serverError={null}
/>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,101 @@ exports[`admin_console/team_channel_settings/team/TeamProfile should match snaps
</div>
</div>
</div>
<div
className="AdminChannelDetails_archiveContainer"
>
<button
className="btn btn-secondary ArchiveButton ArchiveButton___unarchived"
onClick={[MockFunction]}
type="button"
>
<ArchiveIcon
className="channel-icon channel-icon__archive"
/>
<FormattedMessage
defaultMessage="Archive Team"
id="admin.team_settings.team_details.archiveTeam"
/>
</button>
</div>
</div>
</div>
</AdminPanel>
`;

exports[`admin_console/team_channel_settings/team/TeamProfile should match snapshot with isArchived true 1`] = `
<AdminPanel
className=""
id="team_profile"
subtitleDefault="Summary of the team, including team name and description."
subtitleId="admin.team_settings.team_detail.profileDescription"
titleDefault="Team Profile"
titleId="admin.team_settings.team_detail.profileTitle"
>
<div
className="group-teams-and-channels"
>
<div
className="group-teams-and-channels--body"
>
<div
className="d-flex"
>
<div
className="large-team-image-col"
>
<TeamIcon
content="test"
size="lg"
url={null}
/>
</div>
<div
className="team-desc-col"
>
<div
className="row row-bottom-padding"
>
<injectIntl(FormattedMarkdownMessage)
defaultMessage="**Team Name**:"
id="admin.team_settings.team_detail.teamName"
/>
<br />
test
</div>
<div
className="row"
>
<injectIntl(FormattedMarkdownMessage)
defaultMessage="**Team Description**:"
id="admin.team_settings.team_detail.teamDescription"
/>
<br />
<span
className="greyed-out"
>
No team description added.
</span>
</div>
</div>
</div>
<div
className="AdminChannelDetails_archiveContainer"
>
<button
className="btn btn-secondary ArchiveButton ArchiveButton___archived"
onClick={[MockFunction]}
type="button"
>
<UnarchiveIcon
className="channel-icon channel-icon__unarchive"
/>
<FormattedMessage
defaultMessage="Unarchive Team"
id="admin.team_settings.team_details.unarchiveTeam"
/>
</button>
</div>
</div>
</div>
</AdminPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {connect} from 'react-redux';

import {getTeam} from 'mattermost-redux/selectors/entities/teams';

import {getTeam as fetchTeam, membersMinusGroupMembers, patchTeam, removeUserFromTeam, updateTeamMemberSchemeRoles, addUserToTeam} from 'mattermost-redux/actions/teams';
import {getTeam as fetchTeam, membersMinusGroupMembers, patchTeam, removeUserFromTeam, updateTeamMemberSchemeRoles, addUserToTeam, deleteTeam, unarchiveTeam} from 'mattermost-redux/actions/teams';
import {getAllGroups, getGroupsAssociatedToTeam} from 'mattermost-redux/selectors/entities/groups';

import {
Expand Down Expand Up @@ -50,6 +50,8 @@ function mapDispatchToProps(dispatch) {
removeUserFromTeam,
addUserToTeam,
updateTeamMemberSchemeRoles,
deleteTeam,
unarchiveTeam,
}, dispatch),
};
}
Expand Down
Loading