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 qa reported bugs #2216

Open
wants to merge 14 commits into
base: feature/embedded-events-editor
Choose a base branch
from

Conversation

thecalcc
Copy link
Contributor

STT-31

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
Copy link
Contributor Author

thecalcc commented Feb 26, 2025

TODO:

  • autosave should work for temporary embedded events.
  • add all fields for events
  • handle input type fields config - multiline, editor3, etc.
  • change description of tooltips and icons for unlinking an embedded item
  • fix empty labels
  • fix saving & linking of events

Note: Look into _temporary prop of planning item. Should be able to store temp events there.

): Promise<void> => {
for (const exposed of getEmbeddedItemsExposed(editorType, itemType)) {
): Promise<Array<T>> => {
const updatedItems: Array<T> = [];
Copy link
Member

Choose a reason for hiding this comment

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

what's the purpose of adding 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.

I use the result of handleEmbeddedItems in ItemManager.tsx to update related_events.

Copy link
Member

Choose a reason for hiding this comment

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

Could you respond to everything in one review?

}
}

if (updates.type === 'planning' && (updates.related_events ?? []).length > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

What are you doing here that wasn't working with the previous version of code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm updating related_events

label: getVocabularyItemFieldTranslated(
option,
'label',
'en',
Copy link
Member

Choose a reason for hiding this comment

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

language shouldn't be hardcoded

label: getVocabularyItemFieldTranslated(
option,
'label',
'en',
Copy link
Member

Choose a reason for hiding this comment

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

language shouldn't be hardcoded

]}
>
{(res) => {
const files: Array<IFile> = res[0]._items;
const files: Array<IFile> = res?.[0]?._items ?? [];
Copy link
Member

Choose a reason for hiding this comment

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

after superdesk/superdesk-client-core#4762 you can revert this line to how it was

// otherwise trying to save the same item twice would happen
if (isTemporaryId(original._id) && !isTemporaryId(updates._id)) {
editor.form.changeField(
'_unsaved_related_events',
Copy link
Member

Choose a reason for hiding this comment

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

use nameof

profile: 'event' | 'planning',
item: T,
onSave: (current: T, original: T) => Promise<T>,
): IAuthoringStorage<T> {
/**
* Timeout for 500 seconds to let newly added embedded events finish autosaving.
Copy link
Member

Choose a reason for hiding this comment

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

Timing can't be relied upon. We should do a better solution. Could you elaborate what issue you're trying to address here?

Why did you drop my usage of spread operator to handle validation?

return new Promise<T>((resolve) => {
setTimeout(() => {
autosave
.getById(profile === 'event' ? 'event' : 'planning', id)
Copy link
Member

Choose a reason for hiding this comment

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

profile === 'event' ? 'event' : 'planning'

It's a trap to do it like that. If more items are added to the union type the code will fail silently. And we want it to fail loud and clear :D Use if/else if/assert never

@@ -750,6 +750,7 @@ export interface IPlanningItem extends IBaseRestApiResponse {
// added by client - should be dropped before sending to server
event?: IEventItem;

_unsaved_related_events?: Array<IPlanningRelatedEventLink>;
Copy link
Member

Choose a reason for hiding this comment

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

add a comment on how it is mean to be used. sent to autosave, but not save?

@@ -218,6 +218,7 @@
"mapping": not_analyzed,
"nullable": True,
},
"_unsaved_related_events": {"type": "list", "nullable": True},
Copy link
Member

Choose a reason for hiding this comment

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

can this be added to autosave only?

const clonedValue = cloneDeep(item.dates.recurring_rule);

if (clonedValue?.until != null) {
set(clonedValue, nameof<typeof clonedValue>('until'), moment(clonedValue.until));
Copy link
Member

Choose a reason for hiding this comment

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

since value update path is static rather than dynamic - no need to use lodash.set here. It'd be cleaner to use the usual immutable updating via spreading.

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