Skip to content

Commit

Permalink
Show plus sign when maximum tracking is reached (#13810)
Browse files Browse the repository at this point in the history
* Show plus sign when maximum tracking is reached

---------

Co-authored-by: abhigyanghosh30 <abhigyanghosh30@gmail.com>
  • Loading branch information
britneywwc and abhigyanghosh30 committed Jun 4, 2024
1 parent e3eeefa commit a215d81
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions static/js/src/advantage/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export type UserSubscription = {
statuses: UserSubscriptionStatuses;
subscription_id: string | null;
type: UserSubscriptionType;
max_tracking_reached: boolean;
};

export type ContractToken = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const DetailsContent = ({ selectedId, setHasUnsavedChanges }: Props) => {
title: "Active machines",
value: (
<React.Fragment>
{subscription.max_tracking_reached ? "+" : ""}
{subscription.number_of_active_machines}
<Tooltip
tooltipClassName="p-subscriptions-tooltip"
Expand Down
2 changes: 2 additions & 0 deletions static/js/src/advantage/tests/factories/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const userSubscriptionFactory = Factory.define<UserSubscription>(
statuses: userSubscriptionStatusesFactory.build(),
subscription_id: `VO7AyCYZzvjY3JaBWF0xmUu8vv5S684ZTeXMnJ${sequence}`,
type: UserSubscriptionType.Yearly,
max_tracking_reached: false,
})
);

Expand Down Expand Up @@ -112,6 +113,7 @@ export const freeSubscriptionFactory = Factory.define<UserSubscription>(
statuses: userSubscriptionStatusesFactory.build(),
subscription_id: null,
type: UserSubscriptionType.Free,
max_tracking_reached: false,
})
);

Expand Down
1 change: 1 addition & 0 deletions webapp/shop/api/ua_contracts/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def build_final_user_subscriptions(
period=listing.period if listing else None,
renewal_id=renewal.id if renewal else None,
statuses=statuses,
max_tracking_reached=contract.max_tracking_reached,
)

# Do not return expired user subscriptions after 90 days
Expand Down
2 changes: 2 additions & 0 deletions webapp/shop/api/ua_contracts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(
period: str = None,
listing_id: str = None,
renewal_id: str = None,
max_tracking_reached: bool = False,
):
self.id = id
self.account_id = account_id
Expand All @@ -109,6 +110,7 @@ def __init__(
self.contract_id = contract_id
self.listing_id = listing_id
self.renewal_id = renewal_id
self.max_tracking_reached = max_tracking_reached


class OfferItem:
Expand Down
7 changes: 7 additions & 0 deletions webapp/shop/api/ua_contracts/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ def parse_contract(raw_contract: Dict) -> Contract:
items = parse_contract_items(raw_items)

number_of_active_machines = 0
max_tracking_reached = False
if "activeMachines" in contract_info:
active_machines = contract_info["activeMachines"]
number_of_active_machines = active_machines["activeMachines"]
max_tracking_reached = (
active_machines["maximumTrackingReached"]
if "maximumTrackingReached" in active_machines
else False
)

return Contract(
id=contract_info.get("id"),
Expand All @@ -165,6 +171,7 @@ def parse_contract(raw_contract: Dict) -> Contract:
entitlements=entitlements,
number_of_active_machines=number_of_active_machines,
items=items,
max_tracking_reached=max_tracking_reached,
)


Expand Down
2 changes: 2 additions & 0 deletions webapp/shop/api/ua_contracts/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(
entitlements: List[Entitlement],
number_of_active_machines: int,
items: List[ContractItem] = None,
max_tracking_reached: bool = False,
):
self.id = id
self.account_id = account_id
Expand All @@ -78,6 +79,7 @@ def __init__(
self.entitlements = entitlements
self.number_of_active_machines = number_of_active_machines
self.items = items
self.max_tracking_reached = max_tracking_reached


class SubscriptionItem:
Expand Down

0 comments on commit a215d81

Please sign in to comment.