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

fixed portal link UI issues with subscriptions, endpoints and license check #2208

Merged
merged 2 commits into from
Dec 26, 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
4 changes: 4 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ func (a *ApplicationHandler) BuildControlPlaneRoutes() *chi.Mux {

portalLinkRouter.Get("/portal_link", handler.GetPortalLink)

portalLinkRouter.Get("/license/features", handler.GetLicenseFeatures)

portalLinkRouter.Route("/endpoints", func(endpointRouter chi.Router) {
endpointRouter.With(middleware.Pagination).Get("/", handler.GetEndpoints)
endpointRouter.Get("/{endpointID}", handler.GetEndpoint)
Expand Down Expand Up @@ -660,6 +662,8 @@ func (a *ApplicationHandler) BuildDataPlaneRoutes() *chi.Mux {
portalLinkRouter.Use(middleware.RequireValidPortalLinksLicense(handler.A.Licenser))
portalLinkRouter.Use(middleware.RequireAuth())

portalLinkRouter.Get("/license/features", handler.GetLicenseFeatures)

portalLinkRouter.Route("/events", func(eventRouter chi.Router) {
eventRouter.Post("/", handler.CreateEndpointEvent)
eventRouter.With(middleware.Pagination).Get("/", handler.GetEventsPaged)
Expand Down
2 changes: 1 addition & 1 deletion datastore/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ type Subscription struct {
UID string `json:"uid" db:"id"`
Name string `json:"name" db:"name"`
Type SubscriptionType `json:"type" db:"type"`
ProjectID string `json:"-" db:"project_id"`
ProjectID string `json:"project_id" db:"project_id"`
SourceID string `json:"-" db:"source_id"`
EndpointID string `json:"-" db:"endpoint_id"`
DeviceID string `json:"-" db:"device_id"`
Expand Down
1 change: 1 addition & 0 deletions web/ui/dashboard/src/app/models/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface SUBSCRIPTION {
status: string;
type: 'outgoing' | 'incoming';
uid: string;
project_id: string;
updated_at: string;
endpoint_metadata?: ENDPOINT;
alert_config?: { count: number; threshold: string };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { DropdownComponent, DropdownOptionDirective } from 'src/app/components/d
import { PortalService } from '../portal.service';
import { DialogDirective } from 'src/app/components/dialog/dialog.directive';
import { TagComponent } from 'src/app/components/tag/tag.component';
import { LicensesService } from '../../services/licenses/licenses.service';

@Component({
selector: 'convoy-subscriptions',
Expand All @@ -43,10 +44,10 @@ export class SubscriptionsComponent implements OnInit {

token: string = this.route.snapshot.queryParams.token;

constructor(private privateService: PrivateService, private generalService: GeneralService, private location: Location, private route: ActivatedRoute, private portalService: PortalService) {}
constructor(private privateService: PrivateService, private generalService: GeneralService, private location: Location, private route: ActivatedRoute, private portalService: PortalService, public licenseService: LicensesService) {}

ngOnInit() {
Promise.all([this.getPortalDetails(), this.getSubscriptions()]);
Promise.all([this.getPortalDetails(), this.getSubscriptions(), this.licenseService.setLicenses()]);
}

async getPortalDetails() {
Expand All @@ -71,10 +72,29 @@ export class SubscriptionsComponent implements OnInit {
}

openSubsriptionForm(action: 'create' | 'update') {
let project = localStorage.getItem("CONVOY_PROJECT");
if (!project && this.activeSubscription?.project_id) {
localStorage.setItem(
'CONVOY_PROJECT',
JSON.stringify({ uid: this.activeSubscription?.project_id })
);
}
this.action = action;
this.showSubscriptionForm = true;
this.location.go(`/portal/subscriptions/${action === 'create' ? 'new' : this.activeSubscription?.uid}?token=${this.token}${this.activeSubscription || this.endpointId ? `&endpointId=${this.activeSubscription?.uid || this.endpointId}` : ''}`);
}
let subscriptionPath = '/portal/subscriptions/';
if (action === 'create') {
subscriptionPath += 'new';
} else if (this.activeSubscription?.uid) {
subscriptionPath += this.activeSubscription.uid;
}

let queryParams = `?token=${this.token}`;
if (this.endpointId) {
queryParams += `&endpointId=${this.endpointId}`;
}

this.location.go(subscriptionPath + queryParams);
}

async deleteSubscripton() {
this.isDeletingSubscription = true;
Expand Down
Loading