-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add configuration types. #1017
Add configuration types. #1017
Changes from all commits
b0dd5d0
ce3e6f5
406f49d
8f1bc56
00c1b2d
db839d6
0970b80
9961dd5
6380069
842a70a
f652d06
e085a80
ebee4c5
21f730c
f6d2fbb
1c9f6e3
4f9cc21
380094d
197f7ba
b807459
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ import type { WrappedComponentProps } from 'react-intl' | |
import * as callTakerActions from '../../actions/call-taker' | ||
import * as fieldTripActions from '../../actions/field-trip' | ||
import * as uiActions from '../../actions/ui' | ||
import { AppMenuItemConfig, LanguageConfig } from '../../util/config-types' | ||
import { AppReduxState } from '../../util/state-types' | ||
import { ComponentContext } from '../../util/contexts' | ||
import { getLanguageOptions } from '../../util/i18n' | ||
import { isModuleEnabled, Modules } from '../../util/config' | ||
|
@@ -29,28 +31,27 @@ import PopupTriggerText from './popup-trigger-text' | |
type MenuItem = { | ||
children?: MenuItem[] | ||
href?: string | ||
iconType: string | JSX.Element | ||
iconType?: string | JSX.Element | ||
iconUrl?: string | ||
id: string | ||
isSelected?: boolean | ||
label: string | JSX.Element | ||
label?: string | JSX.Element | ||
lang?: string | ||
onClick?: () => void | ||
skipLocales?: boolean | ||
subMenuDivider: boolean | ||
subMenuDivider?: boolean | ||
} | ||
|
||
type AppMenuProps = { | ||
activeLocale: string | ||
callTakerEnabled?: boolean | ||
extraMenuItems?: MenuItem[] | ||
extraMenuItems?: AppMenuItemConfig[] | ||
fieldTripEnabled?: boolean | ||
// Typescript TODO language and language options based on configLanguage. | ||
language: Record<string, any> | null | ||
language?: LanguageConfig | ||
languageOptions: Record<string, any> | null | ||
location: { search: string } | ||
mailablesEnabled?: boolean | ||
popupTarget: string | ||
popupTarget?: string | ||
reactRouterConfig?: { basename: string } | ||
resetAndToggleCallHistory?: () => void | ||
resetAndToggleFieldTrips?: () => void | ||
|
@@ -89,7 +90,7 @@ class AppMenu extends Component< | |
|
||
_triggerPopup = () => { | ||
const { popupTarget, setPopupContent } = this.props | ||
setPopupContent(popupTarget) | ||
if (popupTarget) setPopupContent(popupTarget) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change added? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
_togglePane = () => { | ||
|
@@ -288,10 +289,8 @@ class AppMenu extends Component< | |
|
||
// connect to the redux store | ||
|
||
// FIXME: type otp config | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const mapStateToProps = (state: Record<string, any>) => { | ||
const { extraMenuItems, language } = state.otp.config | ||
const mapStateToProps = (state: AppReduxState) => { | ||
const { extraMenuItems, language, popups } = state.otp.config | ||
return { | ||
activeLocale: state.otp.ui.locale, | ||
callTakerEnabled: isModuleEnabled(state, Modules.CALL_TAKER), | ||
|
@@ -300,7 +299,7 @@ const mapStateToProps = (state: Record<string, any>) => { | |
language, | ||
languageOptions: getLanguageOptions(language), | ||
mailablesEnabled: isModuleEnabled(state, Modules.MAILABLES), | ||
popupTarget: state.otp.config?.popups?.launchers?.sidebarLink | ||
popupTarget: popups?.launchers?.sidebarLink | ||
} | ||
} | ||
|
||
|
@@ -324,7 +323,7 @@ export const Icon = ({ | |
iconType, | ||
iconUrl | ||
}: { | ||
iconType: string | ||
iconType?: string | ||
iconUrl?: string | ||
}): JSX.Element => { | ||
// FIXME: add types to context | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,10 @@ import tinycolor from 'tinycolor2' | |
|
||
import * as mapActions from '../../actions/map' | ||
import * as uiActions from '../../actions/ui' | ||
import { AppReduxState } from '../../util/state-types' | ||
import { ComponentContext } from '../../util/contexts' | ||
import { | ||
ConfiguredTransitMode, | ||
SetLocationHandler, | ||
SetViewedStopHandler | ||
} from '../util/types' | ||
import { getModeFromStop, getStopName } from '../../util/viewer' | ||
import { SetLocationHandler, SetViewedStopHandler } from '../util/types' | ||
|
||
interface OwnProps { | ||
stop: Stop | ||
|
@@ -166,12 +163,11 @@ class EnhancedStopMarker extends Component<Props> { | |
} | ||
} | ||
|
||
const mapStateToProps = (state: any, ownProps: OwnProps) => { | ||
const mapStateToProps = (state: AppReduxState, ownProps: OwnProps) => { | ||
const { highlightedStop } = state.otp.ui | ||
|
||
const transitModes = state.otp.config.modes.transitModes | ||
const modeColors: ModeColors = {} | ||
transitModes.forEach((mode: ConfiguredTransitMode) => { | ||
state.otp.config.modes.transitModes.forEach((mode) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to also add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, in this file, it is used only on this line. |
||
modeColors[mode.mode] = mode.color | ||
}) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,6 @@ const mapStateToProps = (state) => { | |
mediumId: null, | ||
riderCategoryId: null | ||
}, | ||
displayCalories: | ||
typeof itinerary?.displayCalories === 'boolean' | ||
Comment on lines
-23
to
-24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Displaying calories was completely removed from OTP-UI, so this doesn't apply anymore. |
||
? itinerary?.displayCalories | ||
: undefined, | ||
fareDetailsLayout: itinerary?.fareDetailsLayout || undefined, | ||
fareKeyNameMap: itinerary?.fareKeyNameMap || {} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,10 +105,3 @@ export type SetViewedRouteHandler = (route?: ViewedRouteState) => void | |
export type SetViewedStopHandler = (payload: { stopId: string } | null) => void | ||
|
||
export type SetLocationHandler = (payload: MapLocationActionArg) => void | ||
|
||
export interface ConfiguredTransitMode { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this interface being removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved it to |
||
color?: string | ||
label?: string | ||
mode: string | ||
showWheelchairSetting?: boolean | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this behavior removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Displaying calories was completely removed from OTP-UI, so this doesn't apply anymore.