Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: LEAP-598: Self Serve M2 #5517

Merged
merged 8 commits into from
Mar 27, 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
8 changes: 4 additions & 4 deletions web/dist/apps/labelstudio/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Add one more `@example` tag",
"commit": "f4b43e51fcdedc4f9f79d7b1a567d63454b44c6e",
"date": "2024-03-27T10:34:10.000Z",
"branch": "fix-misspells-frontend-docs"
"message": "Merge branch 'develop' into 'fb-leap-598'",
"commit": "850f6275c9010ad01c6cb8a275874b16f343e868",
"date": "2024-03-27T12:19:01.000Z",
"branch": "fb-leap-598"
}
2 changes: 1 addition & 1 deletion web/dist/libs/datamanager/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/datamanager/main.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions web/dist/libs/datamanager/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Add one more `@example` tag",
"commit": "f4b43e51fcdedc4f9f79d7b1a567d63454b44c6e",
"date": "2024-03-27T10:34:10.000Z",
"branch": "fix-misspells-frontend-docs"
"message": "Merge branch 'develop' into 'fb-leap-598'",
"commit": "850f6275c9010ad01c6cb8a275874b16f343e868",
"date": "2024-03-27T12:19:01.000Z",
"branch": "fb-leap-598"
}
8 changes: 4 additions & 4 deletions web/dist/libs/editor/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Add one more `@example` tag",
"commit": "f4b43e51fcdedc4f9f79d7b1a567d63454b44c6e",
"date": "2024-03-27T10:34:10.000Z",
"branch": "fix-misspells-frontend-docs"
"message": "Merge branch 'develop' into 'fb-leap-598'",
"commit": "850f6275c9010ad01c6cb8a275874b16f343e868",
"date": "2024-03-27T12:19:01.000Z",
"branch": "fb-leap-598"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { aroundTransition } from "../../../utils/transition";
import "./Tooltip.styl";

export const Tooltip = forwardRef(
({ title, children, defaultVisible, style }, ref) => {
({ title, children, defaultVisible, disabled, style }, ref) => {
const child = Children.only(children);
const triggerElement = ref ?? useRef();
const tooltipElement = useRef();
Expand Down Expand Up @@ -83,14 +83,20 @@ export const Tooltip = forwardRef(
[injected, offset, title, visibilityClasses, tooltipElement],
);

useEffect(() => {
if (disabled === true && visibility === "visible") performAnimation(false);
}, [disabled]);

const clone = cloneElement(child, {
...child.props,
ref: triggerElement,
onMouseEnter(e) {
if (disabled === true) return;
setInjected(true);
child.props.onMouseEnter?.(e);
},
onMouseLeave(e) {
if (disabled === true) return;
performAnimation(false);
child.props.onMouseLeave?.(e);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { FaCaretDown, FaChevronDown } from "react-icons/fa";
import { FF_LOPS_E_10, isFF } from "../../../utils/feature-flags";
import { Block } from "../../../utils/bem";
import { FF_LOPS_E_10, FF_SELF_SERVE, isFF } from "../../../utils/feature-flags";
import { ErrorBox } from "../../Common/ErrorBox";
import { FieldsButton } from "../../Common/FieldsButton";
import { FiltersPane } from "../../Common/FiltersPane";
import { Icon } from "../../Common/Icon/Icon";
import { Interface } from "../../Common/Interface";
import { ExportButton, ImportButton } from "../../Common/SDKButtons";
import { Tooltip } from "../../Common/Tooltip/Tooltip";
import { ActionsButton } from "./ActionsButton";
import { GridWidthButton } from "./GridWidthButton";
import { LabelButton } from "./LabelButton";
Expand All @@ -14,9 +16,42 @@ import { OrderButton } from "./OrderButton";
import { RefreshButton } from "./RefreshButton";
import { ViewToggle } from "./ViewToggle";

const style = {
minWidth: '110px',
justifyContent: 'space-between',
const style = {
minWidth: '110px',
justifyContent: 'space-between',
};

// Check if user is on trial
const isTrialExpired = window.APP_SETTINGS.billing.checks.is_license_expired;
// Check the subscription period end date
const subscriptionPeriodEnd = window.APP_SETTINGS.subscription.current_period_end;
// Check if user is self-serve
const isSelfServe = isFF(FF_SELF_SERVE) && window.APP_SETTINGS.billing.enterprise;
// Check if user is self-serve and has expired trial
const isSelfServeExpiredTrial = isSelfServe && isTrialExpired && !subscriptionPeriodEnd;
// Check if user is self-serve and has expired subscription
const isSelfServeExpiredSubscription = isSelfServe && subscriptionPeriodEnd && new Date(subscriptionPeriodEnd) < new Date();
// Check if user is self-serve and has expired trial or subscription
const isSelfServeExpired = isSelfServeExpiredTrial || isSelfServeExpiredSubscription;

const WithDisabledTooltip = ({ children, ...props }) => {
if (!props.disabled) {
return children;
}

return (
<Tooltip
title={props.title}
style={{
maxWidth:200,
textAlign: "center",
}}>
<Block name="button-wrapper">
{children}
</Block>
</Tooltip>
);

};

export const instruments = {
Expand All @@ -26,7 +61,7 @@ export const instruments = {
'columns': ({ size }) => {
const iconProps = {};
const isNewUI = isFF(FF_LOPS_E_10);

if (isNewUI) {
iconProps.size = 12;
iconProps.style = {
Expand Down Expand Up @@ -71,7 +106,11 @@ export const instruments = {
'import-button': ({ size }) => {
return (
<Interface name="import">
<ImportButton size={size}>Import</ImportButton>
<WithDisabledTooltip
title="You must upgrade your plan to import data"
disabled={isSelfServeExpired}>
<ImportButton disabled={isSelfServeExpired} size={size}>Import</ImportButton>
</WithDisabledTooltip>
</Interface>
);
},
Expand Down
6 changes: 6 additions & 0 deletions web/libs/datamanager/src/utils/feature-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export const FF_OPTIC_2 = "fflag_feat_optic_2_ensure_draft_saved_short";
*/
export const FF_LOPS_86 = "fflag_feat_front_lops_86_datasets_storage_edit_short";

/**
* Self Serve
* @link https://app.launchdarkly.com/default/test/features/fflag_feat_front_leap_482_self_serve_short/
*/
export const FF_SELF_SERVE = "fflag_feat_front_leap_482_self_serve_short";

// Customize flags
const flags = {};

Expand Down
Loading