Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate, useLocation } from "react-router-dom";
import set from "lodash.set";
import dayjs from "dayjs";
import { useDispatch } from "react-redux";
import idFromUrl from "../util/helpers/id-from-url";
Expand Down Expand Up @@ -281,7 +280,7 @@ function PlaylistCampaignManager({
*/
const handleInput = ({ target }) => {
const localFormStateObject = { ...formStateObject };
set(localFormStateObject, target.id, target.value);
localFormStateObject[target.id] = target.value;
setFormStateObject(localFormStateObject);
};

Expand Down
3 changes: 1 addition & 2 deletions assets/admin/components/screen/screen-manager.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import set from "lodash.set";
import { useNavigate } from "react-router-dom";
import {
usePostV2ScreensMutation,
Expand Down Expand Up @@ -96,7 +95,7 @@ function ScreenManager({
const handleInput = ({ target }) => {
let localFormStateObject = { ...formStateObject };
localFormStateObject = JSON.parse(JSON.stringify(localFormStateObject));
set(localFormStateObject, target.id, target.value);
localFormStateObject[target.id] = target.value;
setFormStateObject(localFormStateObject);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import set from "lodash.set";
import { Col, Row } from "react-bootstrap";
import { useTranslation } from "react-i18next";
import FileSelector from "../file-selector";
Expand Down Expand Up @@ -28,7 +27,7 @@ function ContactForm({
*/
const onInput = ({ target }) => {
const localContact = { ...contact };
set(localContact, target.name, target.value);
localContact[target.name] = target.value;
onChange(localContact);
};

Expand Down
5 changes: 2 additions & 3 deletions assets/admin/components/slide/content/feed-selector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Spinner } from "react-bootstrap";
import { useDispatch } from "react-redux";
import set from "lodash.set";
import {
enhancedApi,
useGetV2FeedSourcesQuery,
Expand Down Expand Up @@ -100,12 +99,12 @@ function FeedSelector({
const configuration = { ...value.configuration };

if (target !== null) {
set(configuration, target.id, target.value);
configuration[target.id] = target.value;
}

if (targets !== null) {
targets.forEach(({ id, value: targetValue }) => {
set(configuration, id, targetValue);
configuration[id] = targetValue;
});
}

Expand Down
62 changes: 25 additions & 37 deletions assets/admin/components/slide/slide-manager.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { useEffect, useState, useContext } from "react";
import { useTranslation } from "react-i18next";
import get from "lodash.get";
import set from "lodash.set";
import { ulid } from "ulid";
import { useDispatch } from "react-redux";
import dayjs from "dayjs";
Expand Down Expand Up @@ -155,7 +153,7 @@ function SlideManager({
*/
const handleInput = ({ target }) => {
const localFormStateObject = { ...formStateObject };
set(localFormStateObject, target.id, target.value);
localFormStateObject[target.id] = target.value;
setFormStateObject(localFormStateObject);
};

Expand Down Expand Up @@ -208,7 +206,7 @@ function SlideManager({
const value =
target.type === "number" ? target.valueAsNumber : target.value;
const localFormStateObject = { ...formStateObject };
set(localFormStateObject.content, target.id, value);
localFormStateObject.content[target.id] = value;
setFormStateObject(localFormStateObject);
};

Expand Down Expand Up @@ -353,12 +351,12 @@ function SlideManager({
// It is an already added temp file.
if (entry.tempId) {
newField.push(entry.tempId);
set(localMediaData, entry.tempId, entry);
localMediaData[entry.tempId] = entry;
}
// It is a new temp file.
else {
if (!Array.isArray(localFormStateObject.content[fieldId])) {
set(localFormStateObject.content, fieldId, []);
localFormStateObject.content[fieldId] = [];
}

// Create a tempId for the media.
Expand All @@ -369,7 +367,7 @@ function SlideManager({

const newEntry = { ...entry };
newEntry.tempId = tempId;
set(localMediaData, tempId, newEntry);
localMediaData[tempId] = newEntry;
}
}
// Previously selected file.
Expand All @@ -383,18 +381,16 @@ function SlideManager({
if (
!Object.prototype.hasOwnProperty.call(localMediaData, entry["@id"])
) {
set(localMediaData, entry["@id"], entry);
localMediaData[entry["@id"]] = entry;

localFormStateObject.media.push(entry["@id"]);
}
}
});
}

set(localFormStateObject.content, fieldId, newField);
set(localFormStateObject, "media", [
...new Set([...localFormStateObject.media]),
]);
localFormStateObject.content[fieldId] = newField;
localFormStateObject.media = [...new Set([...localFormStateObject.media])];

setFormStateObject(localFormStateObject);
setMediaData(localMediaData);
Expand All @@ -406,7 +402,7 @@ function SlideManager({

// Setup submittingMedia list.
mediaFields.forEach((fieldName) => {
const fieldData = get(formStateObject.content, fieldName);
const fieldData = formStateObject.content[fieldName];

if (fieldData) {
if (Array.isArray(fieldData)) {
Expand Down Expand Up @@ -548,33 +544,25 @@ function SlideManager({

/** Submitted media is successful. */
useEffect(() => {
if (submitting) {
if (isSaveMediaSuccess) {
const newSubmittingMedia = [...submittingMedia];
const submittedMedia = newSubmittingMedia.shift();

const newFormStateObject = { ...formStateObject };
newFormStateObject.media.push(savedMediaData["@id"]);

// Replace TEMP-- id with real id.
set(
newFormStateObject.content,
submittedMedia.fieldName,
get(newFormStateObject.content, submittedMedia.fieldName).map(
(mediaId) =>
mediaId === submittedMedia.tempId
? savedMediaData["@id"]
: mediaId,
),
if (submitting && isSaveMediaSuccess) {
const newSubmittingMedia = [...submittingMedia];
const submittedMedia = newSubmittingMedia.shift();

const newFormStateObject = { ...formStateObject };
newFormStateObject.media.push(savedMediaData["@id"]);

// Replace TEMP-- id with real id.
newFormStateObject.content[submittedMedia.fieldName] =
newFormStateObject.content[submittedMedia.fieldName].map((mediaId) =>
mediaId === submittedMedia.tempId ? savedMediaData["@id"] : mediaId,
);

const newMediaData = { ...mediaData };
newMediaData[savedMediaData["@id"]] = savedMediaData;
setMediaData(newMediaData);
const newMediaData = { ...mediaData };
newMediaData[savedMediaData["@id"]] = savedMediaData;
setMediaData(newMediaData);

// Save new list.
setSubmittingMedia(newSubmittingMedia);
}
// Save the new list.
setSubmittingMedia(newSubmittingMedia);
}
}, [isSaveMediaSuccess]);

Expand Down
3 changes: 1 addition & 2 deletions assets/admin/components/util/table/table-body.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Fragment } from "react";
import get from "lodash.get";
import useModal from "../../../context/modal-context/modal-context-hook";

/**
Expand All @@ -23,7 +22,7 @@ function TableBody({ columns, data }) {
return column.content(item);
}

let cellData = get(item, column.path);
let cellData = item[column.path];

if (column.dataFunction) {
cellData = column.dataFunction(cellData);
Expand Down
9 changes: 4 additions & 5 deletions assets/client/data-sync/pull-strategy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import cloneDeep from "lodash.clonedeep";
import isPublished from "../util/isPublished";
import logger from "../logger/logger";
import ApiHelper from "./api-helper";
Expand Down Expand Up @@ -136,7 +135,7 @@ class PullStrategy {
async getSlidesForRegions(regions) {
return new Promise((resolve, reject) => {
const promises = [];
const regionData = cloneDeep(regions);
const regionData = structuredClone(regions);

// @TODO: Fix eslint-raised issues.
// eslint-disable-next-line guard-for-in,no-restricted-syntax
Expand Down Expand Up @@ -200,7 +199,7 @@ class PullStrategy {
return;
}

const newScreen = cloneDeep(screen);
const newScreen = structuredClone(screen);

newScreen.hasActiveCampaign = false;

Expand Down Expand Up @@ -304,7 +303,7 @@ class PullStrategy {
const dataEntrySlidesData = dataEntryPlaylist.slidesData;

for (const slideKey of Object.keys(dataEntrySlidesData)) {
const slide = cloneDeep(dataEntrySlidesData[slideKey]);
const slide = structuredClone(dataEntrySlidesData[slideKey]);

let previousSlide = null;

Expand All @@ -315,7 +314,7 @@ class PullStrategy {
this.lastestScreenData.regionData[regionKey][playlistKey]
.slidesData[slideKey]
) {
previousSlide = cloneDeep(
previousSlide = structuredClone(
this.lastestScreenData.regionData[regionKey][playlistKey]
.slidesData[slideKey],
);
Expand Down
3 changes: 1 addition & 2 deletions assets/client/service/schedule-service.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import cloneDeep from "lodash.clonedeep";
import sha256 from "crypto-js/sha256";
import Md5 from "crypto-js/md5";
import Base64 from "crypto-js/enc-base64";
Expand Down Expand Up @@ -214,7 +213,7 @@ class ScheduleService {
return;
}

const newSlide = cloneDeep(slide);
const newSlide = structuredClone(slide);

// Execution id is the product of region, playlist and slide id, to ensure uniqueness in the client.
const executionId = Md5(regionId + playlist["@id"] + slide["@id"]);
Expand Down
4 changes: 3 additions & 1 deletion assets/tests/template/template-calendar.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { test, expect } from "@playwright/test";

// Fixed time since calendar template filters events older than now.
// Fixed time since the calendar template filters events older than now.
const fixTime = async (page) => {
const newDate = new Date();
newDate.setMonth(8);
newDate.setDate(15);
newDate.setHours(6);
newDate.setMinutes(0);
await page.clock.install({ time: newDate });
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ services:
playwright:
# https://playwright.dev/docs/docker
# This Playwright version should match the one in `package.json`.
image: mcr.microsoft.com/playwright:v1.53.2
image: mcr.microsoft.com/playwright:v1.57.0
networks:
- app
depends_on:
Expand Down
Loading
Loading