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 authoring-react fields #2147

Merged

Conversation

thecalcc
Copy link
Contributor

@thecalcc thecalcc commented Dec 3, 2024

STT-63

Front-end checklist

  • This pull request is adding missing TypeScript types to modified code segments where it's easy to do so with confidence
  • This pull request is using TypeScript interfaces instead of prop-types and updates usages where it's quick to do so
  • This pull request is using memo or PureComponent to define new React components (and updates existing usages in modified code segments)
  • This pull request is replacing lodash.get with optional chaining and nullish coalescing for modified code segments
  • This pull request is not importing anything from client-core directly (use superdeskApi)
  • This pull request is importing UI components from superdesk-ui-framework and superdeskApi when possible instead of using ones defined in this repository.
  • This pull request is not using planningApi where it is possible to use superdeskApi
  • This pull request is not adding redux based modals
  • In this pull request, properties of redux state are not being passed as props to components; instead, we connect it to the component that needs them. Except components where using a react key is required - do not connect those due to performance reasons.
  • This pull request is not adding redux actions that do not modify state (e.g. only calling angular services; those should be moved to planningApi)

@thecalcc thecalcc changed the base branch from develop to add-to-planning-refactoring December 3, 2024 14:50
@thecalcc thecalcc changed the base branch from add-to-planning-refactoring to release/2.8 December 3, 2024 14:50
@thecalcc thecalcc changed the base branch from release/2.8 to feature/multiple-events-in-planning December 3, 2024 14:50
@thecalcc
Copy link
Contributor Author

thecalcc commented Dec 3, 2024

@tomaskikutis what's a better way to handle this? I have the branch based off of yours - authoring-react-planning

Edit: might be a good idea for you to push your branch to the remote so I can merge to it as well, while not messing directly with it

@tomaskikutis tomaskikutis changed the base branch from feature/multiple-events-in-planning to authoring-react-planning December 4, 2024 08:53
@tomaskikutis
Copy link
Member

I've deleted the branch from my fork and pushed it to this repo. You'll have to fix a conflict now since I've changed the content profile file.

@tomaskikutis
Copy link
Member

why are you removing package-lock from planning extension?

@thecalcc
Copy link
Contributor Author

thecalcc commented Dec 4, 2024

why are you removing package-lock from planning extension?

Unintentionally, I will revert it

@thecalcc thecalcc changed the title Planning date field Planning authoring-react fields Dec 5, 2024
@tomaskikutis
Copy link
Member

Usually if I leave some comments I expect you would only push next after you handled it which seems not to be the case here right?

"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
"integrity": "sha512-OLUyIIZ7mF5oaAUT1w0TFqQS81q3saT46x8t7ukpPjMNk+nbs4ZHhs7ToV8EWnLYLepjETXd4XaCE4uxkMeqUw==",
"dev": true
"name": "superdesk-planning-extension",
Copy link
Member

Choose a reason for hiding this comment

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

no changes should be present in the PR of
client/planning-extension/package-lock.json

if you revert by copying over manually - use an editor that doesn't modify formatting

const customVocabularyIds =
(planningProfile.schema?.['custom_vocabularies'] as IProfileSchemaTypeList)?.vocabularies;

if ((customVocabularyIds?.length ?? 0) > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

custom vocabularies definition is quite big, could you move it to a separate file? here you would import the function, call it and push the result to the array of fields

@@ -15,7 +16,18 @@ export const storageAdapterPlanningItem: IStorageAdapter<IPlanningItem> = {
const fieldDefinitions = getFieldDefinitions();
const fieldStorageAdapter = fieldDefinitions[fieldId]?.storageAdapter;

if (fieldStorageAdapter != null) {
if (fieldId.includes(SUBJECT_PREFIX_ID)) {
Copy link
Member

Choose a reason for hiding this comment

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

use .startsWith instead of .includes

Regarding SUBJECT_PREFIX_ID - would be good if we could avoid this approach of checking contents of an ID. I suggested the idea to assure you that it can be done using existing vocabulary fields from client-core. Since we agree now that it can be done, we can look into how to do it better :) It's a bit messy that you run storage adapter twice for vocabulary fields. Once in field definition and second time in main storage adapter. Change IFieldDefinition['storageAdapter'] so you can do it all in once place.

const fieldDefinitions = getFieldDefinitions();
const fieldStorageAdapter = fieldDefinitions[fieldId]?.storageAdapter;

if (fieldStorageAdapter != null) {
if (fieldId.startsWith(SUBJECT_PREFIX_ID)) {
Copy link
Member

Choose a reason for hiding this comment

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

use the same approach here as well to avoid running 2 storage adapters

client/components/planning-editor-standalone/profile.ts Outdated Show resolved Hide resolved
storageAdapter: {
storeValue: (item, operationalValue: IVocabularyItem['qcode']) => {
const vocabulary = allVocabularies.get(id);
const vocabItems = vocabulary.items.filter((x) => operationalValue.includes(x.qcode)) ?? [];
Copy link
Member

Choose a reason for hiding this comment

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

Default will never get applied here. If .filter does not crash it will always return an array.

import {
IAttachmentsFieldConfig,
} from '../../planning-extension/src/authoring-react-fields/planning-attachments/interfaces';
import {getCustomVocabularyFields} from './field-adapters/custom-vocabularies';
import {getPlanningProfileFields} from './profile-fields';
import {IEventOrPlanningItem} from 'interfaces';
Copy link
Member

Choose a reason for hiding this comment

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

use only planning item interface here. Event will have a separate editor

@tomaskikutis
Copy link
Member

FYI it was pretty annoying to have the date PR together with vocabularies PR. Since you was refactoring a lot in this PR I would never review diff between commits, but a diff between target branch and this branch - so I saw how final changes look. I then had to look at date field multiple times when there were no changes there.

Next time spin up another branch from the PR branch to separate work on different features.

@tomaskikutis tomaskikutis merged commit d0cd58a into superdesk:authoring-react-planning Dec 12, 2024
11 of 13 checks passed
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