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-dia-666/semantic-search-polish
Browse files Browse the repository at this point in the history
  • Loading branch information
yyassi-heartex authored Nov 22, 2023
2 parents 61b3f3a + 6c6a255 commit c5d1c39
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sync-pr-ls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}

env:
DOWNSTREAM_REPOSITORY: "label-studio-enterprise"
DOWNSTREAM_REPOSITORY: "label-studio"
DOWNSTREAM_EVENT_TYPE: "upstream_repo_update"

jobs:
Expand Down
27 changes: 17 additions & 10 deletions src/sdk/dm-sdk.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @global LSF */
/** @global LSF * /
/**
* @typedef {{
Expand Down Expand Up @@ -191,14 +191,7 @@ export class DataManager {

Object.assign(this.tabControls, config.tabControls ?? {});

if (config.actions) {
config.actions.forEach(([action, callback]) => {
if (!isDefined(action.id)) {
throw new Error("Every action must provide a unique ID");
}
this.actions.set(action.id, { action, callback });
});
}
this.updateActions(config.actions);

this.type = config.type ?? "dm";

Expand Down Expand Up @@ -262,7 +255,10 @@ export class DataManager {
if (!id) throw new Error("Action must provide a unique ID");

this.actions.set(id, { action, callback });
this.store.addActions(action);

const actions = Array.from(this.actions.values()).map(({ action }) => action);

this.store?.setActions(actions);
}

removeAction(id) {
Expand All @@ -280,6 +276,17 @@ export class DataManager {
});
}

updateActions(actions) {
if (!Array.isArray(actions)) return;

actions.forEach(([action, callback]) => {
if (!isDefined(action.id)) {
throw new Error("Every action must provide a unique ID");
}
this.addAction(action, callback);
});
}

registerInstrument(name, initializer) {
if (instruments[name]) {
return console.warn(`Can't override native instrument ${name}`);
Expand Down
17 changes: 11 additions & 6 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ export const AppStore = types
self.mode = mode;
},

addActions(...actions) {
self.availableActions.push(...actions);
setActions(actions) {
if (!Array.isArray(actions)) throw new Error("Actions must be an array");
self.availableActions = actions;
},

removeAction(id) {
Expand Down Expand Up @@ -454,7 +455,7 @@ export const AppStore = types
} else if (JSON.stringify(newProject ?? {}) !== JSON.stringify(self.project ?? {})) {
self.project = newProject;
}
if ( isFF(FF_LOPS_E_3) ) {
if (isFF(FF_LOPS_E_3)) {
const itemType = self.SDK.type === 'DE' ? 'dataset' : 'project';

self.SDK.invoke(`${itemType}Updated`, self.project);
Expand All @@ -470,7 +471,11 @@ export const AppStore = types
fetchActions: flow(function* () {
const serverActions = yield self.apiCall("actions");

self.addActions(...(serverActions ?? []));
const actions = (serverActions ?? []).map((action) => {
return [action, undefined];
});

self.SDK.updateActions(actions);
}),

fetchUsers: flow(function* () {
Expand All @@ -492,8 +497,8 @@ export const AppStore = types
];

if (!isLabelStream || (self.project?.show_annotation_history && task)) {
if(self.SDK.type === 'dm') {
requests.push(self.fetchActions());
if (self.SDK.type === 'dm') {
requests.push(self.fetchActions());
}

if (self.SDK.settings?.onlyVirtualTabs && self.project?.show_annotation_history && !task) {
Expand Down

0 comments on commit c5d1c39

Please sign in to comment.