Skip to content

Commit

Permalink
refactor: rename closePanel to onClosePanel
Browse files Browse the repository at this point in the history
  • Loading branch information
lemald committed Oct 24, 2023
1 parent 4d699b6 commit 2642ff9
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion assets/src/components/mapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ const MapPage = (): ReactElement<HTMLDivElement> => {
{selectedRightPanelVehicleOrGhost && (
<PropertiesPanel
selectedVehicleOrGhost={selectedRightPanelVehicleOrGhost}
closePanel={() => setSelectedRightPanelVehicleOrGhost(null)}
onClosePanel={() => setSelectedRightPanelVehicleOrGhost(null)}
initialTab="run"
/>
)}
Expand Down
14 changes: 7 additions & 7 deletions assets/src/components/propertiesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import { TabMode } from "./propertiesPanel/tabPanels"
interface Props {
selectedVehicleOrGhost: Vehicle | Ghost
initialTab?: TabMode
closePanel: () => void
onClosePanel: () => void
}

export type IndividualPropertiesPanelProps = {
tabMode: TabMode
onChangeTabMode: React.Dispatch<React.SetStateAction<TabMode>>
closePanel: () => void
onClosePanel: () => void
}

export const hideMeIfNoCrowdingTooltip = (hideMe: () => void) => {
Expand All @@ -32,7 +32,7 @@ export const hideMeIfNoCrowdingTooltip = (hideMe: () => void) => {
const PropertiesPanel = ({
selectedVehicleOrGhost,
initialTab = "status",
closePanel,
onClosePanel,
}: Props) => {
const { socket } = useSocket()
const liveVehicle = useVehicleForId(socket, selectedVehicleOrGhost.id)
Expand All @@ -56,29 +56,29 @@ const PropertiesPanel = ({
selectedVehicle={mostRecentVehicle}
tabMode={tabMode}
onChangeTabMode={setTabMode}
closePanel={closePanel}
onClosePanel={onClosePanel}
/>
) : isVehicle(mostRecentVehicle) ? (
<VehiclePropertiesPanel
selectedVehicle={mostRecentVehicle}
tabMode={tabMode}
onChangeTabMode={setTabMode}
closePanel={closePanel}
onClosePanel={onClosePanel}
/>
) : (
<GhostPropertiesPanel
selectedGhost={mostRecentVehicle}
tabMode={tabMode}
onChangeTabMode={setTabMode}
closePanel={closePanel}
onClosePanel={onClosePanel}
/>
)}
</div>
<div
className="c-properties-panel-backdrop"
onClick={
/* istanbul ignore next */
() => hideMeIfNoCrowdingTooltip(closePanel)
() => hideMeIfNoCrowdingTooltip(onClosePanel)
}
aria-hidden={true}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ const GhostPropertiesPanel = ({
selectedGhost,
tabMode,
onChangeTabMode,
closePanel,
onClosePanel,
}: Props) => {
return (
<div className="c-ghost-properties-panel">
<Header
vehicle={selectedGhost}
tabMode={tabMode}
setTabMode={onChangeTabMode}
closePanel={closePanel}
closePanel={onClosePanel}
/>

<TabPanels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ const StaleDataPropertiesPanel: React.FC<Props> = ({
selectedVehicle,
tabMode,
onChangeTabMode,
closePanel,
onClosePanel,
}) => {
return (
<div className="c-stale-data-properties-panel">
<StaleDataHeader
vehicle={selectedVehicle}
tabMode={tabMode}
setTabMode={onChangeTabMode}
closePanel={closePanel}
closePanel={onClosePanel}
/>
{isVehicleInScheduledService(selectedVehicle) ? (
<TabPanels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ const VehiclePropertiesPanel = ({
selectedVehicle,
tabMode,
onChangeTabMode,
closePanel,
onClosePanel,
}: Props) => {
return (
<div className="c-vehicle-properties-panel">
Expand All @@ -219,7 +219,7 @@ const VehiclePropertiesPanel = ({
}
onChangeTabMode(newTabMode)
}}
closePanel={closePanel}
closePanel={onClosePanel}
/>

{isVehicleInScheduledService(selectedVehicle) ? (
Expand Down
2 changes: 1 addition & 1 deletion assets/src/components/rightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const RightPanel = ({
return (
<PropertiesPanel
selectedVehicleOrGhost={selectedVehicleOrGhost}
closePanel={() => dispatch(closeView())}
onClosePanel={() => dispatch(closeView())}
/>
)
} else if (state.openView === OpenView.Swings) {
Expand Down
2 changes: 1 addition & 1 deletion assets/tests/components/propertiesPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const PropertiesPanelWrapper: React.FC<{
<RoutesProvider routes={routes}>
<PropertiesPanel
selectedVehicleOrGhost={vehicleOrGhost}
closePanel={closePanel || jest.fn()}
onClosePanel={closePanel || jest.fn()}
initialTab={initialTab}
/>
</RoutesProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("GhostPropertiesPanel", () => {
selectedGhost={ghost}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
</RoutesProvider>
)
Expand All @@ -75,7 +75,7 @@ describe("GhostPropertiesPanel", () => {
selectedGhost={ghostWithoutRun}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
</RoutesProvider>
)
Expand Down Expand Up @@ -103,7 +103,7 @@ describe("GhostPropertiesPanel", () => {
selectedGhost={ghostWithBlockWaivers}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -119,7 +119,7 @@ describe("GhostPropertiesPanel", () => {
selectedGhost={ghost}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={mockClosePanel}
onClosePanel={mockClosePanel}
/>
)

Expand All @@ -145,7 +145,7 @@ describe("GhostPropertiesPanel", () => {
selectedGhost={ghostFactory.build()}
tabMode={initialTab || "status"}
onChangeTabMode={mockSetTabMode}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("StaleDataPropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand All @@ -41,7 +41,7 @@ describe("StaleDataPropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand All @@ -56,7 +56,7 @@ describe("StaleDataPropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand All @@ -73,7 +73,7 @@ describe("StaleDataPropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={mockClosePanel}
onClosePanel={mockClosePanel}
/>
)

Expand All @@ -99,7 +99,7 @@ describe("StaleDataPropertiesPanel", () => {
selectedVehicle={vehicleFactory.build()}
tabMode={initialTab || "status"}
onChangeTabMode={mockSetTabMode}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -153,7 +153,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
</RoutesProvider>
)
Expand All @@ -173,7 +173,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={earlyVehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -187,7 +187,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={invalidVehicleFactory.build()}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
expect(screen.getByRole("heading", { name: "Invalid Bus" })).toBeVisible()
Expand All @@ -204,7 +204,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={earlyVehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -224,7 +224,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={offCourseVehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -246,7 +246,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={shuttleVehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -273,7 +273,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicleWithBlockWaivers}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
.toJSON()
Expand All @@ -290,7 +290,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
expect(result.getByText("Atlantic Ave & Summer St")).toBeInTheDocument()
Expand All @@ -306,7 +306,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand All @@ -323,7 +323,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand All @@ -343,7 +343,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={thisVehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
</VehiclesByRouteIdProvider>
)
Expand Down Expand Up @@ -371,7 +371,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={thisVehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)
expect(useVehiclesForRoute).toHaveBeenCalled()
Expand Down Expand Up @@ -400,7 +400,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand All @@ -415,7 +415,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicle}
tabMode="status"
onChangeTabMode={jest.fn()}
closePanel={mockClosePanel}
onClosePanel={mockClosePanel}
/>
)

Expand All @@ -442,7 +442,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicleFactory.build()}
tabMode={initialTab || "status"}
onChangeTabMode={mockSetTabMode}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand Down Expand Up @@ -470,7 +470,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicleFactory.build()}
tabMode={initialTab || "status"}
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand Down Expand Up @@ -501,7 +501,7 @@ describe("VehiclePropertiesPanel", () => {
selectedVehicle={vehicleFactory.build()}
tabMode={initialTab}
onChangeTabMode={jest.fn()}
closePanel={jest.fn()}
onClosePanel={jest.fn()}
/>
)

Expand Down

0 comments on commit 2642ff9

Please sign in to comment.