Skip to content

Commit ea9a9cf

Browse files
company settings: set up visibility of elements depending on company role and saas/self-hosted version
1 parent 858a0d4 commit ea9a9cf

File tree

6 files changed

+44
-42
lines changed

6 files changed

+44
-42
lines changed

frontend/src/app/components/branding/branding.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ <h1 class="mat-h1 branding-page-header">Branding</h1>
1212

1313
<div class="white-label">
1414
<div class="white-label-settings">
15-
<div *ngIf="(currentPlan === 'free' || currentUser.role === 'DB_ADMIN') && isSaas && !isDemo"
15+
<div *ngIf="(currentPlan === 'free' || currentUser.role !== 'ADMIN') && isSaas && !isDemo"
1616
class="white-label-settings__overlay"
17-
[matTooltip]="currentUser.role === 'DB_ADMIN' ? 'Contact your Account Owner to set up white label settings.' : 'To white‑label your domain, please upgrade to the Team plan or higher.'">
17+
[matTooltip]="currentUser.role !== 'ADMIN' ? 'Contact your Account Owner to set up white label settings.' : 'To white‑label your domain, please upgrade to the Team plan or higher.'">
1818
</div>
1919
<form *ngIf="isSaas"
2020
class="text-filed-edit"
@@ -27,7 +27,7 @@ <h1 class="mat-h1 branding-page-header">Branding</h1>
2727
angularticsAction="Company: custom domain is edited"
2828
(change)="posthog.capture('Company: custom domain is edited')"
2929
placeholder="e.g. {{companyCustomDomainPlaceholder}}"
30-
[readonly]="currentUser.role === 'DB_ADMIN' || isCustomDomain"
30+
[readonly]="currentUser.role !== 'ADMIN' || isCustomDomain"
3131
[(ngModel)]="companyCustomDomainHostname">
3232
<mat-hint *ngIf="currentPlan !== 'free' && currentUser.role === 'ADMIN' && isCustomDomain" class="cname-hint">
3333
To change the domain, visit <a href="https://app.rocketadmin.com/company" target="_blank">app.rocketadmin.com/company</a>
@@ -48,7 +48,7 @@ <h1 class="mat-h1 branding-page-header">Branding</h1>
4848
(click)="handleDeleteDomainDialogOpen()">
4949
Delete
5050
</button>
51-
<a *ngIf="currentUser.role === 'DB_ADMIN' && companyCustomDomainHostname"
51+
<a *ngIf="currentUser.role !== 'ADMIN' && companyCustomDomainHostname"
5252
href="https://{{companyCustomDomainHostname}}"
5353
target="_blank"
5454
mat-button color="primary">
@@ -57,7 +57,7 @@ <h1 class="mat-h1 branding-page-header">Branding</h1>
5757
</div>
5858
</form>
5959

60-
<div class="white-label-settings-images">
60+
<div *ngIf="currentUser.role === 'ADMIN' && !isDemo" class="white-label-settings-images">
6161
<form #uploadLogoForm="ngForm" class="upload-logo-form">
6262
<div class="file-uploader-appearance">
6363
<button mat-stroked-button type="button" (click)="logoInput.click()">
@@ -98,7 +98,7 @@ <h1 class="mat-h1 branding-page-header">Branding</h1>
9898
angularticsAction="Company: tab title domain is edited"
9999
(change)="posthog.capture('Company: tab title domain is edited')"
100100
placeholder="e.g. {{company.name}}"
101-
[readonly]="currentUser.role === 'DB_ADMIN'"
101+
[readonly]="currentUser.role !== 'ADMIN'"
102102
[(ngModel)]="companyTabTitle">
103103
<mat-hint *ngIf="currentPlan === 'free'" class="cname-hint">
104104
Set the title that appears on the browser tab.

frontend/src/app/components/company/company.component.html

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,8 @@ <h1 class="mat-h1 companyPageHeader">
3131
{{submittingChangedName ? 'Saving' : 'Save'}}
3232
</button>
3333
</div>
34-
3534
</form>
3635

37-
<div *ngIf="isSaas" class="company-plan">
38-
<div>
39-
<strong>Current plan: </strong>
40-
<span class="company-plan-name" data-testid="company-plan-string">{{currentPlan}}</span>
41-
</div>
42-
</div>
43-
4436
<div class="tableHeader">
4537
<h2 class="heading-2 tableHeader__heading">Members <span *ngIf="currentPlan === 'free' && isSaas" data-testid="company-members-max-string">(max 3)</span></h2>
4638
<div class="tableHeader__actions">

frontend/src/app/components/profile/profile-sidebar/profile-sidebar.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<span *ngIf="!collapsed()" matListItemTitle>Branding</span>
6161
</a>
6262
<a mat-list-item
63+
*ngIf="isSaas"
6364
routerLink="/saml"
6465
[class.active-link]="activeTab() === 'saml'"
6566
class="sidebar-nav-item"

