Skip to content

Commit 8625dce

Browse files
authored
Merge pull request #1227 from nyaruka/mobile-friendly
Disallow editing nodes on mobile
2 parents d6f5d96 + 89f19bc commit 8625dce

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"@babel/core": "^7.4.4",
7171
"@babel/preset-env": "^7.4.4",
7272
"@babel/preset-react": "7.0.0",
73-
"@nyaruka/temba-components": "0.72.1",
73+
"@nyaruka/temba-components": "0.75.0",
7474
"@testing-library/jest-dom": "4.0.0",
7575
"@testing-library/react": "8.0.1",
7676
"@types/common-tags": "^1.8.0",

src/components/flow/Flow.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import { react as bindCallbacks } from 'auto-bind';
23
import Button from 'components/button/Button';
34
import { Canvas } from 'components/canvas/Canvas';
@@ -146,6 +147,11 @@ export class Flow extends React.PureComponent<FlowStoreProps, {}> {
146147
return (this.ghost = ref);
147148
}
148149

150+
public isMobile() {
151+
const win = window as any;
152+
return win.isMobile && win.isMobile();
153+
}
154+
149155
public componentDidMount(): void {
150156
this.Plumber.bind('connection', (event: ConnectionEvent) =>
151157
this.props.updateConnection(event.sourceId, event.targetId)
@@ -407,7 +413,7 @@ export class Flow extends React.PureComponent<FlowStoreProps, {}> {
407413
{this.getNodeEditor()}
408414

409415
<Canvas
410-
mutable={this.context.config.mutable}
416+
mutable={!this.isMobile() && this.context.config.mutable}
411417
draggingNew={!!this.props.ghostNode && !this.props.nodeEditorSettings}
412418
newDragElement={this.getDragNode()}
413419
onDragging={this.handleDragging}

src/config/ConfigProvider.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import { FlowEditorConfig } from 'flowTypes';
23
import * as React from 'react';
34

@@ -27,6 +28,10 @@ export default class ConfigProvider extends React.Component<ConfigProviderProps>
2728

2829
constructor(props: ConfigProviderProps) {
2930
super(props);
31+
const win = window as any;
32+
if (win.isMobile && win.isMobile()) {
33+
this.props.config.mutable = false;
34+
}
3035

3136
if (React.Children.count(props.children) > 1) {
3237
throw new Error(SINGLE_CHILD_ERROR);

src/testUtils/index.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
// TODO: Remove use of Function
23
// tslint:disable:ban-types
34
import { ConfigProviderContext, fakePropType } from 'config/ConfigProvider';
@@ -49,6 +50,11 @@ export const getConfigProviderContext = (
4950
flowType: FlowTypes = FlowTypes.MESSAGING
5051
): ConfigProviderContext => {
5152
const flowEditorConfig = getFlowEditorConfig(flowType);
53+
const win = window as any;
54+
if (win.isMobile && win.isMobile()) {
55+
flowEditorConfig.mutable = false;
56+
}
57+
5258
const configProviderContext = { config: flowEditorConfig };
5359
return configProviderContext;
5460
};

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1496,10 +1496,10 @@
14961496
"@nodelib/fs.scandir" "2.1.3"
14971497
fastq "^1.6.0"
14981498

1499-
"@nyaruka/temba-components@0.72.1":
1500-
version "0.72.1"
1501-
resolved "https://registry.yarnpkg.com/@nyaruka/temba-components/-/temba-components-0.72.1.tgz#1ee11d763f1657ea9a038807dcdbe79f08b2e887"
1502-
integrity sha512-qyVdL10dz50V+rHBXZhlRwrHs428BXj+rhfSFqbtF8WSf8xn8HpVzlHnT+wZHoBnUCAE1h0btPCGfqdhiYmEOA==
1499+
"@nyaruka/temba-components@0.75.0":
1500+
version "0.75.0"
1501+
resolved "https://registry.yarnpkg.com/@nyaruka/temba-components/-/temba-components-0.75.0.tgz#3ff7b415c228f32d8b2d3c72f889e5889faf3fc1"
1502+
integrity sha512-7j4cJK/dy+t21rIGMjSw78zNA8aCmEdbZOjw8w9GThS/SLMSbh4m0DAsDSBSfQDrtjUrCxST+5eIf6XcNqW0xw==
15031503
dependencies:
15041504
"@lit/localize" "^0.11.4"
15051505
color-hash "^2.0.2"

0 commit comments

Comments
 (0)