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

do not show publishing tab for articles where desk_type is authoring and global noPublishOnAuthoringDesk config is set #4539

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 18 additions & 8 deletions scripts/api/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import {sendItems} from './article-send';
import {authoringApiCommon} from 'apps/authoring-bridge/authoring-api-common';
import {CONTENT_FIELDS_DEFAULTS} from 'apps/authoring/authoring/helpers';
import _ from 'lodash';

Check warning on line 33 in scripts/api/article.ts

View workflow job for this annotation

GitHub Actions / test

'_' is defined but never used

const isLocked = (_article: IArticle) => _article.lock_session != null;
const isLockedInCurrentSession = (_article: IArticle) => _article.lock_session === ng.get('session').sessionId;
Expand Down Expand Up @@ -66,20 +66,30 @@
item.state === ITEM_STATE.INGESTED;

function canPublish(item: IArticle): boolean {
const deskId = item?.task?.desk;

if (deskId == null) {
if (
sdApi.user.hasPrivilege('publish') !== true
|| item.flags?.marked_for_not_publication === true
|| item.state === 'draft'
) {
return false;
}

const desk = sdApi.desks.getAllDesks().get(deskId);
const $location = ng.get('$location');

if (desk.desk_type === 'authoring' && appConfig?.features?.noPublishOnAuthoringDesk === true) {
if ($location.path() === '/workspace/personal' && appConfig?.features?.publishFromPersonal !== true) {
return false;
}
} else {
const deskId = item?.task?.desk;

if (sdApi.user.hasPrivilege('publish') !== true) {
return false;
if (deskId == null) {
return false;
}

const desk = sdApi.desks.getAllDesks().get(deskId);

if (desk.desk_type === 'authoring' && appConfig?.features?.noPublishOnAuthoringDesk === true) {
return false;
}
}

return true;
Expand Down Expand Up @@ -265,7 +275,7 @@
});
}

function notifyPreconditionFailed($scope: any) {

Check warning on line 278 in scripts/api/article.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
notify.error(gettext('Item has changed since it was opened. ' +
'Please close and reopen the item to continue. ' +
'Regrettably, your changes cannot be saved.'));
Expand Down Expand Up @@ -569,7 +579,7 @@
canPublishOnDesk(deskType: string): boolean;
showCloseAndContinue(item: IArticle, dirty: boolean): boolean;
showPublishAndContinue(item: IArticle, dirty: boolean): boolean;
publishItem_legacy(orig: IArticle, item: IArticle, $scope: any, action?: IAuthoringActionType): Promise<boolean>;

Check warning on line 582 in scripts/api/article.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type

getItemPatchWithKillOrTakedownTemplate(item: IArticle, action: IAuthoringActionType): Promise<IArticle>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {addInternalEventListener, dispatchInternalEvent} from 'core/internal-eve
import {appConfig} from 'appConfig';
import {ITEM_STATE} from 'apps/archive/constants';
import {IArticleActionInteractive} from 'core/interactive-article-actions-panel/interfaces';
import {sdApi} from 'api';

/**
* @ngdoc directive
Expand Down Expand Up @@ -62,10 +63,14 @@ export function AuthoringTopbarDirective(
function getAvailableTabs(): Array<IArticleActionInteractive> {
if (scope.isCorrection(scope.item)) {
return ['send_to', 'correct'];
} else if (scope.item.flags?.marked_for_not_publication === true) {
return ['send_to'];
} else {
return ['send_to', 'publish'];
const result: Array<IArticleActionInteractive> = ['send_to'];

if (sdApi.article.canPublish(scope.item)) {
result.push('publish');
}

return result;
}
}

Expand Down
15 changes: 1 addition & 14 deletions scripts/apps/search/controllers/get-multi-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,7 @@ export function getMultiActions(
}

function canPublishItem() {
return getSelectedItems().every((item) => {
const desk = desks.getCurrentDesk();

if (privileges.userHasPrivileges({publish: 1})
&& !(desk.desk_type === 'authoring' && appConfig?.features?.noPublishOnAuthoringDesk)) {
if (item.state !== 'draft' && $location.path() !== '/workspace/personal') {
return true;
} else if (item.state !== 'draft' && $location.path() === '/workspace/personal') {
return appConfig?.features?.publishFromPersonal;
}
}

return false;
});
return getSelectedItems().every((item) => sdApi.article.canPublish(item));
}

/**
Expand Down
13 changes: 1 addition & 12 deletions scripts/core/interactive-article-actions-panel/index-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,11 @@ export class InteractiveArticleActionsPanel
const markupV2 = authoringReactViewEnabled && this.props.markupV2 === true;
const handleUnsavedChanges = this.props.handleUnsavedChanges ?? handleUnsavedChangesDefault;

const filteredTabs = tabs.filter((tab) => {
if (tab === 'publish') {
const item = items[0]; // only one item is supported in publishing tab
const notForPublication = item?.flags?.marked_for_not_publication ?? false;

return notForPublication !== true;
} else {
return true;
}
});

const panelHeader = (
<PanelHeader markupV2={markupV2}>
<div className="space-between" style={{width: '100%', paddingInlineEnd: 10}}>
<TabList
tabs={filteredTabs.map((id) => ({id, label: getTabLabel(id)}))}
tabs={tabs.map((id) => ({id, label: getTabLabel(id)}))}
selectedTabId={activeTab}
onChange={(tab: IArticleActionInteractive) => {
this.setState({
Expand Down
Loading