Skip to content

Commit

Permalink
Hotfix issues with the floating action buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaslehnertum committed Nov 30, 2023
1 parent ee70f75 commit 695c940
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 44 deletions.
10 changes: 5 additions & 5 deletions src/main/compat/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Assessment, UMLElement, UMLRelationship } from '../typings';
import { UMLModelCompat } from './typings';
import {
isV2,
findElement as findElementV2,
addOrUpdateAssessment as addOrUpdateAssessmentV2,
addOrUpdateElement as addOrUpdateElementV2,
findRelationship as findRelationshipV2,
addOrUpdateRelationship as addOrUpdateRelationshipV2,
findAssessment as findAssessmentV2,
addOrUpdateAssessment as addOrUpdateAssessmentV2,
findElement as findElementV2,
findRelationship as findRelationshipV2,
isInteractiveElement as isInteractiveElementV2,
setInteractiveElement as setInteractiveElementV2,
isInteractiveRelationship as isInteractiveRelationshipV2,
isV2,
setInteractiveElement as setInteractiveElementV2,
setInteractiveRelationship as setInteractiveRelationshipV2,
} from './v2';

Expand Down
30 changes: 5 additions & 25 deletions src/main/components/uml-element/updatable/updatable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { FloatingButton } from './FloatingButton';
import { EditIcon } from './icons/EditIcon';
import { DeleteIcon } from './icons/DeleteIcon';

const FAB_TIMEOUT = 500;

const initialState = {
showActionButtons: false,
};
const initialState = {};

type StateProps = {
hovered: boolean;
Expand Down Expand Up @@ -67,31 +63,15 @@ export const updatable = (

const element = getById(props.id);

// We wait a few milliseconds before hiding the float action buttons
// to prevent the actions from being hidden un
if (!this.state.showActionButtons && (hovered || selected)) {
this.setState({ ...this.state, showActionButtons: true });

if (this.timer) {
clearTimeout(this.timer);
}
}

if (this.state.showActionButtons && !(hovered || selected)) {
this.timer = setTimeout(() => {
this.setState({ ...this.state, showActionButtons: false });
}, FAB_TIMEOUT);
}

const shouldRenderFABs = element && !UMLRelationship.isUMLRelationship(element);

return (
<WrappedComponent {...props}>
{shouldRenderFABs && (
<FloatingButton
style={{
opacity: this.state.showActionButtons ? 1 : 0,
transform: `translate(${element.bounds.width}px, ${this.state.showActionButtons ? -40 : -30}px)`,
opacity: selected ? 1 : 0,
transform: `translate(${element.bounds.width}px, ${selected ? -40 : -30}px)`,
}}
onClick={this.onStartUpdate}
>
Expand All @@ -101,8 +81,8 @@ export const updatable = (
{shouldRenderFABs && (
<FloatingButton
style={{
opacity: this.state.showActionButtons ? 1 : 0,
transform: `translate(${element.bounds.width}px, ${this.state.showActionButtons ? -80 : -30}px)`,
opacity: selected ? 1 : 0,
transform: `translate(${element.bounds.width}px, ${selected ? -80 : -30}px)`,
}}
onClick={this.onDelete}
>
Expand Down
5 changes: 1 addition & 4 deletions src/main/packages/bpmn/bpmn-swimlane/bpmn-swimlane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ export class BPMNSwimlane extends UMLContainer {
droppable: true,
movable: false,
connectable: false,
updatable: false,
resizable: 'HEIGHT',
};

type: UMLElementType = BPMNElementType.BPMNSwimlane;

// We set this flag to indicate that swimlanes should not be picked up by the layouter
// for resizing-based repositioning.
isManuallyLayouted = true;

render(layer: ILayer, children: ILayoutable[] = []): ILayoutable[] {
if (this.bounds.height < BPMNSwimlane.MIN_HEIGHT) {
this.bounds.height = BPMNSwimlane.MIN_HEIGHT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { UMLElementSelectorType } from '../../../packages/uml-element-selector-type';
import { Action } from '../../../utils/actions/actions';
import { UMLElementState } from '../uml-element-types';

export const enum RemoteSelectionActionTypes {
SELECTION_CHANGE = '@@element/remote-selection/CHANGE',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { UMLElementSelectorType } from '../../../packages/uml-element-selector-type';
import {
RemoteSelectionActionTypes,
RemoteSelectionChangeTypes,
RemoteSelectionChange,
RemoteSelectionChangeAction,
RemoteSelectionChangeTypes,
RemoteSelectionPruneSelectorsAction,
} from './remote-selectable-types';

Expand Down
1 change: 0 additions & 1 deletion src/main/services/uml-element/uml-element.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DeepPartial } from 'redux';
import { UMLDiagramType } from '../../packages/diagram-type';
import { UMLElementSelectorType } from '../../packages/uml-element-selector-type';
import { UMLElementType } from '../../packages/uml-element-type';
import { UMLRelationshipType } from '../../packages/uml-relationship-type';
import * as Apollon from '../../typings';
Expand Down
1 change: 0 additions & 1 deletion src/main/typings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { DeepPartial } from 'redux';
import { Styles } from './components/theme/styles';
import { UMLDiagramType } from './packages/diagram-type';
import { UMLElementSelectorType } from './packages/uml-element-selector-type';
import { UMLElementType } from './packages/uml-element-type';
import { UMLRelationshipType } from './packages/uml-relationship-type';
import { ApollonMode, Locale } from './services/editor/editor-types';
Expand Down
10 changes: 5 additions & 5 deletions src/tests/unit/compat/v2/helper-test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { deepClone } from 'fast-json-patch';

import {
UMLModelCompat,
findElement,
addOrUpdateAssessment,
addOrUpdateElement,
findRelationship,
addOrUpdateRelationship,
findAssessment,
addOrUpdateAssessment,
findElement,
findRelationship,
isInteractiveElement,
setInteractiveElement,
isInteractiveRelationship,
setInteractiveElement,
setInteractiveRelationship,
UMLModelCompat,
} from '../../../../main/compat';
import { Assessment, UMLElement, UMLModel, UMLRelationship } from '../../../../main';

Expand Down
2 changes: 1 addition & 1 deletion src/tests/unit/services/patcher/patcher-saga-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { take, delay, select, call } from 'redux-saga/effects';
import { call, delay, select, take } from 'redux-saga/effects';

import { patchLayout } from '../../../../main/services/patcher/patcher-saga';
import { PatcherActionTypes, PatcherRepository } from '../../../../main/services/patcher';
Expand Down

0 comments on commit 695c940

Please sign in to comment.