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-1476/preselected-taxonomy
Browse files Browse the repository at this point in the history
  • Loading branch information
hlomzik committed Oct 2, 2023
2 parents ab24ec1 + 95fb62a commit dd77647
Show file tree
Hide file tree
Showing 110 changed files with 346 additions and 286 deletions.
2 changes: 1 addition & 1 deletion src/assets/icons/outliner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export { ReactComponent as IconOutlinerExpand } from './expand.svg';
export { ReactComponent as IconOutlinerDrag } from './drag.svg';
export { ReactComponent as IconInfo } from './info.svg';
export { ReactComponent as IconOutlinerEyeOpened } from './eye_opened.svg';
export { ReactComponent as IconOutlinerEyeClosed } from './eye_closed.svg';
export { ReactComponent as IconOutlinerEyeClosed } from './eye_closed.svg';
4 changes: 2 additions & 2 deletions src/common/Dropdown/DropdownTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getMinIndex = (element?: HTMLElement) => {
if (element) {
let parent = element.parentElement;

while(parent) {
while (parent) {
const parentIndex = parseInt(getComputedStyle(parent).zIndex);

if (!isNaN(parentIndex)) {
Expand Down Expand Up @@ -43,7 +43,7 @@ export const DropdownTrigger = forwardRef<DropdownRef, DropdownTriggerProps>(({
closeOnClickOutside = true,
disabled = false,
...props
}, ref ) => {
}, ref) => {
const dropdownRef = (ref ?? useRef<DropdownRef>()) as RefObject<DropdownRef>;
const triggerEL = Children.only(children);
const childset = useRef(new Set<DropdownContextValue>());
Expand Down
18 changes: 9 additions & 9 deletions src/common/Range/Range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ export interface RangeProps {
onMaxIconClick?: (value: RangeValueType) => void;
}

const arrayReverse = <T extends any[] = any[]>(array: T, reverse=false) => {
const arrayReverse = <T extends any[] = any[]>(array: T, reverse = false) => {
return reverse ? [...array].reverse() : array;
};

export const Range: FC<RangeProps> = ({
value,
defaultValue,
multi=false,
reverse=false,
continuous=false,
min=0,
max=100,
step=1,
size=120,
align='horizontal',
multi = false,
reverse = false,
continuous = false,
min = 0,
max = 100,
step = 1,
size = 120,
align = 'horizontal',
resetValue,
minIcon,
maxIcon,
Expand Down
2 changes: 1 addition & 1 deletion src/common/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const Select: SelectComponent<SelectProps> = ({

const selected = useMemo(() => {
if (isFF(FF_DEV_2669) && multiple && renderMultipleSelected) {
return renderMultipleSelected(Array.isArray(currentValue) ? currentValue : [currentValue||'']);
return renderMultipleSelected(Array.isArray(currentValue) ? currentValue : [currentValue || '']);
}
if (multiple && Array.isArray(currentValue) && currentValue?.length > 1) {
return <>Multiple values selected</>;
Expand Down
2 changes: 1 addition & 1 deletion src/common/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const TextArea: FC<TextAreaProps> = ({

let newHeight: number;

if(textarea.scrollHeight > autoGrowRef.current.maxHeight){
if (textarea.scrollHeight > autoGrowRef.current.maxHeight) {
textarea.style.overflowY = 'scroll';
newHeight = autoGrowRef.current.maxHeight;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/common/TimeAgo/TimeAgo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ export const TimeAgo = ({ date, ...rest }: TimeAgoProps) => {
{text}
</time>
);
};
};
2 changes: 1 addition & 1 deletion src/common/Userpic/Userpic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const Userpic = forwardRef<any, UserpicProps>(({
const [nameVisible, setNameVisible] = useState(true);

if (isFF(FF_DEV_1507)) {
useEffect(()=>{
useEffect(() => {
if (propsSrc !== finalSrc) {
setFinalSrc(propsSrc);
setImgVisible(false);
Expand Down
4 changes: 2 additions & 2 deletions src/components/AnnotationsCarousel/AnnotationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block, Elem } from '../../utils/bem';
import { Userpic } from '../../common/Userpic/Userpic';
import { IconAnnotationGroundTruth, IconAnnotationSkipped2, IconDraftCreated2, IconDuplicate, IconEllipsis, IconTrashRect, LsCommentResolved, LsCommentUnresolved, LsSparks, LsStar, LsStarOutline } from '../../assets/icons';
import { userDisplayName } from '../../utils/utilities';
import { TimeAgo } from '../../common/TimeAgo/TimeAgo';
import { TimeAgo } from '../../common/TimeAgo/TimeAgo';
import './AnnotationButton.styl';
import { useCallback, useEffect, useState } from 'react';
import { Dropdown } from '../../common/Dropdown/Dropdown';
Expand Down Expand Up @@ -214,7 +214,7 @@ export const AnnotationButton = observer(({ entity, capabilities, annotationStor
<Elem name='contextMenu'>
<Dropdown.Trigger
content={<ContextMenu entity={entity} capabilities={capabilities} annotationStore={annotationStore} />}
onToggle={(isVisible)=> setIsContextMenuOpen(isVisible)}
onToggle={(isVisible) => setIsContextMenuOpen(isVisible)}
>
<Elem name='ellipsisIcon'>
<IconEllipsis width={28} height={28}/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/AnnotationsCarousel/AnnotationsCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ export const AnnotationsCarousel = observer(({ store, annotationStore }: Annotat
</Elem>
)}
</Block>
): null;
) : null;
});
4 changes: 2 additions & 2 deletions src/components/AnnotationsCarousel/__tests__/sampleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,7 @@ const annotationStore = {
'validation': null,
'sharedStores': {},
};
const commentStore = { 'loading':'list','comments':[] };
const commentStore = { 'loading': 'list','comments': [] };
const store = {
'config': '<View>\\n <Image name="image" value="$image"/><RectangleLabels name="label" toName="image"><Label value="Airplane" background="green"/><Label value="Car" background="blue"/></RectangleLabels></View>',
'task': {
Expand Down Expand Up @@ -6031,4 +6031,4 @@ const store = {
'hasInterface': () => true,
};

export { annotationStore, commentStore, store };
export { annotationStore, commentStore, store };
2 changes: 1 addition & 1 deletion src/components/App/Annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export function Annotation({ annotation, root }) {
};
}, [annotation.pk, annotation.id]);
return root ? Tree.renderItem(root, annotation) : null;
}
}
4 changes: 2 additions & 2 deletions src/components/App/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class Item extends Component {
return o.isReady
? Promise.resolve(o.isReady)
: new Promise(resolve => {
const dispose = observe(o, 'isReady', ()=>{
const dispose = observe(o, 'isReady', () => {
dispose();
resolve();
});
});
})).then(()=>{
})).then(() => {
// ~2 ticks for canvas to be rendered and resized completely
setTimeout(this.props.onFinish, 32);
});
Expand Down
16 changes: 8 additions & 8 deletions src/components/BottomBar/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export const Controls = controlsInjector(observer(({ store, history, annotation

const selected = store.annotationStore?.selected;

if(addedCommentThisSession){
if (addedCommentThisSession) {
selected?.submissionInProgress();
callback();
} else if((currentComment ?? '').trim()) {
} else if ((currentComment ?? '').trim()) {
e.preventDefault();
selected?.submissionInProgress();
await commentFormSubmit();
Expand All @@ -75,8 +75,8 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
const RejectButton = useMemo(() => {
return (
<ButtonTooltip key="reject" title="Reject annotation: [ Ctrl+Space ]">
<Button aria-label="reject-annotation" disabled={disabled} onClick={async (e)=> {
if(store.hasInterface('comments:reject') ?? true) {
<Button aria-label="reject-annotation" disabled={disabled} onClick={async (e) => {
if (store.hasInterface('comments:reject') ?? true) {
buttonHandler(e, () => store.rejectAnnotation({}), 'Please enter a comment before rejecting');
} else {
const selected = store.annotationStore?.selected;
Expand Down Expand Up @@ -130,8 +130,8 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
if (store.hasInterface('skip')) {
buttons.push(
<ButtonTooltip key="skip" title="Cancel (skip) task: [ Ctrl+Space ]">
<Button aria-label="skip-task" disabled={disabled} onClick={async (e)=> {
if(store.hasInterface('comments:skip') ?? true) {
<Button aria-label="skip-task" disabled={disabled} onClick={async (e) => {
if (store.hasInterface('comments:skip') ?? true) {
buttonHandler(e, () => store.skipTask({}), 'Please enter a comment before skipping');
} else {
const selected = store.annotationStore?.selected;
Expand Down Expand Up @@ -206,7 +206,7 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
await store.commentStore.commentFormSubmit();
store.submitAnnotation();
}}
icon={useExitOption &&(
icon={useExitOption && (
<Dropdown.Trigger
content={<SubmitOption onClickMethod={store.submitAnnotation} isUpdate={false} />}
>
Expand Down Expand Up @@ -241,7 +241,7 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
await store.commentStore.commentFormSubmit();
store.updateAnnotation();
}}
icon={useExitOption &&(
icon={useExitOption && (
<Dropdown.Trigger
content={<SubmitOption onClickMethod={store.updateAnnotation} isUpdate={isUpdate} />}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Comments/CommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const CommentForm: FC<CommentFormProps> = observer(({

await commentStore.addComment(comment);

} catch(err) {
} catch (err) {
actionRef.current.update?.(comment || '');
console.error(err);
}
Expand All @@ -54,7 +54,7 @@ export const CommentForm: FC<CommentFormProps> = observer(({


useEffect(() => {
if(!isFF(FF_DEV_3873)){
if (!isFF(FF_DEV_3873)) {
commentStore.setAddedCommentThisSession(false);
clearTooltipMessage();
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Comments/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { FF_DEV_3034, isFF } from '../../utils/feature-flags';
import './Comments.styl';


export const Comments: FC<{ commentStore: any, cacheKey?: string }>= observer(({ commentStore, cacheKey }) => {
export const Comments: FC<{ commentStore: any, cacheKey?: string }> = observer(({ commentStore, cacheKey }) => {
const mounted = useMounted();

const loadComments = async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/CurrentEntity/AnnotationHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const HistoryItemComponent: FC<{
const isPrediction = entity?.type === 'prediction';

const reason = useMemo(() => {
switch(acceptedState) {
switch (acceptedState) {
case 'accepted': return 'Accepted';
case 'rejected': return 'Rejected';
case 'fixed_and_accepted': return 'Fixed';
Expand Down Expand Up @@ -293,7 +293,7 @@ const HistoryComment: FC<{

const HistoryIcon: FC<{type: HistoryItemType}> = ({ type }) => {
const icon = useMemo(() => {
switch(type) {
switch (type) {
case 'submitted': return <IconAnnotationSubmitted style={{ color: '#0099FF' }}/>;
case 'updated': return <IconAnnotationSubmitted style={{ color: '#0099FF' }}/>;
case 'draft_created': return <IconDraftCreated style={{ color: '#0099FF' }}/>;
Expand Down
26 changes: 13 additions & 13 deletions src/components/Entities/LabelList.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ export const LabelList = observer(({ regionStore }) => {
};
});

if( isFF(FF_DEV_2755) ) {
const [collapsedPos, setCollapsedPos] = useState( localStorage.getItem( localStoreName )?.split?.(',')?.filter( pos => !!pos ) ?? [] );
if (isFF(FF_DEV_2755)) {
const [collapsedPos, setCollapsedPos] = useState(localStorage.getItem(localStoreName)?.split?.(',')?.filter(pos => !!pos) ?? []);

const updateLocalStorage = ( collapsedPos ) => {
localStorage.setItem( localStoreName, collapsedPos );
const updateLocalStorage = (collapsedPos) => {
localStorage.setItem(localStoreName, collapsedPos);
};

const collapse = ( pos ) => {
const collapse = (pos) => {
const newCollapsedPos = [...collapsedPos, pos];

setCollapsedPos( newCollapsedPos );
updateLocalStorage( newCollapsedPos );
setCollapsedPos(newCollapsedPos);
updateLocalStorage(newCollapsedPos);
};

const expand = ( pos ) => {
const newCollapsedPos = collapsedPos.filter( cPos => cPos !== pos );
const expand = (pos) => {
const newCollapsedPos = collapsedPos.filter(cPos => cPos !== pos);

setCollapsedPos( newCollapsedPos );
updateLocalStorage( newCollapsedPos );
setCollapsedPos(newCollapsedPos);
updateLocalStorage(newCollapsedPos);
};
const expandedKeys = treeData.filter( (item) => !collapsedPos.includes( item.pos ) ).map( item => item.key ) ?? [];
const expandedKeys = treeData.filter((item) => !collapsedPos.includes(item.pos)).map(item => item.key) ?? [];

return (
<Tree
Expand All @@ -56,7 +56,7 @@ export const LabelList = observer(({ regionStore }) => {
autoExpandParent={true}
expandedKeys={expandedKeys}
switcherIcon={<LsChevron className={styles.switcherIcon} opacity="0.25" />}
onExpand={( internalExpandedKeys, { node } ) => {
onExpand={(internalExpandedKeys, { node }) => {
const region = treeData.find(region => region.key === node.key);
const pos = region.pos;

Expand Down
10 changes: 5 additions & 5 deletions src/components/Entities/RegionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const RegionItemDesc = observer(({ item, setDraggable }) => {
const controls = item.perRegionDescControls || [];

return (
<Elem name="desc" tag="div" mod={{ collapsed, empty: !(controls?.length > 0) }} onMouseEnter={()=>{setDraggable?.(false);}} onMouseLeave={()=>{setDraggable?.(true);}}>
<Elem name="desc" tag="div" mod={{ collapsed, empty: !(controls?.length > 0) }} onMouseEnter={() => { setDraggable?.(false); }} onMouseLeave={() => { setDraggable?.(true); }}>
<Elem name="controls">
{controls.map((tag, idx) => {
const View = Registry.getPerRegionView(tag.type, PER_REGION_MODES.REGION_LIST);
Expand All @@ -45,7 +45,7 @@ const RegionItemDesc = observer(({ item, setDraggable }) => {
const RegionItemContent = observer(({ idx, item, setDraggable }) => {
const itemElRef = useRef();

useEffect(()=>{
useEffect(() => {
if (item.selected) {
const el = itemElRef.current;

Expand All @@ -56,7 +56,7 @@ const RegionItemContent = observer(({ idx, item, setDraggable }) => {
}
}, [item.selected]);
return (
<Block ref={itemElRef} name="region-item" mod={{ hidden : item.hidden }} data-testid={`regionitem:selected=${item.selected}`}>
<Block ref={itemElRef} name="region-item" mod={{ hidden: item.hidden }} data-testid={`regionitem:selected=${item.selected}`}>
<Elem name="header" tag="div">
<Elem name="counter">{isDefined(idx) ? idx + 1 : ''}</Elem>

Expand Down Expand Up @@ -106,7 +106,7 @@ const RegionItemContent = observer(({ idx, item, setDraggable }) => {
});

export const RegionItem = observer(({ item, idx, flat, setDraggable, onClick }) => {
const getVars = useMemo(()=>{
const getVars = useMemo(() => {
let vars;

return () => {
Expand Down Expand Up @@ -134,7 +134,7 @@ export const RegionItem = observer(({ item, idx, flat, setDraggable, onClick })
<List.Item
key={item.id}
className={classnames.join(' ')}
onClick={(e)=>{onClick(e, item);}}
onClick={(e) => { onClick(e, item); }}
onMouseOver={() => item.setHighlight(true)}
onMouseOut={() => item.setHighlight(false)}
style={vars}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Entities/RegionTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const RegionTree = observer(({ regionStore }) => {
}, [renderNow]);

const canDrag = useRef(true);
const setDraggable = useCallback((isDraggable)=>{
const setDraggable = useCallback((isDraggable) => {
canDrag.current = isDraggable;
}, []);

Expand All @@ -40,7 +40,7 @@ export const RegionTree = observer(({ regionStore }) => {
const classifications = regionStore.classifications.map(item => ({
classification: true,
key: item.id,
title: <RegionItem item={item} flat setDraggable={setDraggable} />,
title: <RegionItem item={item} flat setDraggable={setDraggable} />,
}));

const treeData = [...classifications, ...regions];
Expand Down
6 changes: 3 additions & 3 deletions src/components/Filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ export const Filter: FC<FilterInterface> = ({
<IconFilter />
</Elem>
<Elem name={'text'} style={{
fontSize:isFF(FF_DEV_3873) && 12,
fontWeight:isFF(FF_DEV_3873) && 500,
lineHeight:isFF(FF_DEV_3873) && '24px',
fontSize: isFF(FF_DEV_3873) && 12,
fontWeight: isFF(FF_DEV_3873) && 500,
lineHeight: isFF(FF_DEV_3873) && '24px',
}}>Filter</Elem>
{filterList.length > 0 && <Elem name={'filter-length'} data-testid={'filter-length'}>{filterList.length}</Elem>}
</Block>
Expand Down
Loading

0 comments on commit dd77647

Please sign in to comment.