Skip to content

Commit

Permalink
Merge branch 'main' into pk/pause-active-toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJKim committed Oct 28, 2024
2 parents 9a93581 + f55c35d commit 632b41e
Show file tree
Hide file tree
Showing 29 changed files with 263 additions and 131 deletions.
38 changes: 0 additions & 38 deletions assets/css/dashboard/error-toast.scss

This file was deleted.

52 changes: 52 additions & 0 deletions assets/css/dashboard/toast.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.toast-container {
margin-bottom: 40px;

.toast {
font-size: 16px;
display: flex;
align-items: center;

.btn-close {
&:hover {
background-color: transparent;
}
}

&--warning {
background-color: $alert-yellow;
}

&--info {
background-color: $accessibility-blue;
color: white;
}

&__icon {
height: 24px;
width: 24px;
opacity: 60%;
flex-shrink: 0;
}

&__text {
padding-left: 8px;

ul {
margin-bottom: 0;
}
}
}

.toast-header {
.btn-close {
margin-right: 4px;

&:hover {
background-color: transparent;
}
}

border: none;
border-radius: 4px;
}
}
2 changes: 2 additions & 0 deletions assets/css/screen-detail.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.screen-detail__inline-layout {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
gap: 4px;
}

.screen-detail__container {
Expand Down
3 changes: 2 additions & 1 deletion assets/css/screen-simulation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
width: 100%;

&--busway_v2,
&--bus_shelter_v2 {
&--bus_shelter_v2,
&--elevator_v2 {
height: 379px;
}

Expand Down
2 changes: 1 addition & 1 deletion assets/css/screenplay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $form-feedback-invalid-color: $text-error;
@import "sort-label.scss";
@import "search-bar.scss";
@import "dashboard/picker.scss";
@import "dashboard/error-toast.scss";
@import "dashboard/toast.scss";

html {
font-size: 16px;
Expand Down
1 change: 1 addition & 0 deletions assets/css/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ $button-secondary-outline-active-bg: #d9d9d93d;
$text-button-blue-hover-color: #c1e4ff14;
$text-button-grey-hover-color: #f8f9fa14;
$alert-yellow: #ffdd00;
$accessibility-blue: #165c96;
54 changes: 0 additions & 54 deletions assets/js/components/Dashboard/ErrorToast.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SelectStationsAndZones from "./SelectStationsAndZones";
import AssociateAlert from "./AssociateAlert";
import { Alert, InformedEntity } from "Models/alert";
import { usePlacesWithPaEss } from "Hooks/usePlacesWithPaEss";
import ErrorToast from "Components/ErrorToast";
import Toast from "Components/Toast";
import { busRouteIdsAtPlaces, getRouteIdsForSign } from "../../../util";
import fp from "lodash/fp";

Expand Down Expand Up @@ -220,8 +220,9 @@ const PaMessageForm = ({
setEndWithEffectPeriod={setEndWithEffectPeriod}
/>
)}
<ErrorToast
errorMessage={errorMessage}
<Toast
variant="warning"
message={errorMessage}
errors={errors}
onClose={() => {
onErrorsChange([]);
Expand Down
1 change: 1 addition & 0 deletions assets/js/components/Dashboard/PlaceRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const typeMap: Record<string, string> = {
bus_eink_v2: "Bus E-Ink",
solari: "Sectional",
busway_v2: "Sectional",
elevator_v2: "Elevator",
};

const inlineMap = (place: Place, line: string) => {
Expand Down
16 changes: 13 additions & 3 deletions assets/js/components/Dashboard/PlaceRowAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ import ScreenDetail from "Components/ScreenDetail";
import { sortScreens } from "../../util";
import { useUpdateAnimation } from "Hooks/useUpdateAnimation";
import classNames from "classnames";
import fp from "lodash/fp";

type ScreenGroup = {
screens: Screen[];
isInline: boolean;
};

const groupScreens = (screens: Screen[]): ScreenGroup[] => {
const inlineScreenTypes = ["busway_v2", "solari", "elevator_v2"];

const inlineScreens = screens.filter((screen) =>
["busway_v2", "solari"].includes(screen.type),
inlineScreenTypes.includes(screen.type),
);
const paEssScreens = screens.filter((screen) => screen.type === "pa_ess");
const otherScreens = screens.filter(
(screen) => !["busway_v2", "pa_ess", "solari"].includes(screen.type),
(screen) => ![...inlineScreenTypes, "pa_ess"].includes(screen.type),
);

const groups = otherScreens.map((screen) => ({
Expand All @@ -36,7 +39,14 @@ const groupScreens = (screens: Screen[]): ScreenGroup[] => {
}));

if (inlineScreens.length > 0) {
groups.push({ screens: inlineScreens, isInline: true });
const groupedInlineScreens: Screen[][] = fp.flow(
fp.groupBy((screen: Screen) => screen.type),
fp.map((screens) => screens),
)(inlineScreens);

groupedInlineScreens.forEach((screens) =>
groups.push({ screens: screens, isInline: true }),
);
}

if (paEssScreens.length > 0) {
Expand Down
63 changes: 63 additions & 0 deletions assets/js/components/Dashboard/Toast.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from "react";
import { Toast as BSToast, ToastContainer } from "react-bootstrap";
import {
CheckCircleFill,
ExclamationTriangleFill,
} from "react-bootstrap-icons";
import { classWithModifier } from "../../util";

interface ToastProps {
variant: "warning" | "info";
message: string | null;
errors?: string[];
onClose?: () => void;
}

const Toast = ({ message, errors = [], onClose, variant }: ToastProps) => {
const getErrorMessageFromField = (error: string) => {
switch (error) {
case "sign_ids":
return "Add Stations & Zones";
case "visual_text":
return "Visual Text";
case "audio_text":
return "Phonetic Audio";
case "start_datetime":
return "Start date/time";
case "end_datetime":
return "End date/time";
default:
return "";
}
};

const Icon =
variant === "warning" ? ExclamationTriangleFill : CheckCircleFill;

return (
<ToastContainer position="bottom-center" className="toast-container">
<BSToast
show={message != null}
onClose={onClose}
delay={5000}
autohide={true}
>
<BSToast.Header className={classWithModifier("toast", variant)}>
{<Icon className="toast__icon" />}
<div className="toast__text">
{message}
{errors.length > 0 && (
<ul>
{errors.map((error, i) => {
return <li key={i}>{getErrorMessageFromField(error)}</li>;
})}
</ul>
)}
</div>
</BSToast.Header>
</BSToast>
</ToastContainer>
);
};

export default Toast;
2 changes: 1 addition & 1 deletion assets/js/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const SCREEN_TYPES: { label: string; ids: string[] }[] = [
label: "E-Ink: Green Line",
ids: ["gl_eink_single", "gl_eink_double", "gl_eink_v2"],
},
{ label: "Elevator", ids: ["elevator"] },
{ label: "Elevator", ids: ["elevator_v2"] },
{ label: "PA ESS", ids: ["pa_ess"] },
{ label: "Pre Fare Duo", ids: ["pre_fare_v2"] },
{ label: "Sectional", ids: ["busway_v2", "solari"] },
Expand Down
1 change: 1 addition & 0 deletions assets/js/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ const screenTypeOrder = [
"gl_eink_double",
"gl_eink_v2",
"pre_fare_v2",
"elevator_v2",
"pa_ess",
];

Expand Down
5 changes: 5 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ config :ueberauth, Ueberauth,

config :elixir, :time_zone_database, Tzdata.TimeZoneDatabase

config :screenplay, Oban,
engine: Oban.Engines.Basic,
queues: [default: 10],
repo: Screenplay.Repo

import_config "outfront_takeover_tool_screens.exs"

# Import environment specific config. This must remain at the bottom
Expand Down
18 changes: 12 additions & 6 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ if sentry_dsn not in [nil, ""] do
environment_name: env
end

scheduler_jobs =
if env == "prod",
do: [{"0 7 * * *", {Screenplay.Jobs.TakeoverToolTestingJob, :run, []}}],
else: []

config :screenplay, Screenplay.Scheduler, jobs: scheduler_jobs
if env == "prod" do
config :screenplay, Oban,
plugins: [
{Oban.Plugins.Cron,
crontab: [
{"0 7 * * *", Screenplay.Jobs.TakeoverToolTestingJob}
]},
Oban.Plugins.Pruner,
Oban.Plugins.Lifeline,
Oban.Plugins.Reindexer
]
end

config :screenplay, Screenplay.Repo, pool_size: 10
5 changes: 4 additions & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ config :screenplay,
github_api_client: Screenplay.GithubApi.FakeClient,
local_signs_json_path: {:test, "signs.json"},
stops_mod: Screenplay.Stops.Mock,
routes_mod: Screenplay.Routes.Mock
routes_mod: Screenplay.Routes.Mock,
facilities_mod: Screenplay.Facilities.Mock

config :ueberauth, Ueberauth,
providers: [
Expand All @@ -40,5 +41,7 @@ config :ueberauth_oidcc,

config :screenplay, Screenplay.Repo, database: "screenplay_test", pool: Ecto.Adapters.SQL.Sandbox

config :screenplay, Oban, testing: :inline

# Print only warnings and errors during test
config :logger, level: :warning
Loading

0 comments on commit 632b41e

Please sign in to comment.