Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into fb-lsdv-5560/zoom-hotkeys
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/functional/package.json
#	tests/functional/yarn.lock
  • Loading branch information
Gondragos committed Sep 26, 2023
2 parents b10ba1e + 688ba57 commit 10da6ed
Show file tree
Hide file tree
Showing 30 changed files with 380 additions and 145 deletions.
16 changes: 16 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/javascript-node/.devcontainer/base.Dockerfile

# [Choice] Node.js version: 18
ARG VARIANT="18-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# [Optional] Uncomment if you want to install more global node modules
# RUN su node -c "npm install -g <your-package-list-here>"
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.194.0/containers/javascript-node
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 18
"args": {
"VARIANT": "18-bullseye"
}
},
// Set *default* container specific settings.json values on container create.
"settings": {},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"visualstudioexptteam.vscodeintellicode",
"mrmlnc.vscode-scss",
"firefox-devtools.vscode-firefox-debug",
"ms-vscode-remote.vscode-remote-extensionpack"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
}
4 changes: 4 additions & 0 deletions .github/workflows/build_bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: "[DEBUG] Print installed npm packages"
run: |
npm list --depth=1 || true
- name: Build distribution package
timeout-minutes: 10
run: yarn run build:module
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ jobs:
cd e2e
yarn install --frozen-lockfile
- name: "[DEBUG] Print installed npm packages"
run: |
npm list --depth=1 || true
- name: Run e2e test suite
timeout-minutes: 40
env:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ jobs:
set -euo pipefail
yarn install --frozen-lockfile
- name: "[DEBUG] Print installed npm packages"
run: |
npm list --depth=1 || true
- name: Run ESLint
uses: tj-actions/eslint-changed-files@v21
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/fun_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ jobs:
cd ./tests/functional
yarn install --frozen-lockfile
- name: "[DEBUG] Print installed npm packages"
run: |
npm list --depth=1 || true
- name: Run Cypress test suite
timeout-minutes: 40
env:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ jobs:
restore-keys: |
yarn-${{ env.CACHE_NAME_PREFIX }}-${{ runner.os }}-node-${{ env.NODE }}-
- name: Install dependencies for unit tests
run: yarn install --frozen-lockfile

- name: "[DEBUG] Print installed npm packages"
run: |
npm list --depth=1 || true
- name: Run unit tests
run: yarn install --frozen-lockfile && yarn test:coverage
run: yarn test:coverage

