Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recommend pro plan when limit is reached #2540

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SharedModule } from '../../modules/shared/shared.module';
import { AccountService, NotifyService } from '../../services';

import { TeamsDialogComponent } from './teams-dialog.component';
import { Store } from '@ngrx/store';

describe('TeamsDialogComponent', () => {
let component: TeamsDialogComponent;
Expand All @@ -12,7 +13,11 @@ describe('TeamsDialogComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [TeamsDialogComponent],
providers: [MockProvider(AccountService), MockProvider(NotifyService)],
providers: [
MockProvider(AccountService),
MockProvider(NotifyService),
MockProvider(Store),
],
imports: [MockModule(SharedModule)],
}).compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { BehaviorSubject, combineLatest } from 'rxjs';
import { map, take } from 'rxjs/operators';
import { AccountService, NotifyService } from '../../services';
import { debug } from '../../utils/logger';
import { getApiErrorCode, getErrorResponse } from '../../utils/errors';
import { Store } from '@ngrx/store';
import { RootState } from 'altair-graphql-core/build/types/state/state.interfaces';
import * as windowsMetaActions from '../../store/windows-meta/windows-meta.action';

@Component({
selector: 'app-teams-dialog',
Expand Down Expand Up @@ -59,7 +63,8 @@ export class TeamsDialogComponent {
constructor(
private readonly accountService: AccountService,
private readonly notifyService: NotifyService,
private readonly formBuilder: NonNullableFormBuilder
private readonly formBuilder: NonNullableFormBuilder,
private readonly store: Store<RootState>
) {
this.selectedTeam$.subscribe(async (team) => {
if (!team) {
Expand Down Expand Up @@ -123,6 +128,18 @@ export class TeamsDialogComponent {

this.resetTeamForm();
this.reloadTeamChange.emit();
} catch (err) {
const rawError = await getErrorResponse(err);
if (
['ERR_MAX_TEAM_MEMBER_COUNT', 'ERR_MAX_TEAM_COUNT'].includes(
getApiErrorCode(rawError) ?? ''
)
) {
this.store.dispatch(
new windowsMetaActions.ShowUpgradeDialogAction({ value: true })
);
}
this.notifyService.errorWithError(rawError, 'Could not save team');
} finally {
this.loading = false;
}
Expand Down Expand Up @@ -175,8 +192,19 @@ export class TeamsDialogComponent {

this.resetMemberForm();
this.reloadTeamChange.emit();
} catch {
this.notifyService.error('Could not add team member');
} catch (err) {
const rawError = await getErrorResponse(err);
if (
['ERR_MAX_TEAM_MEMBER_COUNT', 'ERR_MAX_TEAM_COUNT'].includes(
getApiErrorCode(rawError) ?? ''
)
) {
this.store.dispatch(
new windowsMetaActions.ShowUpgradeDialogAction({ value: true })
);
}

this.notifyService.errorWithError(rawError, 'Could not add team member');
} finally {
this.loading = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import * as workspaceActions from '../store/workspace/workspace.action';
import * as windowsMetaActions from '../store/windows-meta/windows-meta.action';
import { debug } from '../utils/logger';
import { fromPromise } from '../utils';
import { getErrorResponse } from '../utils/errors';

@Injectable()
export class AccountEffects {
Expand Down Expand Up @@ -101,12 +102,16 @@ export class AccountEffects {
return EMPTY;
}),
catchError((error) => {
debug.error(error);
this.notifyService.errorWithError(
error,
'Sorry, we could not log you in. Please check that your username and password are correct'
return fromPromise(getErrorResponse(error)).pipe(
switchMap((error) => {
debug.error(error);
this.notifyService.errorWithError(
error,
'Sorry, we could not log you in. Please check that your username and password are correct'
);
return EMPTY;
})
);
return EMPTY;
}),
repeat()
);
Expand Down Expand Up @@ -138,12 +143,16 @@ export class AccountEffects {
return EMPTY;
}),
catchError((error) => {
debug.error(error);
this.notifyService.errorWithError(
error,
'Sorry, we could not log you out. Please try again.'
return fromPromise(getErrorResponse(error)).pipe(
switchMap((error) => {
debug.error(error);
this.notifyService.errorWithError(
error,
'Sorry, we could not log you out. Please try again.'
);
return EMPTY;
})
);
return EMPTY;
}),
repeat()
);
Expand All @@ -161,9 +170,13 @@ export class AccountEffects {
return EMPTY;
}),
catchError((err: UnknownError) => {
debug.error(err);
this.notifyService.errorWithError(err, 'Could not load teams');
return EMPTY;
return fromPromise(getErrorResponse(err)).pipe(
switchMap((error) => {
debug.error(error);
this.notifyService.errorWithError(err, 'Could not load teams');
return EMPTY;
})
);
}),
repeat()
);
Expand All @@ -186,9 +199,13 @@ export class AccountEffects {
})
),
catchError((err: UnknownError) => {
debug.error(err);
this.notifyService.errorWithError(err, 'Could not load teams');
return EMPTY;
return fromPromise(getErrorResponse(err)).pipe(
switchMap((error) => {
debug.error(error);
this.notifyService.errorWithError(err, 'Could not load teams');
return EMPTY;
})
);
}),
repeat()
);
Expand Down Expand Up @@ -217,9 +234,13 @@ export class AccountEffects {
})
),
catchError((err: UnknownError) => {
debug.error(err);
this.notifyService.errorWithError(err, 'Could not load user data');
return EMPTY;
return fromPromise(getErrorResponse(err)).pipe(
switchMap((error) => {
debug.error(error);
this.notifyService.errorWithError(err, 'Could not load user data');
return EMPTY;
})
);
}),
repeat()
);
Expand Down
Loading
Loading