Skip to content

Commit

Permalink
merge main in VUU-70
Browse files Browse the repository at this point in the history
  • Loading branch information
vferraro-scottlogic committed Nov 6, 2023
1 parent 5ad3a79 commit 6c93a6a
Show file tree
Hide file tree
Showing 597 changed files with 16,014 additions and 6,875 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,45 @@ jobs:
run: cd ./vuu-ui && npm install
- run: cd ./vuu-ui && npm run test:vite

cypress-e2e:
# As a third party action, cypress-io is pinned to a full length commit SHA for security purposes.
# This is also a requirement for the semgrep (static code analysis) scan to pass.
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-third-party-actions
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- name: Install dependencies
run: cd ./vuu-ui && npm install
- name: Run end-to-end tests in Chrome
uses: cypress-io/github-action@bd9dda317ed2d4fbffc808ba6cdcd27823b2a13b
with:
install: false
working-directory: ./vuu-ui
browser: chrome
build: npm run build
start: npm run showcase
wait-on: "http://localhost:5173"
- name: Run end-to-end tests in Edge
uses: cypress-io/github-action@bd9dda317ed2d4fbffc808ba6cdcd27823b2a13b
with:
install: false
working-directory: ./vuu-ui
browser: edge
build: npm run build
start: npm run showcase
wait-on: "http://localhost:5173"

# ensure the vuu example and showcase still build
vuu-and-showcase-build:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ yarn-debug.log*
yarn-error.log*

/vuu-ui/showcase/src/examples/**/*.js
/vuu-ui/cypress/screenshots

deployed_apps
dist
Expand Down
2 changes: 2 additions & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ vuu/src/main/resources/www/ws-example.html
vuu/src/main/scala/org/finos/vuu/provider/simulation/SimulatedBigInstrumentsProvider.scala
vuu-ui/packages/vuu-data/src/array-data-source/group-utils.ts
vuu-ui/packages/vuu-datagrid-extras/src/column-expression-input/column-language-parser/walkExpressionTree.ts
vuu-ui/packages/vuu-layout/src/layout-persistence/RemoteLayoutPersistenceManager.ts
vuu-ui/packages/vuu-popups/src/menu/useContextMenu.tsx
vuu-ui/packages/vuu-table-extras/src/cell-edit-validators/PatternValidator.ts
vuu-ui/packages/vuu-ui-controls/src/list/Highlighter.tsx
vuu-ui/packages/vuu-ui-controls/src/list/common-hooks/utils/filter-utils.ts
vuu-ui/showcase/scripts/build-file-list.mjs
vuu-ui/showcase/src/index.tsx
vuu-ui/showcase/src/examples/Layout/Menu.examples.tsx
vuu-ui/tools/websocket-test.html
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.finos.vuu.layoutserver;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://127.0.0.1:5173")
.allowedMethods("GET", "POST", "PUT", "DELETE");
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
package org.finos.vuu.layoutserver.config;

