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

related_items field implementation #441

Closed
wants to merge 5 commits into from

Conversation

thecalcc
Copy link
Contributor

SDBELGA-768

@thecalcc
Copy link
Contributor Author

Editor view with some items:
image

Editor view, item hovered:
image

Editor view, no items:
image

Modal view, first item selected, second item hovered:
image

Modal view, item open in preview:
image

@MarkLark86
Copy link
Contributor

@thecalcc I don't really see anything here specific to Belga in this PR (except for checking of the search provider with a static string/url).

IMO, this is a core feature and we should do our best to keep it a core feature. In my Planning PR I have added an improvement where if you add EVENT_RELATED_ITEM_SEARCH_PROVIDER_NAME (with the name of a search provider) to your settings.py, this will enable the related_items field and allow you to use that config in the front-end (under the appConfig.planning.event_related_item_search_provider_name config). Without this config, that field would not be available in the front-end anywhere.

PanelContentBlock,
ContentDivider,
} from 'superdesk-ui-framework/react';
import {getProjectedFieldsArticle, gettext} from 'superdesk-core/scripts/core/utils';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not import anything from superdesk-core, it was something that we used to do years ago before the SuperdeskAPI. Now that we have that API it is best to use that, if needing anything from core then we should add the required functionality to that API.


render(): React.ReactNode {
const {closeModal} = this.props;
const allLanguages = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should ideally come from the languages defined in the system, see vocabs selector for an example

<Spacer v gap="0">
<div
style={{
padding: 12,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constant numbers should not be used, instead we have helper classes for this (https://ui-framework.superdesk.org/#/components/spacing)

<div
style={{
padding: 12,
backgroundColor: 'white'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with a dark theme? An issue with using inline styles vs styles defined in the UI-Framework

</div>
<ContentDivider margin='none' />
<Spacer h gap="0" justifyContent='start' alignItems='start' noWrap>
<div style={{...{width: this.state.previewItem ? '65%' : '100%'}, ...{padding: 12}}}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely the width here can be done better, rather than constant percentage values (@fritzSF)?
Again with the padding, please use the helper classes

</div>
}
<div style={{height: '100%'}}>
<Panel background='light' open={this.state.previewItem != null} side='right' size="medium">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does specifying background='light' work with a dark theme?

@@ -0,0 +1,131 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have an ArchivePreviewComponent, which is used in the Assignment side panel. Could this be used here? They both provide the same functionality, so it's best to stick to DRY principle of re-using an existing component

@@ -0,0 +1,188 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, stick with the DRY principle and use ArticleItemConcise component from the SuperdeskAPI.
This way this one component is used in multiple places to render related articles, rather than duplication of the same functionality.

If we need changes done, such as to show language, then this should be done on the ArticleItemConcise component

@@ -0,0 +1,196 @@
import {IArticle} from 'superdesk-api';

export const fakeEditor: any = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this is not needed for production, only in testing/development. If so, please remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do need it, because the items coming from Belga don't have an actual content profile, but the search_provider_proxy from our backend works with projections, and those are gotten through a content profile. In the future I guess we can rework this so we don't need to fake content profiles.

@thecalcc
Copy link
Contributor Author

Moved to superdesk-planning (superdesk/superdesk-planning#1931)

@thecalcc thecalcc closed this Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants