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

Planning integration adjustments #4686

Merged
merged 39 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
92c036a
Fix article content profile switch in authoring
thecalcc Nov 11, 2024
bd800ca
Fix lint
thecalcc Nov 11, 2024
9f49051
Merge branch 'develop' into fix-profile-dropdown
thecalcc Nov 11, 2024
fd9c4e5
Changes after review
thecalcc Nov 13, 2024
cfdac74
Lint
thecalcc Nov 13, 2024
d0f3fa6
Changes v2
thecalcc Nov 13, 2024
570e447
Cleanup authoring for planning integration and more
thecalcc Nov 13, 2024
a5ef6ab
Lint
thecalcc Nov 13, 2024
5ddb0b3
Fix more lint issues
thecalcc Nov 13, 2024
3c6a7c9
Merge branch 'develop' into planning-integration-adjustments
thecalcc Nov 13, 2024
7f632fc
Don't render collapse header button if header has no fields defined
thecalcc Nov 13, 2024
7d0862c
Fix secondary toolbar
thecalcc Nov 13, 2024
6716871
More lint fixes
thecalcc Nov 13, 2024
a4c889c
Fix lint
thecalcc Nov 13, 2024
1a18bf6
Lint fix
thecalcc Nov 14, 2024
34b0539
test fix
thecalcc Nov 14, 2024
1ca8807
One more fix
thecalcc Nov 14, 2024
6e7290f
fix unit tests
tomaskikutis Nov 14, 2024
539ab62
Remove fix
thecalcc Nov 14, 2024
0334e1b
Remove zIndex
thecalcc Nov 14, 2024
084e764
Final fix
thecalcc Nov 14, 2024
b7697ed
Fix config
thecalcc Nov 15, 2024
f44c0ff
Add more vocabs to stub
thecalcc Nov 15, 2024
d521ed6
Fix lint
thecalcc Nov 15, 2024
01ad7e3
Fix a part of tests
thecalcc Nov 19, 2024
32123df
Pin chrome version, adjust workflow file
thecalcc Nov 20, 2024
a18df9b
Fix lint
thecalcc Nov 20, 2024
c8cae9f
Fix workflow v2
thecalcc Nov 20, 2024
ce75f68
Empty commit
thecalcc Nov 21, 2024
42956c8
Fix workflow file attempt 1
thecalcc Nov 21, 2024
e726ca6
Fix wf file formatting
thecalcc Nov 21, 2024
59f72ce
Fix formatting
thecalcc Nov 21, 2024
4dade8b
Change workflow for protractor
thecalcc Nov 21, 2024
a418e48
Try again
thecalcc Nov 21, 2024
8e501ba
Add working directory
thecalcc Nov 21, 2024
7a344cd
Merge branch 'develop' into planning-integration-adjustments
thecalcc Nov 25, 2024
b397f46
Fix tests
thecalcc Nov 25, 2024
a3fd979
Changes after review
thecalcc Nov 25, 2024
9f9543e
Merge branch 'develop' into planning-integration-adjustments
thecalcc Dec 3, 2024
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
16 changes: 7 additions & 9 deletions e2e/client/specs/helpers/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ class Monitoring {
* @param {boolean} useFullButtonText
* @param {boolean} confirm Accept confirmation dialog.
*/
this.actionOnItem = function(action, group, item, useFullButtonText, confirm) {
var menu = this.openItemMenu(group, item);
this.actionOnItem = function(action, group, item, useFullButtonText = true, confirm) {
const menu: ElementFinder = this.openItemMenu(group, item);

browser.wait(() => menu.isPresent(), 3000);

Expand Down Expand Up @@ -471,14 +471,12 @@ class Monitoring {
* @param {number} item
*/
this.actionOnItemSubmenu = function(action, submenu, group, item) {
var menu = this.openItemMenu(group, item);
var header = menu.element(by.partialButtonText(action));
var btn = menu.all(by.partialButtonText(submenu)).first();
const menu: ElementFinder = this.openItemMenu(group, item);
const header = menu.element(by.buttonText(action));
const btn = menu.element(by.partialButtonText(submenu));

browser.actions().mouseMove(header, {x: -50, y: -50}).mouseMove(header).perform();

browser.actions()
.mouseMove(header, {x: -50, y: -50})
.mouseMove(header)
.perform();
waitFor(btn, 1000);
btn.click();
};
Expand Down
14 changes: 7 additions & 7 deletions e2e/client/specs/helpers/pages.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-this-alias */
/* eslint-disable newline-per-chained-call */

import {element, by, browser, $, $$, promise as wdpromise} from 'protractor';
import {element, by, browser, $, $$, promise as wdpromise, ElementFinder} from 'protractor';
import './waitReady';
export {authoring} from './authoring';
export {content} from './content';
Expand Down Expand Up @@ -102,14 +102,14 @@ class SearchProvider {

class IngestDashboard {
dropDown: any;
ingestDashboard: any;
ingestDashboard: ElementFinder;
openDropDown: () => any;
getProviderList: () => any;
getProvider: (index: any) => any;
getProviderButton: (provider: any) => any;
getDashboardList: () => any;
getDashboard: (index: any) => any;
getDashboardSettings: (dashboard: any) => any;
getDashboardSettingsButton: (dashboard: any) => any;
getDashboardSettingsStatusButton: (settings: any) => any;
getDashboardStatus: (dashboard: any) => any;
getDashboardSettingsIngestCountButton: (settings: any) => any;
Expand Down Expand Up @@ -140,14 +140,14 @@ class IngestDashboard {
};

this.getDashboardList = function() {
return self.ingestDashboard.all(by.repeater('item in items'));
return self.ingestDashboard.all(by.repeater('item in items track by item._id'));
};

this.getDashboard = function(index) {
return self.getDashboardList().get(index);
};

this.getDashboardSettings = function(dashboard) {
this.getDashboardSettingsButton = function(dashboard) {
return dashboard.element(by.css('.dropdown'));
};

Expand All @@ -156,15 +156,15 @@ class IngestDashboard {
};

this.getDashboardStatus = function(dashboard) {
return dashboard.element(by.css('.status'));
return dashboard.element(by.className('status'));
};

this.getDashboardSettingsIngestCountButton = function(settings) {
return settings.element(by.model('item.show_ingest_count'));
};

this.getDashboardIngestCount = function(dashboard) {
return dashboard.element(by.css('.ingested-count'));
return dashboard.element(by.className('ingested-count'));
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/client/specs/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function waitHidden(elem, time?) {
}

export function scrollToView(elem: ElementFinder) {
browser.executeScript('arguments[0].scrollIntoViewIfNeeded();', elem);
browser.executeScript('arguments[0]?.scrollIntoViewIfNeeded?.();', elem);
}

export function scrollRelative(elem: ElementFinder, direction: 'up'| 'down', pixelsToScroll: number) {
Expand Down
4 changes: 2 additions & 2 deletions e2e/client/specs/helpers/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Workspace {
* @param {string} name
*/
this.showHighlightList = function(name) {
var item = this.getHighlightListItem(name);
const item = this.getHighlightListItem(name);

browser.wait(ECE.elementToBeClickable(item), 1000);
item.click();
Expand All @@ -146,7 +146,7 @@ class Workspace {
* @return {promise} highlight element
*/
this.getHighlightListItem = function(name) {
var menu = element(by.id('highlightPackage'));
const menu = element(by.id('highlightPackage'));

browser.actions()
.mouseMove(menu)
Expand Down
13 changes: 7 additions & 6 deletions e2e/client/specs/ingest_provider_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ describe('ingest_provider', () => {
it('Change settings for Ingest Provider', () => {
addProvider();
expect(ingestDashboard.getDashboardList().count()).toEqual(1);
var dashboard = ingestDashboard.getDashboard(0);
var settings = ingestDashboard.getDashboardSettings(dashboard);

settings.click();
const dashboard = ingestDashboard.getDashboard(0);
const mainSettingsButton = ingestDashboard.getDashboardSettingsButton(dashboard);

mainSettingsButton.click();

// status
expect(ingestDashboard.getDashboardStatus(dashboard).isDisplayed()).toBe(true);
ingestDashboard.getDashboardSettingsStatusButton(settings).click();
ingestDashboard.getDashboardSettingsStatusButton(mainSettingsButton).click();
expect(ingestDashboard.getDashboardStatus(dashboard).isDisplayed()).toBe(false);

// ingest count
expect(ingestDashboard.getDashboardIngestCount(dashboard).isDisplayed()).toBe(true);
ingestDashboard.getDashboardSettingsIngestCountButton(settings).click();
ingestDashboard.getDashboardSettingsIngestCountButton(mainSettingsButton).click();
expect(ingestDashboard.getDashboardIngestCount(dashboard).isDisplayed()).toBe(false);
});

Expand All @@ -70,7 +71,7 @@ describe('ingest_provider', () => {
it('Go to Ingest Providers and open dialog', () => {
addProvider();
var dashboard = ingestDashboard.getDashboard(0);
var settings = ingestDashboard.getDashboardSettings(dashboard);
var settings = ingestDashboard.getDashboardSettingsButton(dashboard);

settings.click();
settings.element(by.css('.icon-pencil')).click();
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"sass-loader": "6.0.6",
"shortid": "2.2.8",
"style-loader": "0.20.2",
"superdesk-ui-framework": "^4.0.0",
"superdesk-ui-framework": "^4.0.1",
"ts-loader": "3.5.0",
"typescript": "4.9.5",
"uuid": "8.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ export function getAuthoringPrimaryToolbarWidgets(
return {
...item,
component: (props: {entity: IArticle}) => (
<Component article={props.entity} />
<Component entity={props.entity} />
),
};
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class AuthoringAngularTemplateIntegration extends React.PureComponent<IPr
<AuthoringIntegrationWrapper
itemId={null} // Id doesn't apply when editing embedded JSON.
sidebarMode="hidden"
hideSecondaryToolbar={true}
authoringStorage={getTemplateEditViewAuthoringStorage(this.props.template.data as IArticle)}
onFieldChange={(_fieldId, fieldsData, computeLatestEntity) => {
this.props.template.data = computeLatestEntity();
Expand Down
83 changes: 67 additions & 16 deletions scripts/apps/authoring-react/authoring-integration-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react/no-multi-comp */
/* eslint-disable no-case-declarations */
/* eslint-disable react/display-name */
import React from 'react';
import {
IArticle,
Expand Down Expand Up @@ -44,6 +45,7 @@ import {PINNED_WIDGET_USER_PREFERENCE_SETTINGS, closedIntentionally} from 'apps/
import {AuthoringIntegrationWrapperSidebar} from './authoring-integration-wrapper-sidebar';
import {assertNever} from 'core/helpers/typescript-helpers';
import {ContentProfileDropdown} from './subcomponents/content-profile-dropdown';
import {IconButton} from 'superdesk-ui-framework';

export function getWidgetsFromExtensions(article: IArticle): Array<IArticleSideWidget> {
return Object.values(extensions)
Expand All @@ -52,16 +54,62 @@ export function getWidgetsFromExtensions(article: IArticle): Array<IArticleSideW
.sort((a, b) => a.order - b.order);
}

const defaultToolbarItems: Array<React.ComponentType<{
article: IArticle;
reinitialize: (itemWithChanges: IArticle) => void;
}>> = [
CreatedModifiedInfo,
];

interface IProps {
itemId: IArticle['_id'];
}

const getAuthoringCosmeticActions = (exposed: IExposedFromAuthoring<IArticle>): Array<ITopBarWidget<IArticle>> => [{
availableOffline: true,
component: () => (
<IconButton
icon="preview-mode"
ariaValue={gettext('Print preview')}
onClick={() => {
exposed.printPreview();
}}
/>
),
group: 'end',
priority: 1,
keyBindings: {'ctrl+shift+i': () => {
exposed.printPreview();
}},
},
{
availableOffline: true,
component: () => (
<IconButton
icon="adjust"
ariaValue={gettext('Toggle theme')}
onClick={() => {
exposed.toggleTheme();
}}
/>
),
group: 'end',
priority: 2,
keyBindings: {'ctrl+shift+t': () => {
exposed.toggleTheme();
}},
},
{
availableOffline: true,
component: () => (
<IconButton
icon="switches"
ariaValue={gettext('Configure themes')}
onClick={() => {
exposed.configureTheme();
}}
/>
),
group: 'end',
priority: 3,
keyBindings: {'ctrl+shift+c': () => {
exposed.configureTheme();
}},
}];

export type ISideWidget = {
activeId?: string;
pinnedId?: string;
Expand Down Expand Up @@ -221,9 +269,6 @@ interface IPropsWrapper extends IProps {
actions: Array<ITopBarWidget<IArticle>>;
};

// Hides the toolbar which includes the "Print Preview" button.
hideSecondaryToolbar?: boolean;

// If it's not passed then the sidebar is shown expanded and can't be collapsed.
// If hidden is passed then it can't be expanded.
// If it's set to true or false then it can be collapsed/expanded back.
Expand Down Expand Up @@ -329,16 +374,11 @@ export class AuthoringIntegrationWrapper extends React.PureComponent<IPropsWrapp
const secondaryToolbarWidgetsFromExtensions = Object.values(extensions)
.flatMap(({activationResult}) => activationResult?.contributions?.authoringTopbar2Widgets ?? []);

const secondaryToolbarWidgetsReady = defaultToolbarItems.concat(secondaryToolbarWidgetsFromExtensions)
.map((Component) => (props) => <Component reinitialize={props.reinitialize} article={props.item} />);

return (
<WithInteractiveArticleActionsPanel location="authoring">
{(panelState, panelActions) => (
<AuthoringReact
themingEnabled
onFieldChange={this.props.onFieldChange}
hideSecondaryToolbar={this.props.hideSecondaryToolbar}
ref={(component) => {
this.authoringReactRef = component;
}}
Expand Down Expand Up @@ -550,7 +590,18 @@ export class AuthoringIntegrationWrapper extends React.PureComponent<IPropsWrapp
}}
/>
)}
secondaryToolbarWidgets={secondaryToolbarWidgetsReady}
getSecondaryToolbarWidgets={(exposed) => [
{
availableOffline: true,
component: () => (
<CreatedModifiedInfo article={exposed.item} />
),
group: 'start',
priority: 1,
},
...secondaryToolbarWidgetsFromExtensions,
...getAuthoringCosmeticActions(exposed),
]}
validateBeforeSaving={false}
getSideWidgetIdAtIndex={(article, index) => {
return getWidgetsFromExtensions(article)[index]._id;
Expand Down
Loading
Loading