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

Fix logic for shortcut buttons #4606

Merged
merged 2 commits into from
Aug 20, 2024
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
8 changes: 3 additions & 5 deletions scripts/api/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -311,9 +309,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 {
Expand Down
2 changes: 1 addition & 1 deletion scripts/api/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion scripts/apps/archive/controllers/UploadController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== '';

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/apps/archive/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/apps/archive/services/ArchiveService.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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};
}
};
Expand Down
5 changes: 3 additions & 2 deletions scripts/apps/authoring/authoring/services/AuthoringService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'];
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/apps/search/controllers/get-multi-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class InitialView extends React.PureComponent<IProps, IState> {

<div>
{
sdApi.navigation.getPath() !== '/workspace/personal' && (
!sdApi.navigation.isPersonalSpace() && (
<DropdownOption
label={gettext('Create package')}
icon={{name: 'package-plus'}}
Expand Down
Loading