Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit cffa9c8

Browse files
authored
Release v1.9.4 (#1061)
* fix(ui): address issues on Drag'n'Drop functionality of dashboard widgets cr: https://code.amazon.com/reviews/CR-160389187 * fix(ui): address issues on image widget edition cr: https://code.amazon.com/reviews/CR-160389187 * chore: prepare v1.9.4 * chore: bumps cross-spawn npm package * chore: bumps cross-spawn npm package * chore: adding a missing change to the code base
1 parent f844ef1 commit cffa9c8

19 files changed

+192
-76
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.9.4] - 2024-11-22
9+
10+
### Fixed
11+
12+
- address issues on Drag'n'Drop functionality of dashboard widgets.
13+
- address issues on image widget edition.
14+
15+
816
## [1.9.3] - 2024-10-30
917

1018
### Added

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ lint-staged@13.1.0 under the MIT
129129
lint-staged@13.3.0 under the MIT
130130
mutationobserver-shim@0.3.7 under the MIT
131131
papaparse@5.4.1 under the MIT
132-
performance-dashboard-backend@1.9.3 under the Apache-2.0
132+
performance-dashboard-backend@1.9.4 under the Apache-2.0
133133
pino@6.14.0 under the MIT
134134
prettier@2.8.0 under the MIT
135135
prettier@2.8.1 under the MIT

