Skip to content

Commit a4d3810

Browse files
committed
#654 Require pro subscription on CSS
1 parent 62204ea commit a4d3810

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/components/ContentWrap.jsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import codeService from '../services/code_service';
1919
import { alertsService } from '../notifications';
2020
import { Popover } from './PopOver.jsx';
2121
import { SharePanel } from './SharePanel.jsx';
22+
import userService from '../services/user_service';
2223

2324
const minCodeWrapSize = 33;
2425

@@ -775,6 +776,17 @@ export default class ContentWrap extends Component {
775776
}
776777
}
777778

779+
780+
onCSSActiviation() {
781+
if(!window.user) {
782+
this.props.onLogin();
783+
} else if(userService.isPro()) {
784+
return true;
785+
} else {
786+
this.props.onProFeature();
787+
}
788+
}
789+
778790
toolboxUpdateToApp(param) {
779791
trackEvent('ui', 'code', 'toolbox');
780792
const code = this.cm.js.getValue();
@@ -863,7 +875,7 @@ export default class ContentWrap extends Component {
863875
{/* Inlet(scope.cm.js); */}
864876
</div>
865877
</div>
866-
<div label="CSS">
878+
<div label="CSS" onBeforeActiviation={this.onCSSActiviation.bind(this)}>
867879
<div
868880
data-code-wrap-id="1"
869881
id="cssCodeEl"

src/components/Tabs.jsx

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class Tabs extends Component {
1818
};
1919
};
2020
onClickTabItem = async (tab) => {
21+
const child = this.props.children.find(c => c.props.label === tab);
22+
if(child && child.props.onBeforeActiviation) {
23+
const result = child.props.onBeforeActiviation();
24+
if(!result) {
25+
return;
26+
}
27+
}
28+
2129
await this.setState({ activeTab: tab });
2230
this.props.onChange(tab);
2331
};

src/components/app.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,7 @@ BookLibService.Borrow(id) {
14331433
prefs={this.state.prefs}
14341434
onEditorFocus={this.editorFocusHandler.bind(this)}
14351435
onSplitUpdate={this.splitUpdateHandler.bind(this)}
1436+
onProFeature={this.proBtnClickHandler.bind(this)}
14361437
/>
14371438
{this.isEmbed ? null : (
14381439
<Footer

0 commit comments

Comments
 (0)