Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Disallow editing nodes on mobile #1227

Merged
merged 3 commits into from
Mar 17, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "7.0.0",
"@nyaruka/temba-components": "0.72.1",
"@nyaruka/temba-components": "0.75.0",
"@testing-library/jest-dom": "4.0.0",
"@testing-library/react": "8.0.1",
"@types/common-tags": "^1.8.0",
Expand Down
8 changes: 7 additions & 1 deletion src/components/flow/Flow.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { react as bindCallbacks } from 'auto-bind';
import Button from 'components/button/Button';
import { Canvas } from 'components/canvas/Canvas';
Expand Down Expand Up @@ -146,6 +147,11 @@ export class Flow extends React.PureComponent<FlowStoreProps, {}> {
return (this.ghost = ref);
}

public isMobile() {
const win = window as any;
return win.isMobile && win.isMobile();
}

public componentDidMount(): void {
this.Plumber.bind('connection', (event: ConnectionEvent) =>
this.props.updateConnection(event.sourceId, event.targetId)
Expand Down Expand Up @@ -407,7 +413,7 @@ export class Flow extends React.PureComponent<FlowStoreProps, {}> {
{this.getNodeEditor()}

<Canvas
mutable={this.context.config.mutable}
mutable={!this.isMobile() && this.context.config.mutable}
draggingNew={!!this.props.ghostNode && !this.props.nodeEditorSettings}
newDragElement={this.getDragNode()}
onDragging={this.handleDragging}
Expand Down
5 changes: 5 additions & 0 deletions src/config/ConfigProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { FlowEditorConfig } from 'flowTypes';
import * as React from 'react';

Expand Down Expand Up @@ -27,6 +28,10 @@

constructor(props: ConfigProviderProps) {
super(props);
const win = window as any;
if (win.isMobile && win.isMobile()) {
this.props.config.mutable = false;

Check warning on line 33 in src/config/ConfigProvider.tsx

View check run for this annotation

Codecov / codecov/patch

src/config/ConfigProvider.tsx#L33

Added line #L33 was not covered by tests
}

if (React.Children.count(props.children) > 1) {
throw new Error(SINGLE_CHILD_ERROR);
Expand Down
6 changes: 6 additions & 0 deletions src/testUtils/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// TODO: Remove use of Function
// tslint:disable:ban-types
import { ConfigProviderContext, fakePropType } from 'config/ConfigProvider';
Expand Down Expand Up @@ -49,6 +50,11 @@
flowType: FlowTypes = FlowTypes.MESSAGING
): ConfigProviderContext => {
const flowEditorConfig = getFlowEditorConfig(flowType);
const win = window as any;
if (win.isMobile && win.isMobile()) {
flowEditorConfig.mutable = false;

Check warning on line 55 in src/testUtils/index.tsx

View check run for this annotation

Codecov / codecov/patch

src/testUtils/index.tsx#L55

Added line #L55 was not covered by tests
}

const configProviderContext = { config: flowEditorConfig };
return configProviderContext;
};
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1496,10 +1496,10 @@
"@nodelib/fs.scandir" "2.1.3"
fastq "^1.6.0"

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