backend/package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "performance-dashboard-backend",
3-
"version": "1.9.2",
3+
"version": "1.9.4",
44
"description": "Performance Dashboard on AWS Backend",
55
"license": "Apache-2.0",
66
"author": {

cdk/package-lock.json

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "performance-dashboard-cdk",
3-
"version": "1.9.2",
3+
"version": "1.9.4",
44
"description": "Performance Dashboard on AWS CDK",
55
"license": "Apache-2.0",
66
"author": {

deployment/performance-dashboard-on-aws.template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"AWSTemplateFormatVersion": "2010-09-09",
3-
"Description": "(SO0157) Performance Dashboard on AWS Solution Implementation v1.9.2",
3+
"Description": "(SO0157) Performance Dashboard on AWS Solution Implementation v1.9.4",
44
"Parameters": {
55
"AdminEmail": {
66
"Type": "String",

e2e-tests/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lambda",
3-
"version": "1.9.2",
3+
"version": "1.9.4",
44
"description": "test project for lambda",
55
"license": "Apache-2.0",
66
"author": {

frontend/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "performance-dashboard-frontend",
3-
"version": "1.9.2",
3+
"version": "1.9.4",
44
"private": true,
55
"description": "Performance Dashboard on AWS Frontend",
66
"license": "Apache-2.0",

frontend/src/components/FileInput.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ function FileInput(props: Props) {
7272
<div className="usa-hint">{props.hint}</div>
7373
{props.errors && (
7474
<span className="usa-error-message" id="file-input-error-alert" role="alert">
75-
{props.errors.reduce(
76-
(accumulator: string, currentValue: any) =>
77-
`${currentValue.message}\n${accumulator}`,
78-
"",
79-
)}
75+
{Array.isArray(props.errors)
76+
? props.errors.reduce(
77+
(accumulator: string, currentValue: any) =>
78+
`${currentValue.message}\n${accumulator}`,
79+
"",
80+
)
81+
: props.errors}
8082
</span>
8183
)}
8284
<div className={`usa-file-input${props.disabled ? " usa-file-input--disabled" : ""}`}>

frontend/src/components/WidgetTree.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ function WidgetTree(props: Props) {
9090
if (!tree) {
9191
return;
9292
}
93-
if (sourceIndex < 0) {
94-
sourceIndex = 0;
95-
}
96-
if (destinationIndex >= tree.nodes.length) {
97-
destinationIndex = tree.nodes.length - 1;
98-
}
9993

10094
const widgets = OrderingService.moveWidget(tree, sourceIndex, destinationIndex);
10195
if (widgets) {

frontend/src/containers/EditImage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ function EditImage() {
270270
accept={supportedImageFileTypes.toString()}
271271
loading={imageUploading}
272272
register={register}
273-
required
273+
required={!widget.content.fileName}
274274
hint={<span>{t("EditImageScreen.FileHint")}</span>}
275275
fileName={
276276
newImageFile?.name

frontend/src/services/OrderingService.ts

Lines changed: 75 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ function moveWidget(
140140
sourceIndex: number,
141141
destinationIndex: number,
142142
): Widget[] | undefined {
143-
if (sourceIndex === destinationIndex) {
144-
return undefined;
145-
}
146-
147143
const nodes = tree.nodes.flatMap((node) => {
148144
const list = [node];
149145
if (node.widget?.widgetType === WidgetType.Section) {
@@ -154,36 +150,93 @@ function moveWidget(
154150
return list;
155151
});
156152

157-
let source = nodes[sourceIndex];
158-
if (destinationIndex > sourceIndex && destinationIndex < sourceIndex + source.children.length) {
159-
// only true for sections, invalid case you can't drag a section inside itself
153+
// If sourceIndex or destinationIndex are out of bounds, don't move anything.
154+
if (
155+
sourceIndex < 0 ||
156+
sourceIndex >= nodes.length ||
157+
destinationIndex < 0 ||
158+
destinationIndex >= nodes.length
159+
)
160160
return undefined;
161-
}
162161

163-
// move items and it's children
164-
const items = nodes.splice(sourceIndex, 1 + source.children.length);
165-
if (destinationIndex > sourceIndex) {
166-
destinationIndex -= source.children.length;
162+
if (sourceIndex === destinationIndex) {
163+
return undefined;
167164
}
168165

166+
let source = nodes[sourceIndex];
169167
let destination = nodes[destinationIndex];
170-
if (destination) {
171-
// insert before the destination
172-
if (!!destination.section) {
173-
// if destination is a section, invalid movement
174-
if (source.widget?.widgetType === WidgetType.Section) {
175-
return undefined;
168+
169+
// If moving down
170+
if (sourceIndex < destinationIndex) {
171+
// And source is a Section and destination is a nested item.
172+
if (
173+
source &&
174+
source.widget?.widgetType === WidgetType.Section &&
175+
destination &&
176+
!!destination.section
177+
) {
178+
const sectionWidget = nodes.find((node) => node.id === destination.section);
179+
if (source.id === sectionWidget?.id) {
180+
// And the nested item belongs to the Source Section.
181+
// Then move the Sectiom to the position of the next item that is not a nested item.
182+
destinationIndex =
183+
(sectionWidget?.dragIndex ?? 0) + (sectionWidget?.children?.length ?? 0) + 1;
176184
} else {
177-
// assign the new section to the widget
185+
// And the nested item does not belong to the Source Section.
186+
// Then move the Section to the position of the destination item.
187+
destinationIndex = destinationIndex + 1 - source.children.length;
188+
}
189+
190+
// If the destinationIndex is out of bounds, we don't move anything.
191+
if (destinationIndex >= nodes.length) return undefined;
192+
193+
destination = nodes[destinationIndex];
194+
}
195+
// And source is not a Section
196+
if (source && source.widget?.widgetType !== WidgetType.Section) {
197+
// And destination is a Section.
198+
if (destination && destination.widget?.widgetType === WidgetType.Section) {
199+
// Then move the widget to inside of the Section
200+
// assign the new section to the widget.
201+
source.section = nodes[destinationIndex + 1].section;
202+
} else if (destination && destination.section) {
203+
// And destination is a nested item.
204+
// Then move the widget to inside of the Section
205+
// assign the new section to the widget.
178206
source.section = destination.section;
207+
if (destination.id.startsWith("end-")) {
208+
// And destination is the last item of the Section.
209+
// Then move widget to outside of the Section
210+
source.section = "";
211+
}
179212
}
180-
} else {
181-
source.section = "";
182213
}
183214
} else {
184-
source.section = "";
215+
// If moving up.
216+
// And source is a section and destination is a nested item.
217+
if (
218+
source &&
219+
source.widget?.widgetType === WidgetType.Section &&
220+
destination &&
221+
!!destination.section
222+
) {
223+
const sectionWidget = nodes.find((node) => node.id === destination.section);
224+
// Then move the Section to the position of the previous item that is not a nested item.
225+
destinationIndex = sectionWidget?.dragIndex ?? 0;
226+
destination = nodes[destinationIndex];
227+
}
228+
if (source && source.widget?.widgetType !== WidgetType.Section) {
229+
// And source is not a Section
230+
// Then assign the parent element if of the destination if any.
231+
source.section = destination.section;
232+
}
185233
}
186234

235+
// move items and it's children
236+
const items = nodes.splice(sourceIndex, 1 + source.children.length);
237+
if (destinationIndex > sourceIndex) {
238+
destinationIndex -= source.children.length;
239+
}
187240
// insert the items in the given position
188241
nodes.splice(destinationIndex, 0, ...items);
189242

0 commit comments

Comments
 (0)