Skip to content

Commit

Permalink
remove deprecated backend code (#2502)
Browse files Browse the repository at this point in the history
# What this PR does

See more details comments alongside the code.

Regarding frontend changes, the main changes in this PR are to remove
unused fields on the `Team` interface + unused methods on the `Team`
model.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required) (N/A)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required) (N/A)
  • Loading branch information
joeyorlando authored Jul 12, 2023
1 parent c36c6b5 commit 477794e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 146 deletions.
4 changes: 0 additions & 4 deletions src/models/team.ts

This file was deleted.

90 changes: 0 additions & 90 deletions src/models/team/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { action, observable } from 'mobx';

import BaseStore from 'models/base_store';
import { makeRequest } from 'network';
import { Mixpanel } from 'services/mixpanel';
import { RootStore } from 'state';
import { openErrorNotification } from 'utils';
import { getPathnameByTeamNameSlug } from 'utils/url';

import { Team } from './team.types';

Expand All @@ -30,98 +27,11 @@ export class TeamStore extends BaseStore {
this.currentTeam = await makeRequest('/current_team/', {});
}

@action
async setCurrentTeam(teamId: Team['pk']) {
this.redirectingToProperTeam = true;

const team = await makeRequest(`/current_team/`, {
method: 'POST',
data: { team_id: teamId },
});

const pathName = getPathnameByTeamNameSlug(team.name_slug);

window.location.pathname = pathName;
}

@action
async addTeam(data: Partial<Team>) {
let createdTeam;
try {
createdTeam = await makeRequest('/teams/', {
method: 'POST',
data,
});
} catch (e) {
openErrorNotification(e.response.data);
return;
}

this.setCurrentTeam(createdTeam.pk);

Mixpanel.track('Add Team', null);
}

@action
async saveCurrentTeam(data: any) {
this.currentTeam = await makeRequest('/current_team/', {
method: 'PUT',
data,
});
}

@action
async justSaveCurrentTeam(data: any) {
return await makeRequest('/current_team/', {
method: 'PUT',
data,
});
}

@action
async getTelegramVerificationCode(pk: Team['pk']) {
const response = await makeRequest(`/teams/${pk}/get_telegram_verification_code/`, {
withCredentials: true,
});

return response;
}

@action
async unlinkTelegram(pk: Team['pk']) {
const response = await makeRequest(`/teams/${pk}/unlink_telegram/`, {
method: 'POST',
withCredentials: true,
});

return response;
}

@action
async getInvitationLink() {
const response = await makeRequest('/invitation_link/', {
withCredentials: true,
});

return response;
}

@action
async joinToTeam(invitation_token: string) {
const response = await makeRequest('/join_to_team/', {
method: 'POST',
params: { invitation_token, token: invitation_token },
withCredentials: true,
});

return response;
}

@action
async updateTeam(_teamId: Team['pk']) {
await makeRequest(this.path, {
params: {},
withCredentials: true,
});
}
}
40 changes: 0 additions & 40 deletions src/models/team/team.types.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,7 @@
import { SlackChannel } from 'models/slack_channel/slack_channel.types';

export enum SubscriptionStatus {
OK,
VIOLATION,
HARD_VIOLATION,
}

export interface Limit {
left: number;
limit_title: string;
total: number;
}

export interface Team {
pk: string;
is_free_version: boolean;
limits: {
period_title: string;
show_limits_popup: boolean;
limits_to_show: Limit[];
show_limits_warning: boolean;
warning_text: string;
};
banner: {
title: string;
body: string;
Expand All @@ -33,7 +13,6 @@ export interface Team {
discussion_group_name: string;
};
name: string;
name_slug: string;
slack_team_identity: {
general_log_channel_id: string;
general_log_channel_pk: string;
Expand All @@ -42,29 +21,10 @@ export interface Team {

slack_channel: SlackChannel | null;

number_of_employees: number;

subscription_status: SubscriptionStatus;

stats: {
alerts_count: number;
average_response_time: string;
grouped_percent: number;
noise_reduction: number;
verbal_time_saved_by_amixr: string;
};

incident_retention_web_report: {
num_month_available: number;
incidents_hidden: number;
} | null;

// ex team settings
archive_alerts_from: string;
is_resolution_note_required: boolean;

env_status: {
twilio_configured: boolean;
telegram_configured: boolean;
phone_provider: {
configured: boolean;
Expand Down
12 changes: 0 additions & 12 deletions src/utils/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@ import qs, { ParsedQuery } from 'query-string';

import { PLUGIN_ROOT } from './consts';

export function getTeamNameSlugFromUrl(): string | undefined {
const teamName = window.location.pathname.split('/')[2];
return teamName === 'admin' || teamName === 'auth' ? undefined : teamName;
}

export function getPathnameByTeamNameSlug(teamNameSlug: string): string {
return window.location.pathname
.split('/')
.map((part: string, index) => (index === 2 ? teamNameSlug : part))
.join('/');
}

export function getPathFromQueryParams(query: ParsedQuery<string>) {
const normalizedQuery = { ...query };

Expand Down

0 comments on commit 477794e

Please sign in to comment.