Skip to content

Commit

Permalink
naming stuff is hard
Browse files Browse the repository at this point in the history
  • Loading branch information
hotzenklotz committed Jan 19, 2023
1 parent b627c5b commit 560907b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
PlanExpirationCard,
PlanUpgradeCard,
} from "./organization_cards";
import { enforceActiveOrganization } from "oxalis/model/accessors/organization_accessors";
import { getActiveUserCount } from "./pricing_plan_utils";
import type { OxalisState } from "oxalis/store";

Expand Down Expand Up @@ -301,7 +302,7 @@ class OrganizationEditView extends React.PureComponent<Props, State> {
}

const mapStateToProps = (state: OxalisState): StateProps => ({
organization: state.activeOrganization,
organization: enforceActiveOrganization(state.activeOrganization),
});

const connector = connect(mapStateToProps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ export function isPricingPlanGreaterEqualThan(planA: PricingPlanEnum, planB: Pri

case PricingPlanEnum.Team:
case PricingPlanEnum.TeamTrial:
return planB === PricingPlanEnum.Basic;
switch (planB) {
case PricingPlanEnum.Power:
case PricingPlanEnum.PowerTrial:
case PricingPlanEnum.Custom:
return false;
default:
return true;
}

case PricingPlanEnum.Basic:
default:
Expand Down
33 changes: 27 additions & 6 deletions frontend/javascripts/components/pricing_enforcer.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import { useSelector } from "react-redux";
import { Tooltip, Menu, MenuItemProps, Alert } from "antd";
import { LockOutlined } from "@ant-design/icons";
import { PricingPlanEnum } from "admin/organization/organization_edit_view";
import { isPricingPlanGreaterEqualThan } from "admin/organization/pricing_plan_utils";
import { Tooltip, Menu, MenuItemProps } from "antd";
import { MenuClickEventHandler } from "rc-menu/lib/interface";
import * as React from "react";
import type { MenuClickEventHandler } from "rc-menu/lib/interface";
import type { OxalisState } from "oxalis/store";

export default function PricingEnforcedMenuItem({
children,
Expand All @@ -15,10 +17,12 @@ export default function PricingEnforcedMenuItem({
requiredPricingPlan: PricingPlanEnum;
showLockIcon?: boolean;
} & MenuItemProps): JSX.Element {
const isFeatureAllowed = false;
// const isFeatureAllowed = isPricingPlanGreaterThan(organization.pricingPlan, requiredPricingPlan);
const currentPricingPlan = useSelector((state: OxalisState) =>
state.activeOrganization ? state.activeOrganization.pricingPlan : PricingPlanEnum.Basic,
);
const isFeatureAllowed = isPricingPlanGreaterEqualThan(currentPricingPlan, requiredPricingPlan);

if (isFeatureAllowed) return children;
if (isFeatureAllowed) return <Menu.Item {...menuItemProps}>{children}</Menu.Item>;

// TODO show upragde button for owner
const toolTipMessage = `This feature is not available in your organisation's plan. Ask your organisation owner to upgrade.`;
Expand Down Expand Up @@ -48,3 +52,20 @@ export default function PricingEnforcedMenuItem({
</Tooltip>
);
}

function PageUnavailableForYourPlan() {
return (
<div className="container">
<Alert
style={{
maxWidth: "500px",
margin: "0 auto",
}}
message="Error 404"
description="Page not found."
type="error"
showIcon
/>
</div>
);
}

0 comments on commit 560907b

Please sign in to comment.