# - name: Upload coverage to Codecov
# uses: codecov/[email protected]
Expand Down
35 changes: 34 additions & 1 deletion src/components/BottomBar/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ export const Controls = controlsInjector(observer(({ store, history, annotation

if (isInProgress) return;
setIsInProgress(true);

const selected = store.annotationStore?.selected;

if(addedCommentThisSession){
selected?.submissionInProgress();
callback();
} else if((currentComment ?? '').trim()) {
e.preventDefault();
selected?.submissionInProgress();
await commentFormSubmit();
callback();
} else {
Expand All @@ -74,7 +79,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
if(store.hasInterface('comments:reject') ?? true) {
buttonHandler(e, () => store.rejectAnnotation({}), 'Please enter a comment before rejecting');
} else {
console.log('rejecting');
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.rejectAnnotation({});
}
Expand All @@ -91,6 +98,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
buttons.push(
<ButtonTooltip key="accept" title="Accept annotation: [ Ctrl+Enter ]">
<Button aria-label="accept-annotation" disabled={disabled} look="primary" onClick={async () => {
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.acceptAnnotation();
}}>
Expand All @@ -106,6 +116,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
buttons.push(
<ButtonTooltip key="cancel-skip" title="Cancel skip: []">
<Button aria-label="cancel-skip" disabled={disabled} look="primary" onClick={async () => {
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.unskipTask();
}}>
Expand All @@ -121,6 +134,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
if(store.hasInterface('comments:skip') ?? true) {
buttonHandler(e, () => store.skipTask({}), 'Please enter a comment before skipping');
} else {
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.skipTask({});
}
Expand All @@ -146,6 +162,10 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
onClick={async (event) => {
event.preventDefault();

const selected = store.annotationStore?.selected;

selected?.submissionInProgress();

if ('URLSearchParams' in window) {
const searchParams = new URLSearchParams(window.location.search);

Expand All @@ -154,6 +174,7 @@ export const Controls = controlsInjector(observer(({ store, history, annotation

window.history.pushState(null, '', newRelativePathQuery);
}

await store.commentStore.commentFormSubmit();
onClickMethod();
}}
Expand All @@ -179,6 +200,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
mod={{ has_icon: useExitOption, disabled: isDisabled }}
onClick={async (event) => {
if (event.target.classList.contains('lsf-dropdown__trigger')) return;
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.submitAnnotation();
}}
Expand Down Expand Up @@ -211,6 +235,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
mod={{ has_icon: useExitOption, disabled: isDisabled }}
onClick={async (event) => {
if (event.target.classList.contains('lsf-dropdown__trigger')) return;
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.updateAnnotation();
}}
Expand Down Expand Up @@ -241,6 +268,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
<ButtonTooltip key="submit" title={title}>
<Elem name="tooltip-wrapper">
<Button aria-label="submit" disabled={disabled || submitDisabled} look={look} onClick={async () => {
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.submitAnnotation();
}}>
Expand All @@ -256,6 +286,9 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
const button = (
<ButtonTooltip key="update" title="Update this task: [ Alt+Enter ]">
<Button aria-label="submit" disabled={disabled || submitDisabled} look={look} onClick={async () => {
const selected = store.annotationStore?.selected;

selected?.submissionInProgress();
await store.commentStore.commentFormSubmit();
store.updateAnnotation();
}}>
Expand Down
8 changes: 8 additions & 0 deletions src/components/ImageTransformer/ImageTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export default class TransformerComponent extends Component {
dragBoundFunc={this.dragBoundFunc}
onDragEnd={() => {
this.unfreeze();
setTimeout(this.checkNode);
}}
onTransformEnd={() => {
setTimeout(this.checkNode);
}}
backSelector={this.props.draggableBackgroundSelector}
/>
Expand Down Expand Up @@ -249,6 +253,10 @@ export default class TransformerComponent extends Component {
dragBoundFunc={this.dragBoundFunc}
onDragEnd={() => {
this.unfreeze();
setTimeout(this.checkNode);
}}
onTransformEnd={() => {
setTimeout(this.checkNode);
}}
backSelector={this.props.draggableBackgroundSelector}
/>
Expand Down
8 changes: 8 additions & 0 deletions src/components/ImageView/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export const RELATIVE_STAGE_WIDTH = 100;
*/
export const RELATIVE_STAGE_HEIGHT = 100;

/**
* Mode of snapping to pixel
*/
export const SNAP_TO_PIXEL_MODE = {
EDGE: 'edge',
CENTER: 'center',
};

export const Image = observer(forwardRef(({
imageEntity,
imageTransform,
Expand Down
4 changes: 2 additions & 2 deletions src/components/ImageView/ImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ const TransformerBack = observer(({ item }) => {
}}
onDragStart={e => {
dragStartPointRef.current = {
x: e.target.getAttr('x'),
y: e.target.getAttr('y'),
x: item.canvasToInternalX(e.target.getAttr('x')),
y: item.canvasToInternalY(e.target.getAttr('y')),
};
}}
dragBoundFunc={(pos) => {
Expand Down
11 changes: 10 additions & 1 deletion src/components/InstructionsModal/InstructionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const InstructionsModal = ({
visible: boolean,
onCancel: () => void,
}) => {
const contentStyle: Record<string, string> = { padding: '0 24px 24px', whiteSpace: 'pre-wrap' };

return (
<>
<Modal
Expand Down Expand Up @@ -45,7 +47,14 @@ export const InstructionsModal = ({
>
{title}
</h2>
<p style={{ padding: '0 24px 24px', whiteSpace: 'pre-wrap' }}>{children}</p>
{typeof children === 'string' ? (
<p
style={contentStyle}
dangerouslySetInnerHTML={{ __html: children }}
/>
) : (
<p style={contentStyle}>{children}</p>
)}
</Modal>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import { fireEvent, render, screen } from '@testing-library/react';
import { InstructionsModal } from '../InstructionsModal';

describe('InstructionsModal Component', () => {
Expand All @@ -16,6 +16,20 @@ describe('InstructionsModal Component', () => {
expect(document.body.contains(getByText('Test Children'))).toBe(true);
});

it('should render html', () => {
const title = 'Test Title';
const children = '<h1 style="color: red;">Test Children</h1>';

render(
<InstructionsModal title={title} visible={true} onCancel={() => {}}>
{children}
</InstructionsModal>,
);

expect(screen.queryByText('Test Children')).toBeTruthy();
expect(screen.queryByText('color: red')).toBeNull();
});

it('should call onCancel when the modal is cancelled', () => {
const onCancel = jest.fn();
const { getByLabelText } = render(
Expand Down
2 changes: 2 additions & 0 deletions src/components/SidePanels/OutlinerPanel/OutlinerTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ const useEventHandlers = () => {

if (wasNotSelected) {
annotation.selectArea(self);
// post-select hook
self.onSelectInOutliner?.(wasNotSelected);
} else {
annotation.unselectAll();
}
Expand Down
24 changes: 18 additions & 6 deletions src/regions/KeyPointRegion.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@ const KeyPointRegionAbsoluteCoordsDEV3793 = types
},

setPosition(x, y) {
self.x = x;
self.y = y;
const point = self.control?.getSnappedPoint({
x: self.parent.canvasToInternalX(x),
y: self.parent.canvasToInternalY(y),
});

self.relativeX = (x / self.parent.stageWidth) * RELATIVE_STAGE_WIDTH;
self.relativeY = (y / self.parent.stageHeight) * RELATIVE_STAGE_HEIGHT;
self.x = point.x;
self.y = point.y;

self.relativeX = (point.x / self.parent.stageWidth) * RELATIVE_STAGE_WIDTH;
self.relativeY = (point.y / self.parent.stageHeight) * RELATIVE_STAGE_HEIGHT;
},

updateImageSize(wp, hp, sw, sh) {
Expand Down Expand Up @@ -117,8 +122,13 @@ const Model = types
}))
.actions(self => ({
setPosition(x, y) {
self.x = self.parent.canvasToInternalX(x);
self.y = self.parent.canvasToInternalY(y);
const point = self.control?.getSnappedPoint({
x: self.parent.canvasToInternalX(x),
y: self.parent.canvasToInternalY(y),
});

self.x = point.x;
self.y = point.y;
},

updateImageSize() {},
Expand Down Expand Up @@ -227,6 +237,8 @@ const HtxKeyPointView = ({ item, setShapeRef }) => {
const t = e.target;

item.setPosition(t.getAttr('x'), t.getAttr('y'));
t.setAttr('x', item.canvasX);
t.setAttr('y', item.canvasY);
item.annotation.history.unfreeze(item.id);
item.notifyDrawingFinished();
}}
Expand Down
Loading

0 comments on commit 10da6ed

Please sign in to comment.