Skip to content

Commit

Permalink
remove prop drilling of preferredCoverageDesks.
Browse files Browse the repository at this point in the history
It can be connected from redux state to component that needs it
  • Loading branch information
tomaskikutis committed Dec 17, 2024
1 parent e83c6c7 commit da94fcf
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 19 deletions.
4 changes: 0 additions & 4 deletions client/components/Coverages/CoverageArrayInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ interface IProps {
originalCount?: number;
message: string | {[key: string]: any};
event?: IEventItem;
preferredCoverageDesks: {[key: string]: string};
getRef?(field: string, value: IPlanningCoverageItem): React.RefObject<CoverageEditor>;
testId?: string;
editorType: EDITOR_TYPE;
Expand Down Expand Up @@ -156,7 +155,6 @@ class CoverageArrayInputComponent extends React.Component<IProps, IState> {
popupContainer,
onPopupOpen,
onPopupClose,
preferredCoverageDesks,
item,
navigation,
useLocalNavigation,
Expand Down Expand Up @@ -197,7 +195,6 @@ class CoverageArrayInputComponent extends React.Component<IProps, IState> {
defaultDesk,
onPopupOpen,
onPopupClose,
preferredCoverageDesks,
newsCoverageStatus,
field,
value,
Expand Down Expand Up @@ -227,7 +224,6 @@ class CoverageArrayInputComponent extends React.Component<IProps, IState> {
diff={item}
navigation={coverageNavigation}
openCoverageIds={this.state.openCoverageIds}
preferredCoverageDesks={preferredCoverageDesks}
getRef={this.props.getRef}
editorType={editorType}
{...props}
Expand Down
2 changes: 0 additions & 2 deletions client/components/Main/EditorPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const mapStateToProps = (state: IPlanningAppState) => ({
newsCoverageStatus: selectors.general.newsCoverageStatus(state),
contentTypes: selectors.general.contentTypes(state),
defaultDesk: selectors.general.defaultDesk(state),
preferredCoverageDesks: get(selectors.general.preferredCoverageDesks(state), 'desks'),
associatedPlannings: selectors.events.getRelatedPlannings(state),
associatedEvents: selectors.events.planningEditAssociatedEvents(state),
currentWorkspace: selectors.general.currentWorkspace(state),
Expand All @@ -53,7 +52,6 @@ const mapStateToPropsModal = (state) => ({
inModalView: !!selectors.forms.currentItemIdModal(state),
contentTypes: selectors.general.contentTypes(state),
defaultDesk: selectors.general.defaultDesk(state),
preferredCoverageDesks: get(selectors.general.preferredCoverageDesks(state), 'desks'),
associatedPlannings: selectors.events.getRelatedPlanningsForModalEvent(state),
associatedEvents: selectors.events.planningEditAssociatedEventsModal(state),
currentWorkspace: selectors.general.currentWorkspace(state),
Expand Down
6 changes: 5 additions & 1 deletion client/components/Main/ItemEditor/ItemManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import * as actions from '../../../actions';
import {EditorComponent} from './Editor';
import {AutoSave} from './AutoSave';
import {EditorGroup} from '../../Editor/EditorGroup';
import * as selectors from '../../../selectors';


export class ItemManager {
Expand Down Expand Up @@ -863,13 +864,16 @@ export class ItemManager {
}

addCoverage(g2ContentType) {
const state = planningApi.redux.store.getState();
const preferredCoverageDesks = selectors.general.preferredCoverageDesks(state)?.desks ?? {};

const newCoverage = planningUtils.defaultCoverageValues(
this.props.newsCoverageStatus,
this.state.initialValues,
this.props.associatedEvents?.[0] ?? null, // TAG: MULTIPLE_PRIMARY_EVENTS
g2ContentType,
this.props.defaultDesk,
this.props.preferredCoverageDesks
preferredCoverageDesks,
);

this.editor.onChangeHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ describe('components.Main.ItemManager', () => {
inModalView: false,
newsCoverageStatus: null,
defaultDesk: null,
preferredCoverageDesks: null,
onCancel: null,

occurStatuses: testData.vocabularies.eventoccurstatus,
Expand Down
3 changes: 0 additions & 3 deletions client/components/Planning/PlanningEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ interface IProps {
user: IUser['_id'];
contentTypes: Array<IG2ContentType>;
defaultDesk?: IDesk;
preferredCoverageDesks: {[key: string]: string};
files: Array<IFile>;
lockedItems: ILockedItems;

Expand Down Expand Up @@ -87,7 +86,6 @@ const mapStateToProps = (state) => ({
desk: selectors.general.currentDeskId(state),
user: selectors.general.currentUserId(state),
defaultDesk: selectors.general.defaultDesk(state),
preferredCoverageDesks: get(selectors.general.preferredCoverageDesks(state), 'desks'),
files: selectors.general.files(state),
contentTypes: selectors.general.contentTypes(state),
formProfile: selectors.forms.planningProfile(state),
Expand Down Expand Up @@ -406,7 +404,6 @@ class PlanningEditorComponent extends React.Component<IProps, IState> {
originalCount: this.props.item?.coverages?.length ?? 0,
message: this.props.message,
event: this.props.event, // TAG: MULTIPLE_PRIMARY_EVENTS
preferredCoverageDesks: this.props.preferredCoverageDesks,
defaultValue: [],
files: this.props.files,
uploadFiles: this.props.uploadFiles,
Expand Down
4 changes: 0 additions & 4 deletions client/components/UI/Form/InputArray/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ import {Button} from '../../';
import {Row, LineInput} from '../';
import './style.scss';
import {superdeskApi} from '../../../../superdeskApi';
import {planningApis} from '../../../../api';
import {
EDITOR_TYPE,
IAssignmentItem,
IG2ContentType,
IPlanningCoverageItem,
IPlanningNewsCoverageStatus,
} from 'interfaces';
import {IDesk} from 'superdesk-api';
Expand Down Expand Up @@ -55,7 +52,6 @@ interface IProps {
newsCoverageStatus: Array<IPlanningNewsCoverageStatus>;
navigation: any;
openCoverageIds: Array<string>;
preferredCoverageDesks: {[key: string]: string};
editorType: EDITOR_TYPE;
}

Expand Down
2 changes: 0 additions & 2 deletions client/components/fields/editor/coverages.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
ICoverageScheduledUpdate,
IEditorFieldProps,
IEventItem, IFile,
IPlanningCoverageItem,
Expand All @@ -22,7 +21,6 @@ export interface IPropsEditorFieldCoverages extends IEditorFieldProps {
originalCount?: number;
message: string | {[key: string]: any};
event?: IEventItem;
preferredCoverageDesks: {[key: string]: string};

popupContainer?(): HTMLElement;
onPopupOpen?(): void;
Expand Down
1 change: 0 additions & 1 deletion client/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,6 @@ export interface IEditorProps {
inModalView: boolean;
hideExternalEdit: boolean;
defaultDesk: IDesk;
preferredCoverageDesks: {[key: string]: string};
associatedPlannings?: Array<IPlanningItem>;
associatedEvents?: Array<IEventItem>;
currentWorkspace: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class Editor extends React.PureComponent<IProps> {
related_events: this.props.item.related_events,
} as IPlanningItem}
// PR-TODO: implement functions below
preferredCoverageDesks={{}}
uploadFiles={() => Promise.resolve([])}
message={{}}
notifyValidationErrors={noop}
Expand Down

0 comments on commit da94fcf

Please sign in to comment.