frontend/src/app/components/upgrade/upgrade.component.html

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<app-alert></app-alert>
66

77
<div class="plans">
8-
<div class="current-plan-banner">
8+
<div *ngIf="isAdmin" class="current-plan-banner">
99
<div class="current-plan-info">
1010
<span class="current-plan-label">Current plan</span>
1111
<span class="current-plan-name">{{ currentPlan.name }}</span>
@@ -46,33 +46,35 @@ <h1 class="mat-h1">
4646
Current
4747
</button>
4848
<ng-template #activeButton>
49-
<button mat-flat-button color="accent" type="button"
50-
*ngIf="plan.price > currentPlan.price && hasPaymentMethod"
51-
[disabled]="submitting"
52-
(click)="changePlan(plan.key)">
53-
Upgrade
54-
</button>
55-
<button mat-button type="button"
56-
*ngIf="plan.price < currentPlan.price && hasPaymentMethod"
57-
[disabled]="submitting"
58-
(click)="changePlan(plan.key)">
59-
Downgrade
60-
</button>
49+
<ng-container *ngIf="isAdmin">
50+
<button mat-flat-button color="accent" type="button"
51+
*ngIf="plan.price > currentPlan.price && hasPaymentMethod"
52+
[disabled]="submitting"
53+
(click)="changePlan(plan.key)">
54+
Upgrade
55+
</button>
56+
<button mat-button type="button"
57+
*ngIf="plan.price < currentPlan.price && hasPaymentMethod"
58+
[disabled]="submitting"
59+
(click)="changePlan(plan.key)">
60+
Downgrade
61+
</button>
6162

62-
<a mat-flat-button color="accent"
63-
*ngIf="plan.price > currentPlan.price && !hasPaymentMethod"
64-
[disabled]="submitting"
65-
routerLink="/upgrade/payment"
66-
[queryParams]="{plan: plan.key}">
67-
Upgrade
68-
</a>
69-
<a mat-button
70-
*ngIf="plan.price < currentPlan.price && !hasPaymentMethod"
71-
[disabled]="submitting"
72-
routerLink="/upgrade/payment"
73-
[queryParams]="{plan: plan.key}">
74-
Downgrade
75-
</a>
63+
<a mat-flat-button color="accent"
64+
*ngIf="plan.price > currentPlan.price && !hasPaymentMethod"
65+
[disabled]="submitting"
66+
routerLink="/upgrade/payment"
67+
[queryParams]="{plan: plan.key}">
68+
Upgrade
69+
</a>
70+
<a mat-button
71+
*ngIf="plan.price < currentPlan.price && !hasPaymentMethod"
72+
[disabled]="submitting"
73+
routerLink="/upgrade/payment"
74+
[queryParams]="{plan: plan.key}">
75+
Downgrade
76+
</a>
77+
</ng-container>
7678
</ng-template>
7779
</div>
7880
</ng-template>

frontend/src/app/components/upgrade/upgrade.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
22

33
import { AlertComponent } from '../ui-components/alert/alert.component';
44
import { CommonModule } from '@angular/common';
5+
import { CompanyMemberRole } from 'src/app/models/company';
56
import { CompanyService } from 'src/app/services/company.service';
67
import { MatButtonModule } from '@angular/material/button';
78
import { MatChipsModule } from '@angular/material/chips';
@@ -11,6 +12,7 @@ import { PaymentService } from 'src/app/services/payment.service';
1112
import { PlanKey } from 'src/app/models/plans';
1213
import { ProfileSidebarComponent } from '../profile/profile-sidebar/profile-sidebar.component';
1314
import { RouterModule } from '@angular/router';
15+
import { UserService } from 'src/app/services/user.service';
1416
import plans from '../../consts/plans';
1517

1618
@Component({
@@ -39,6 +41,7 @@ export class UpgradeComponent implements OnInit {
3941
public portalLink: string = null;
4042
public companyId: string;
4143
public submitting = false;
44+
public isAdmin = false;
4245

4346
databases = [
4447
{
@@ -175,10 +178,14 @@ export class UpgradeComponent implements OnInit {
175178
constructor(
176179
private _paymentService: PaymentService,
177180
private _company: CompanyService,
181+
private _userService: UserService,
178182
) { }
179183

180184
ngOnInit(): void {
181185
this.getCompanyPaln();
186+
this._userService.cast.subscribe((user) => {
187+
this.isAdmin = user.role === CompanyMemberRole.CAO;
188+
});
182189
}
183190

184191
getCompanyPaln() {

frontend/src/environments/environment.dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const environment = {
22
production: false,
3-
saas: false,
3+
saas: true,
44
apiRoot: 'https://app.rocketadmin.com/api',
55
saasURL: 'https://app.rocketadmin.com',
66
saasHostnames: ['localhost', '127.0.0.1'],

0 commit comments

Comments
 (0)