Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IconChevronDown, IconChevronRight, IconTrash } from "@humansignal/icons";
import { Button, Spinner, Tooltip } from "@humansignal/ui";
import { inject, observer } from "mobx-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import { Block, Elem } from "../../../utils/bem";
import { FF_LOPS_E_3, isFF } from "../../../utils/feature-flags";
import { Dropdown } from "../../Common/Dropdown/DropdownComponent";
Expand Down Expand Up @@ -205,19 +205,19 @@ export const ActionsButton = injector(
const selectedCount = store.currentView.selectedCount;
const [isOpen, setIsOpen] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const fetchedActionsRef = useRef(false);

const actions = useMemo(() => {
return store.availableActions.filter((a) => !a.hidden).sort((a, b) => a.order - b.order);
}, [store.availableActions]);
const actions = store.availableActions.filter((a) => !a.hidden).sort((a, b) => a.order - b.order);

useEffect(() => {
if (isOpen && actions.length === 0) {
if (isOpen && !fetchedActionsRef.current) {
setIsLoading(true);
store.fetchActions().finally(() => {
setIsLoading(false);
});
fetchedActionsRef.current = true;
}
}, [isOpen, actions, store]);
}, [isOpen, store]);

const actionButtons = actions.map((action) => (
<ActionButton key={action.id} action={action} parentRef={formRef} store={store} formRef={formRef} />
Expand All @@ -227,7 +227,15 @@ export const ActionsButton = injector(
return (
<Dropdown.Trigger
content={
<Menu size="compact">{isLoading ? <Menu.Item disabled>Loading actions...</Menu.Item> : actionButtons}</Menu>
<Menu size="compact">
{isLoading ? (
<Menu.Item disabled data-testid="loading-actions">
Loading actions...
</Menu.Item>
) : (
actionButtons
)}
</Menu>
}
openUpwardForShortViewport={false}
disabled={!hasSelected}
Expand Down
7 changes: 1 addition & 6 deletions web/libs/datamanager/src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,6 @@ export const AppStore = types
}

if (!isLabelStream || (self.project?.show_annotation_history && task)) {
if (self.SDK.type === "dm") {
// Fetch actions in background to avoid blocking the main thread
setTimeout(() => self.fetchActions(), 0);
}

if (self.SDK.settings?.onlyVirtualTabs && self.project?.show_annotation_history && !task) {
requests.push(
self.viewsStore.addView(
Expand Down Expand Up @@ -751,7 +746,7 @@ export const AppStore = types
}

if (actionCallback instanceof Function) {
const result = yield actionCallback(actionParams, view);
const result = actionCallback(actionParams, view);
self.SDK.invoke("actionDialogOkComplete", actionId, {
result,
view: viewReloaded,
Expand Down
Loading