From e3184e4f3e44567fbc72d3700353ffce10ff62c5 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Tue, 20 Aug 2024 11:53:02 +0300 Subject: [PATCH 1/2] Fix logic for shortcut buttons --- scripts/api/article.ts | 4 ++-- scripts/api/navigation.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/api/article.ts b/scripts/api/article.ts index c155201bcf..4b97412153 100644 --- a/scripts/api/article.ts +++ b/scripts/api/article.ts @@ -311,9 +311,9 @@ function canPublishOnDesk(deskType: string): boolean { function showPublishAndContinue(item: IArticle, dirty: boolean): boolean { return appConfig.features?.customAuthoringTopbar?.publishAndContinue - && sdApi.navigation.isPersonalSpace() + && !sdApi.navigation.isPersonalSpace() && canPublishOnDesk(sdApi.desks.getDeskById(sdApi.desks.getCurrentDeskId()).desk_type) - && authoringApiCommon.checkShortcutButtonAvailability(item, dirty, sdApi.navigation.isPersonalSpace()); + && authoringApiCommon.checkShortcutButtonAvailability(item, dirty); } function showCloseAndContinue(item: IArticle, dirty: boolean): boolean { diff --git a/scripts/api/navigation.ts b/scripts/api/navigation.ts index 80b08ab3a5..397e03b3ed 100644 --- a/scripts/api/navigation.ts +++ b/scripts/api/navigation.ts @@ -20,7 +20,7 @@ function currentPathStartsWith( } function isPersonalSpace(): boolean { - return !(ng.get('$location').path() === '/workspace/personal'); + return ng.get('$location').path() === '/workspace/personal'; } export const navigation = { From 97b4b46211b9bcdafeaa15a4a3a4158f4ddb2d01 Mon Sep 17 00:00:00 2001 From: Konstantin Markov Date: Tue, 20 Aug 2024 12:32:43 +0300 Subject: [PATCH 2/2] use sdApi.navigation.isPersonalSpace --- scripts/api/article.ts | 4 +--- scripts/apps/archive/controllers/UploadController.ts | 3 ++- scripts/apps/archive/index.tsx | 2 +- scripts/apps/archive/services/ArchiveService.ts | 3 ++- .../apps/authoring/authoring/services/AuthoringService.ts | 5 +++-- scripts/apps/search/controllers/get-multi-actions.tsx | 2 +- .../ui/components/content-create-dropdown/initial-view.tsx | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/api/article.ts b/scripts/api/article.ts index 4b97412153..0c32436c18 100644 --- a/scripts/api/article.ts +++ b/scripts/api/article.ts @@ -74,9 +74,7 @@ function canPublish(item: IArticle): boolean { return false; } - const $location = ng.get('$location'); - - if ($location.path() === '/workspace/personal' && appConfig?.features?.publishFromPersonal !== true) { + if (sdApi.navigation.isPersonalSpace() && appConfig?.features?.publishFromPersonal !== true) { return false; } else { const deskId = item?.task?.desk; diff --git a/scripts/apps/archive/controllers/UploadController.ts b/scripts/apps/archive/controllers/UploadController.ts index 35e90452dd..7941cbe713 100644 --- a/scripts/apps/archive/controllers/UploadController.ts +++ b/scripts/apps/archive/controllers/UploadController.ts @@ -8,6 +8,7 @@ import {IPTCMetadata, IUser, IArticle} from 'superdesk-api'; import {appConfig} from 'appConfig'; import {fileUploadErrorModal} from './file-upload-error-modal'; import {showModal} from '@superdesk/common'; +import {sdApi} from 'api'; const isNotEmptyString = (value: any) => value != null && value !== ''; @@ -102,7 +103,7 @@ export function UploadController( $scope.allowAudio = !($scope.locals && $scope.locals.data && $scope.locals.data.allowAudio === false); $scope.validator = _.omit(appConfig.validator_media_metadata, ['archive_description']); $scope.parent = $scope.locals?.data?.parent || null; - $scope.deskSelectionAllowed = ($location.path() !== '/workspace/personal') && $scope.locals && + $scope.deskSelectionAllowed = !sdApi.navigation.isPersonalSpace() && $scope.locals && $scope.locals.data && $scope.locals.data.deskSelectionAllowed === true; if ($scope.deskSelectionAllowed === true) { diff --git a/scripts/apps/archive/index.tsx b/scripts/apps/archive/index.tsx index 53007fb390..919c00f43d 100644 --- a/scripts/apps/archive/index.tsx +++ b/scripts/apps/archive/index.tsx @@ -468,7 +468,7 @@ function spikeActivity(data, modal, $location, multi, }); function _spike() { - if ($location.path() === '/workspace/personal') { + if (sdApi.navigation.isPersonalSpace()) { return modal.confirm(gettext('Do you want to delete the item permanently?'), gettext('Confirm')) .then(() => sdApi.article.doSpike(data.item)); } diff --git a/scripts/apps/archive/services/ArchiveService.ts b/scripts/apps/archive/services/ArchiveService.ts index c8a20bda20..e6b319ff50 100644 --- a/scripts/apps/archive/services/ArchiveService.ts +++ b/scripts/apps/archive/services/ArchiveService.ts @@ -1,6 +1,7 @@ import _ from 'lodash'; import moment from 'moment'; import {appConfig} from 'appConfig'; +import {sdApi} from 'api'; ArchiveService.$inject = ['desks', 'session', 'api', '$q', 'search', '$location']; export function ArchiveService(desks, session, api, $q, search, $location) { @@ -11,7 +12,7 @@ export function ArchiveService(desks, session, api, $q, search, $location) { * @param {Object} desk when passed the item will be assigned to this desk instead of user's activeDesk. */ this.addTaskToArticle = function(item, desk = desks.getCurrentDesk()) { - if ((!item.task || !item.task.desk) && desk && $location.path() !== '/workspace/personal') { + if ((!item.task || !item.task.desk) && desk && !sdApi.navigation.isPersonalSpace()) { item.task = {desk: desk._id, stage: desk.working_stage, user: session.identity._id}; } }; diff --git a/scripts/apps/authoring/authoring/services/AuthoringService.ts b/scripts/apps/authoring/authoring/services/AuthoringService.ts index 84423da2b6..7d64d29c29 100644 --- a/scripts/apps/authoring/authoring/services/AuthoringService.ts +++ b/scripts/apps/authoring/authoring/services/AuthoringService.ts @@ -13,6 +13,7 @@ import {appConfig, extensions} from 'appConfig'; import {IPublishedArticle, IArticle, IExtensionActivationResult} from 'superdesk-api'; import {getPublishWarningConfirmModal} from '../components/publish-warning-confirm-modal'; import {authoringApiCommon} from 'apps/authoring-bridge/authoring-api-common'; +import {sdApi} from 'api'; function isReadOnly(item: IArticle) { return READONLY_STATES.includes(item.state); @@ -377,7 +378,7 @@ export function AuthoringService( ) { let extDiff = helpers.extendItem({}, diff); - if (extDiff['task'] && $location.path() !== '/workspace/personal') { + if (extDiff['task'] && !sdApi.navigation.isPersonalSpace()) { delete extDiff['task']; } @@ -815,7 +816,7 @@ export function AuthoringService( this._updateGeneralActions = function(currentItem, action) { let isReadOnlyState = this._isReadOnly(currentItem); let userPrivileges = privileges.privileges; - let isPersonalSpace = $location.path() === '/workspace/personal'; + const isPersonalSpace = sdApi.navigation.isPersonalSpace(); action.re_write = canRewrite(currentItem) === true && !isBeingCorrected(currentItem) && !isCorrection(currentItem); diff --git a/scripts/apps/search/controllers/get-multi-actions.tsx b/scripts/apps/search/controllers/get-multi-actions.tsx index da3d58bf9f..66ee1c8164 100644 --- a/scripts/apps/search/controllers/get-multi-actions.tsx +++ b/scripts/apps/search/controllers/get-multi-actions.tsx @@ -163,7 +163,7 @@ export function getMultiActions( }); }; - if ($location.path() === '/workspace/personal') { + if (sdApi.navigation.isPersonalSpace()) { modal.confirm(gettext('Do you want to delete the items permanently?')).then(spikeMultiple); return; } diff --git a/scripts/core/ui/components/content-create-dropdown/initial-view.tsx b/scripts/core/ui/components/content-create-dropdown/initial-view.tsx index 1be7b1866f..48ecfeef6f 100644 --- a/scripts/core/ui/components/content-create-dropdown/initial-view.tsx +++ b/scripts/core/ui/components/content-create-dropdown/initial-view.tsx @@ -194,7 +194,7 @@ export class InitialView extends React.PureComponent {
{ - sdApi.navigation.getPath() !== '/workspace/personal' && ( + !sdApi.navigation.isPersonalSpace() && (