Skip to content

Commit

Permalink
[MM-53702] Remove Downgrade Team Selection modal and all accompanying…
Browse files Browse the repository at this point in the history
… logic (mattermost#24059)

* Remove Downgrade Team Selection modal and all accompanying logic

* fix linter

* Fix i18n

* Final pipeline fixes
  • Loading branch information
nickmisasi committed Jul 19, 2023
1 parent 9322f71 commit 0b56400
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 955 deletions.
20 changes: 0 additions & 20 deletions server/channels/api4/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (api *API) InitTeam() {
api.BaseRoutes.Team.Handle("", api.APISessionRequired(getTeam)).Methods("GET")
api.BaseRoutes.Team.Handle("", api.APISessionRequired(updateTeam)).Methods("PUT")
api.BaseRoutes.Team.Handle("", api.APISessionRequired(deleteTeam)).Methods("DELETE")
api.BaseRoutes.Team.Handle("/except", api.APISessionRequired(softDeleteTeamsExcept)).Methods("DELETE")
api.BaseRoutes.Team.Handle("/patch", api.APISessionRequired(patchTeam)).Methods("PUT")
api.BaseRoutes.Team.Handle("/restore", api.APISessionRequired(restoreTeam)).Methods("POST")
api.BaseRoutes.Team.Handle("/privacy", api.APISessionRequired(updateTeamPrivacy)).Methods("PUT")
Expand Down Expand Up @@ -464,25 +463,6 @@ func deleteTeam(c *Context, w http.ResponseWriter, r *http.Request) {
ReturnStatusOK(w)
}

func softDeleteTeamsExcept(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireTeamId()
if c.Err != nil {
return
}

if !c.App.SessionHasPermissionToTeam(*c.AppContext.Session(), c.Params.TeamId, model.PermissionManageTeam) {
c.SetPermissionError(model.PermissionManageTeam)
return
}

err := c.App.SoftDeleteAllTeamsExcept(c.Params.TeamId)
if err != nil {
c.Err = err
}

ReturnStatusOK(w)
}

func getTeamsForUser(c *Context, w http.ResponseWriter, r *http.Request) {
c.RequireUserId()
if c.Err != nil {
Expand Down
1 change: 0 additions & 1 deletion server/channels/app/app_iface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions server/channels/app/opentracing/opentracing_layer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions server/channels/app/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +133,6 @@ func (a *App) AdjustTeamsFromProductLimits(teamLimits *model.TeamsLimits) *model
return nil
}

func (a *App) SoftDeleteAllTeamsExcept(teamID string) *model.AppError {
teams, appErr := a.GetAllTeams()
if appErr != nil {
return appErr
}

if teams == nil {
return nil
}
cloudLimitsArchived := true
patch := &model.TeamPatch{CloudLimitsArchived: &cloudLimitsArchived}
for _, team := range teams {
if team.Id != teamID {
_, err := a.PatchTeam(team.Id, patch)
if err != nil {
return err
}

err = a.SoftDeleteTeam(team.Id)
if err != nil {
return err
}
}
}
return nil
}

func (a *App) CreateTeam(c request.CTX, team *model.Team) (*model.Team, *model.AppError) {
rteam, err := a.ch.srv.teamService.CreateTeam(team)
if err != nil {
Expand Down
35 changes: 0 additions & 35 deletions server/channels/app/team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,41 +469,6 @@ func TestAddUserToTeamByTeamId(t *testing.T) {

}

func TestSoftDeleteAllTeamsExcept(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()

teams := []*model.Team{
{
DisplayName: "team-1",
Name: "team-1",
Email: "[email protected]",
Type: model.TeamOpen,
},
}
teamId := ""
for _, create := range teams {
team, err := th.App.CreateTeam(th.Context, create)
require.Nil(t, err)
teamId = team.Id
}

err := th.App.SoftDeleteAllTeamsExcept(teamId)
assert.Nil(t, err)
allTeams, err := th.App.GetAllTeams()
require.Nil(t, err)
for _, team := range allTeams {
if team.Id == teamId {
require.Equal(t, int64(0), team.DeleteAt)
require.Equal(t, false, team.CloudLimitsArchived)
} else {
require.NotEqual(t, int64(0), team.DeleteAt)
require.Equal(t, true, team.CloudLimitsArchived)
}
}

}

func TestAdjustTeamsFromProductLimits(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import PaymentSuccessStandardSvg from 'components/common/svg_images_components/p
import PaymentFailedSvg from 'components/common/svg_images_components/payment_failed_svg';
import IconMessage from 'components/purchase_modal/icon_message';
import ProgressBar, {ProcessState} from 'components/icon_message_with_progress_bar';
import {
archiveAllTeamsExcept,
} from 'mattermost-redux/actions/teams';
import {DispatchFunc} from 'mattermost-redux/types/actions';

type Props = RouteComponentProps & {
Expand Down Expand Up @@ -55,10 +52,6 @@ function CloudSubscribeWithLoad(props: Props) {

const handleSubscribe = async () => {
const start = new Date();
if (props.teamToKeep) {
await dispatch(archiveAllTeamsExcept(props.teamToKeep.id));
}

const result = await dispatch(subscribeCloudSubscription(
props.selectedProduct?.id as string, undefined, 0, props.downgradeFeedback,
));
Expand Down
35 changes: 9 additions & 26 deletions webapp/channels/src/components/pricing_modal/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {DispatchFunc} from 'mattermost-redux/types/actions';
import {deprecateCloudFree} from 'mattermost-redux/selectors/entities/preferences';

import {Feedback} from '@mattermost/types/cloud';
import useGetUsage from 'components/common/hooks/useGetUsage';
import useGetLimits from 'components/common/hooks/useGetLimits';
import SuccessModal from 'components/cloud_subscribe_result_modal/success';
import ErrorModal from 'components/cloud_subscribe_result_modal/error';
Expand All @@ -41,7 +40,6 @@ import useOpenSalesLink from 'components/common/hooks/useOpenSalesLink';
import {useOpenCloudZendeskSupportForm} from 'components/common/hooks/useOpenZendeskForm';
import ExternalLink from 'components/external_link';

import DowngradeTeamRemovalModal from './downgrade_team_removal_modal';
import ContactSalesCTA from './contact_sales_cta';
import StarterDisclaimerCTA from './starter_disclaimer_cta';
import StartTrialCaution from './start_trial_caution';
Expand All @@ -60,7 +58,6 @@ type ContentProps = {
function Content(props: ContentProps) {
const {formatMessage, formatNumber} = useIntl();
const dispatch = useDispatch<DispatchFunc>();
const usage = useGetUsage();
const [limits] = useGetLimits();
const openPricingModalBackAction = useOpenPricingModal();

Expand Down Expand Up @@ -379,29 +376,15 @@ function Content(props: ContentProps) {
if (!starterProduct) {
return;
}

if (usage.teams.active > 1) {
dispatch(
openModal({
modalId: ModalIdentifiers.CLOUD_DOWNGRADE_CHOOSE_TEAM,
dialogType: DowngradeTeamRemovalModal,
dialogProps: {
product_id: starterProduct?.id,
starterProduct,
},
}),
);
} else {
dispatch(
openModal({
modalId: ModalIdentifiers.FEEDBACK,
dialogType: DowngradeFeedbackModal,
dialogProps: {
onSubmit: handleClickDowngrade,
},
}),
);
}
dispatch(
openModal({
modalId: ModalIdentifiers.FEEDBACK,
dialogType: DowngradeFeedbackModal,
dialogProps: {
onSubmit: handleClickDowngrade,
},
}),
);
},
text: freeTierText,
disabled: isStarter || isEnterprise || !isAdmin,
Expand Down

This file was deleted.

Loading

0 comments on commit 0b56400

Please sign in to comment.