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

Adding next button to the labeling interface #12

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 17 additions & 7 deletions src/components/BottomBar/Controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const controlsInjector = inject(({ store }) => {

export const Controls = controlsInjector(observer(({ store, history, annotation }) => {
const isReview = store.hasInterface('review');

const historySelected = isDefined(store.annotationStore.selectedHistory);
const { userGenerate, sentUserGenerate, versions, results, editable: annotationEditable } = annotation;
const buttons = [];
Expand All @@ -40,10 +40,10 @@ export const Controls = controlsInjector(observer(({ store, history, annotation

const disabled = !annotationEditable || store.isSubmitting || historySelected || isInProgress;
const submitDisabled = store.hasInterface('annotations:deny-empty') && results.length === 0;

const buttonHandler = useCallback(async (e, callback, tooltipMessage) => {
const { addedCommentThisSession, currentComment, commentFormSubmit } = store.commentStore;

if (isInProgress) return;
setIsInProgress(true);
if(addedCommentThisSession){
Expand All @@ -57,10 +57,10 @@ export const Controls = controlsInjector(observer(({ store, history, annotation
}
setIsInProgress(false);
}, [
store.rejectAnnotation,
store.skipTask,
store.commentStore.currentComment,
store.commentStore.commentFormSubmit,
store.rejectAnnotation,
store.skipTask,
store.commentStore.currentComment,
store.commentStore.commentFormSubmit,
store.commentStore.addedCommentThisSession,
isInProgress,
]);
Expand Down Expand Up @@ -166,6 +166,16 @@ export const Controls = controlsInjector(observer(({ store, history, annotation

buttons.push(button);
}

buttons.push(
<ButtonTooltip key="next" title="Next">
<Button aria-label="next" onClick={async () => {
store.nextTaskInList();
}}>
Next Task
</Button>
</ButtonTooltip>,
);
}

return (
Expand Down
17 changes: 16 additions & 1 deletion src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import AnnotationStore from './Annotation/store';
import Project from './ProjectStore';
import Settings from './SettingsStore';
import Task from './TaskStore';
import { UserExtended } from './UserStore';
import { UserExtended } from './UserStore';
import { UserLabels } from './UserLabels';
import { FF_DEV_1536, FF_DEV_2715, FF_LLM_EPIC, FF_LSDV_4620_3_ML, FF_LSDV_4998, isFF } from '../utils/feature-flags';
import { CommentStore } from './Comment/CommentStore';
Expand Down Expand Up @@ -758,6 +758,20 @@ export default types
await getEnv(self).events.invoke('nextTask');
}

// nextTask will only call the next task in taskHistroy. We need to
// invoke the next task in the whole task list.
function nextTaskInList() {
// TODO: we should find better way to access the dataManager's Mobx Store
const taskList = window.dataManager.store.taskStore.list;
const thisTaskIdx = taskList.findIndex((x) => x.id === self.task.id);
Comment on lines +767 to +769

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the task list for the specific tab we came from? Or all of them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! Conveniently this is the list showed in the datamanager table, which is what is in the tab 🎉

I will add a comment on this!


if (thisTaskIdx === -1 || thisTaskIdx === taskList.length - 1) {
console.warn('nextTaskInList: No next task found!');
return;
}
getEnv(self).events.invoke('nextTask', taskList[thisTaskIdx + 1].id);
}

function nextTask() {
if (self.canGoNextTask) {
const { taskId, annotationId } = self.taskHistory[self.taskHistory.findIndex((x) => x.taskId === self.task.id) + 1];
Expand Down Expand Up @@ -826,6 +840,7 @@ export default types

addAnnotationToTaskHistory,
nextTask,
nextTaskInList,
prevTask,
postponeTask,
beforeDestroy() {
Expand Down
Loading