From 9fa505f6da153431b32b6515bbbdbd0ac142dc13 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Thu, 10 Oct 2024 15:25:55 +0300 Subject: [PATCH 01/14] Pass article through translate endpoint on create article (#4654) --- scripts/api/article.ts | 18 ++++++++++ .../services/TranslationService.ts | 26 +++++--------- .../core/get-superdesk-api-implementation.tsx | 2 ++ scripts/core/superdesk-api.d.ts | 2 ++ .../src/translations/translations-body.tsx | 35 ++++++++----------- 5 files changed, 45 insertions(+), 38 deletions(-) diff --git a/scripts/api/article.ts b/scripts/api/article.ts index 0c32436c18..ec468559d3 100644 --- a/scripts/api/article.ts +++ b/scripts/api/article.ts @@ -21,6 +21,7 @@ import { IAuthoringActionType, IDangerousArticlePatchingOptions, IDesk, + IExtensionActivationResult, IStage, onPublishMiddlewareResult, } from 'superdesk-api'; @@ -231,6 +232,21 @@ function createNewWithData(data: Partial, contentProfileId: string): v }); } +function translate( + item: IArticle, + language: string, +): Promise { + return httpRequestJsonLocal({ + method: 'POST', + path: '/archive/translate', + payload: { + guid: item.guid, + language: language, + desk: sdApi.desks.getCurrentDeskId(), + }, + }); +} + /** * Checks if associations is with rewrite_of item then open then modal to add associations. * The user has options to add associated media to the current item and review the media change @@ -514,6 +530,7 @@ function rewrite(item: IArticle): void { } interface IArticleApi { + translate(item: IArticle, language: string): Promise; get(id: IArticle['_id']): Promise; isLocked(article: IArticle): boolean; isEditable(article: IArticle): boolean; @@ -608,6 +625,7 @@ interface IArticleApi { } export const article: IArticleApi = { + translate, rewrite, isLocked, isEditable, diff --git a/scripts/apps/translations/services/TranslationService.ts b/scripts/apps/translations/services/TranslationService.ts index 282f294049..a83b28358f 100644 --- a/scripts/apps/translations/services/TranslationService.ts +++ b/scripts/apps/translations/services/TranslationService.ts @@ -1,9 +1,9 @@ import _, {flatMap} from 'lodash'; -import {AuthoringWorkspaceService} from 'apps/authoring/authoring/services/AuthoringWorkspaceService'; -import {gettext} from 'core/utils'; import {extensions} from 'appConfig'; -import {IExtensionActivationResult} from 'superdesk-api'; -import ng from 'core/services/ng'; +import {IArticle, IExtensionActivationResult} from 'superdesk-api'; +import {sdApi} from 'api'; +import {ILanguage} from 'superdesk-interfaces/Language'; +import {openArticle} from 'core/get-superdesk-api-implementation'; /** * @ngdoc service @@ -18,13 +18,10 @@ import ng from 'core/services/ng'; * @description Provides set of methods to translate items to different languages */ -TranslationService.$inject = ['api', '$rootScope', 'notify', 'authoringWorkspace', 'desks', 'search']; +TranslationService.$inject = ['api', '$rootScope', 'search']; export function TranslationService( api, $rootScope, - notify, - authoringWorkspace: AuthoringWorkspaceService, - desks, search, ) { var service: any = {}; @@ -59,14 +56,8 @@ export function TranslationService( * @param {Object} item item to be translated * @param {Object} language translate language */ - service.set = function(item, language) { - var params = { - guid: item.guid, - language: language.language, - desk: desks.getCurrentDeskId(), - }; - - api.save('translate', params).then((_item) => { + service.set = function(item: IArticle, language: ILanguage) { + sdApi.article.translate(item, language.language).then((_item) => { const onTranslateAfterMiddlewares : Array = flatMap( @@ -79,8 +70,7 @@ export function TranslationService( fn(item, _item); }); } else { - ng.get('authoringWorkspace').open(_item); - notify.success(gettext('Item Translated')); + return openArticle(_item._id, 'edit'); } $rootScope.$broadcast('item:translate'); diff --git a/scripts/core/get-superdesk-api-implementation.tsx b/scripts/core/get-superdesk-api-implementation.tsx index ec75915de0..786d2d9642 100644 --- a/scripts/core/get-superdesk-api-implementation.tsx +++ b/scripts/core/get-superdesk-api-implementation.tsx @@ -325,6 +325,8 @@ export function getSuperdeskApiImplementation( getExtensionConfig: () => extensions[requestingExtensionId]?.configuration ?? {}, entities: { article: { + translate: sdApi.article.translate, + get: sdApi.article.get, isPersonal: sdApi.article.isPersonal, isLocked: sdApi.article.isLocked, isLockedInCurrentSession: sdApi.article.isLockedInCurrentSession, diff --git a/scripts/core/superdesk-api.d.ts b/scripts/core/superdesk-api.d.ts index 90580e924b..75b3781ab7 100644 --- a/scripts/core/superdesk-api.d.ts +++ b/scripts/core/superdesk-api.d.ts @@ -2883,6 +2883,8 @@ declare module 'superdesk-api' { }; entities: { article: { + translate(article: IArticle, language: string): Promise; + get(articleId: IArticle['_id']): Promise; isLocked(article: IArticle): boolean; // returns true if locked by anyone, including the current user isLockedInCurrentSession(article: IArticle): boolean; isLockedInOtherSession(article: IArticle): boolean; diff --git a/scripts/extensions/ai-widget/src/translations/translations-body.tsx b/scripts/extensions/ai-widget/src/translations/translations-body.tsx index d0c073ae7c..cefc089213 100644 --- a/scripts/extensions/ai-widget/src/translations/translations-body.tsx +++ b/scripts/extensions/ai-widget/src/translations/translations-body.tsx @@ -124,26 +124,21 @@ export default class TranslationsBody extends React.Component { {this.props.mode === 'current' && ( - + From bcd9ebfff53d89ea7d76f616059cebc3c91f4504 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Fri, 25 Oct 2024 15:02:37 +0200 Subject: [PATCH 11/14] release 2.8.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index daad6a77d3..779c421786 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "superdesk-core", - "version": "2.8.0", + "version": "2.8.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ca1c18b8e1..12595ca296 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "superdesk-core", - "version": "2.8.0", + "version": "2.8.1", "license": "AGPL-3.0", "repository": { "type": "git", From d5bd677df0cc36c73b730004cff2ad5c678bd4ee Mon Sep 17 00:00:00 2001 From: Nikola Stojanovic <68916411+dzonidoo@users.noreply.github.com> Date: Mon, 25 Nov 2024 09:20:11 +0100 Subject: [PATCH 12/14] Add to planning dialog is frozen on CP instances (#4691) * zIndex prop * fix lint --- scripts/core/activity/views/activity-modal.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/core/activity/views/activity-modal.html b/scripts/core/activity/views/activity-modal.html index 8e54206c33..b48ce77a52 100644 --- a/scripts/core/activity/views/activity-modal.html +++ b/scripts/core/activity/views/activity-modal.html @@ -1,4 +1,4 @@ -