import lombok.RequiredArgsConstructor;
import org.finos.vuu.layoutserver.dto.request.LayoutRequestDto;
import org.finos.vuu.layoutserver.dto.request.MetadataRequestDto;
import org.finos.vuu.layoutserver.dto.response.MetadataResponseDto;
import org.finos.vuu.layoutserver.model.Layout;
import org.finos.vuu.layoutserver.model.Metadata;
import org.finos.vuu.layoutserver.service.LayoutService;
import org.modelmapper.ModelMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RequiredArgsConstructor
@Configuration
public class MappingConfig {

private final LayoutService layoutService;

@Bean
public ModelMapper modelMapper() {
ModelMapper mapper = new ModelMapper();

mapper.typeMap(LayoutRequestDto.class, Layout.class)
.addMappings(m -> m.skip(Layout::setId));

mapper.typeMap(MetadataRequestDto.class, Metadata.class)
.addMappings(m -> m.skip(Metadata::setId));
mapper.typeMap(Metadata.class, MetadataResponseDto.class)
.addMappings(m -> m.map(
metadata -> layoutService.getLayoutByMetadataId(metadata.getId()),
MetadataResponseDto::setLayoutId));

return mapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@
import org.modelmapper.ModelMapper;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
Expand All @@ -38,6 +30,7 @@ public class LayoutController {
* @param id ID of the layout to get
* @return the layout
*/
@ResponseStatus(HttpStatus.OK)
@GetMapping("/{id}")
public LayoutResponseDto getLayout(@PathVariable UUID id) {
return mapper.map(layoutService.getLayout(id), LayoutResponseDto.class);
Expand All @@ -48,6 +41,7 @@ public LayoutResponseDto getLayout(@PathVariable UUID id) {
*
* @return the metadata
*/
@ResponseStatus(HttpStatus.OK)
@GetMapping("/metadata")
public List<MetadataResponseDto> getMetadata() {

Expand Down Expand Up @@ -97,8 +91,6 @@ public void updateLayout(@PathVariable UUID id,
@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping("/{id}")
public void deleteLayout(@PathVariable UUID id) {
// Generate a 404 if layout doesn't exist
layoutService.getLayout(id);
layoutService.deleteLayout(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class LayoutRequestDto {
* components)
*/
@JsonProperty(value = "definition", required = true)
@NotBlank(message = "Please provide a valid definition")
@NotBlank(message = "Definition must not be blank")
private String definition;

@JsonProperty(value = "metadata", required = true)
@NotNull(message = "Please provide valid metadata")
@NotNull(message = "Metadata must not be null")
private MetadataRequestDto metadata;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package org.finos.vuu.layoutserver.dto.request;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import lombok.Data;
import org.finos.vuu.layoutserver.dto.MetadataDto;

import javax.validation.constraints.NotNull;
import org.finos.vuu.layoutserver.model.BaseMetadata;

@Data
public class MetadataRequestDto implements MetadataDto {

@JsonProperty(value = "name", required = true)
@NotNull(message = "Please provide a valid name")
private String name;
public class MetadataRequestDto {

private String group;
private String screenshot;
private String user;
@JsonUnwrapped
BaseMetadata baseMetadata;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class LayoutResponseDto {
private UUID id;

/**
* The definition of the layout as a string (e.g. stringified JSON structure containing components)
* The definition of the layout as a string (e.g. stringified JSON structure containing
* components)
*/
private String definition;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package org.finos.vuu.layoutserver.dto.response;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import lombok.Data;
import org.finos.vuu.layoutserver.dto.MetadataDto;
import org.finos.vuu.layoutserver.model.BaseMetadata;

import java.util.Date;
import java.time.LocalDate;
import java.util.UUID;

@Data
public class MetadataResponseDto implements MetadataDto {
public class MetadataResponseDto {

private UUID layoutId;
private String name;
private String group;
private String screenshot;
private String user;
private Date created;
private Date updated;

@JsonUnwrapped
BaseMetadata baseMetadata;

private LocalDate created;
private LocalDate updated;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.finos.vuu.layoutserver.controller;
package org.finos.vuu.layoutserver.exceptions;

import org.finos.vuu.layoutserver.dto.response.ErrorResponse;
import org.finos.vuu.layoutserver.exceptions.InternalServerErrorException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;

@ControllerAdvice
public class GlobalExceptionHandler {
Expand All @@ -20,11 +22,23 @@ public ResponseEntity<Object> handleNotFound(HttpServletRequest request, Excepti
return generateResponse(request, ex, HttpStatus.NOT_FOUND);
}

@ExceptionHandler({MethodArgumentNotValidException.class, MethodArgumentTypeMismatchException.class})
public ResponseEntity<Object> handleBadRequest(Exception ex, HttpServletRequest request) {
@ExceptionHandler({
HttpMessageNotReadableException.class,
MethodArgumentTypeMismatchException.class})
public ResponseEntity<Object> handleBadRequest(HttpServletRequest request, Exception ex) {

return generateResponse(request, ex, HttpStatus.BAD_REQUEST);
}

@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<String> handleMethodArgumentNotValid(MethodArgumentNotValidException ex) {
List<String> errors = ex.getFieldErrors()
.stream()
.map(fieldError -> fieldError.getField() + ": " + fieldError.getDefaultMessage())
.collect(Collectors.toList());
return new ResponseEntity<>(errors.toString(),
org.springframework.http.HttpStatus.BAD_REQUEST);
}
@ExceptionHandler(InternalServerErrorException.class)
public ResponseEntity<Object> handleInternalServerError(HttpServletRequest request, Exception ex) {
return generateResponse(request, ex, HttpStatus.INTERNAL_SERVER_ERROR);
Expand All @@ -35,4 +49,5 @@ private ResponseEntity<Object> generateResponse(HttpServletRequest request,
HttpStatus status) {
return new ResponseEntity<>(new ErrorResponse(request, ex, status), status);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.finos.vuu.layoutserver.model;

import lombok.Data;

import javax.persistence.Embeddable;
import javax.persistence.Lob;

@Data
@Embeddable
public class BaseMetadata {

private String name;
private String group;

@Lob
private String screenshot;

private String user;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.finos.vuu.layoutserver.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import javax.persistence.*;
import java.time.LocalDate;
import java.util.UUID;
import lombok.Data;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Metadata {

Expand All @@ -19,16 +21,10 @@ public class Metadata {
@Column(columnDefinition = "BINARY(16)")
private UUID id;

private String name;

private String group;

@Column(length = 16384)
private String screenshot;

private String user;
@Embedded
private BaseMetadata baseMetadata;

private Date created = new Date();
private final LocalDate created = LocalDate.now();

private Date updated;
private LocalDate updated;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package org.finos.vuu.layoutserver.repository;

import java.util.UUID;
import org.finos.vuu.layoutserver.model.Layout;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.UUID;

@Repository
public interface LayoutRepository extends CrudRepository<Layout, UUID> {}
public interface LayoutRepository extends CrudRepository<Layout, UUID> {

Layout findLayoutByMetadataId(UUID id);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.finos.vuu.layoutserver.repository;

import java.util.UUID;
import org.finos.vuu.layoutserver.model.Metadata;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.UUID;

@Repository
public interface MetadataRepository extends CrudRepository<Metadata, UUID> {}
Loading

0 comments on commit 6c93a6a

Please sign in to comment.