Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #758 from dedica-team/develop
Browse files Browse the repository at this point in the history
Preparing Release 0.4.2 (Bugfix release 0.4.1)
  • Loading branch information
jenarp authored Nov 8, 2021
2 parents 4394bf7 + 19d2471 commit 8c292b8
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 53 deletions.
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Release
about: Create a new release
title: ''
labels: ''
assignees: ''

---

- [] check screenshots
- [] test-click through app, reports
- [] check docs
- [] gather changelog
- [] merge to master and tag
- [] AFTER release increment pom and package.json versions
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.bonndan</groupId>
<artifactId>nivio</artifactId>
<version>0.4.1</version>
<version>0.4.2</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nivio",
"version": "0.4.1",
"version": "0.4.2",
"private": true,
"homepage": "./",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const StatusBarLayout: React.FC<Props> = ({ onItemClick, onGroupClick }) => {

return groups.map((group) => {
if (group.items.length === 0) {
console.log('Skipping group without items');
return null;
}

Expand Down
53 changes: 23 additions & 30 deletions src/main/app/src/Components/Notification/Changes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactElement, useContext, useEffect, useState } from 'react';
import { IChange, INotificationMessage } from '../../interfaces';
import { IChange } from '../../interfaces';
import { Card, CardHeader, Table, TableBody, TableCell, TableRow } from '@material-ui/core';
import { get } from '../../utils/API/APIClient';
import IconButton from '@material-ui/core/IconButton';
Expand All @@ -11,19 +11,14 @@ import { Close, LinkOutlined } from '@material-ui/icons';
import Button from '@material-ui/core/Button';
import { LandscapeContext } from '../../Context/LandscapeContext';

interface Props {
notification: INotificationMessage;
}

/**
* Displays the changes of an ProcessingFinishedEvent
*
* @param notification
* @constructor
*/
const Changes: React.FC<Props> = ({ notification }) => {
const Changes: React.FC = () => {
const componentClasses = componentStyles();
const [changes, setChanges] = useState<ReactElement[]>([]);
const [renderedChanges, setRenderedChanges] = useState<ReactElement[]>([]);
const locateFunctionContext = useContext(LocateFunctionContext);
const landscapeContext = useContext(LandscapeContext);
const [visible, setVisible] = useState<boolean>(true);
Expand All @@ -42,7 +37,7 @@ const Changes: React.FC<Props> = ({ notification }) => {
* render changes, calling api for component info
*/
useEffect(() => {
if (notification == null) return;
if (landscapeContext.changes == null) return;

const getItemChange = (key: string, change: IChange): Promise<any> => {
if (change.changeType === 'DELETED') {
Expand Down Expand Up @@ -137,36 +132,34 @@ const Changes: React.FC<Props> = ({ notification }) => {
);
};

if (notification.changelog != null) {
let promises: Promise<any>[] = [];
for (let key of Object.keys(notification.changelog.changes)) {
let change = notification.changelog.changes[key];
let promises: Promise<any>[] = [];
for (let key of Object.keys(landscapeContext.changes)) {
let change = landscapeContext.changes[key];

switch (change.componentType) {
case 'Item':
promises.push(getItemChange(key, change));
break;
case 'Group':
promises.push(getGroupChange(key, change));
break;
case 'Relation':
promises.push(getRelationChange(key, change));
break;
}
switch (change.componentType) {
case 'Item':
promises.push(getItemChange(key, change));
break;
case 'Group':
promises.push(getGroupChange(key, change));
break;
case 'Relation':
promises.push(getRelationChange(key, change));
break;
}
Promise.all<ReactElement>(promises).then((rows) => {
setChanges(rows);
});
}
}, [notification, componentClasses.card, locateFunctionContext, landscapeContext]);
Promise.all<ReactElement>(promises).then((rows) => {
setRenderedChanges(rows);
});
}, [ componentClasses.card, locateFunctionContext, landscapeContext]);

if (!visible) return null;

return (
<Card className={componentClasses.card}>
<CardHeader title={'Latest changes in ' + notification.landscape} action={close} />
<CardHeader title={'Latest changes in ' + landscapeContext.landscape?.name} action={close} />
<Table aria-label={'changes'} style={{ tableLayout: 'fixed' }}>
<TableBody>{notification.changelog != null ? changes : null}</TableBody>
<TableBody>{landscapeContext.changes != null ? renderedChanges : null}</TableBody>
</Table>
</Card>
);
Expand Down
8 changes: 4 additions & 4 deletions src/main/app/src/Components/Notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ interface Props {
*/
const Notification: React.FC<Props> = ({ setSidebarContent }) => {
const classes = componentStyles();
const [newChanges, setNewChanges] = useState<Boolean>(false);
const [newChanges, setNewChanges] = useState<boolean>(false);
const [renderedChanges, setRenderedChanges] = useState<ReactElement | null>(null);
const landscapeContext = useContext(LandscapeContext);

/**
* render changes,
*/
useEffect(() => {
if (landscapeContext.notification == null) return;
setRenderedChanges(<Changes notification={landscapeContext.notification} />);
if (landscapeContext.changes == null) return;
setRenderedChanges(<Changes />);
setNewChanges(true);
}, [landscapeContext.notification]);
}, [landscapeContext.changes]);

return (
<Badge
Expand Down
2 changes: 1 addition & 1 deletion src/main/app/src/Context/FrontendMappingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const FrontendMappingProvider: React.FC = ({ children }) => {
get(`/api/mapping`).then((response) => {
setFrontendMapping(new Map(Object.entries(response)));
});
});
}, []);

return (
<FrontendMappingContext.Provider
Expand Down
12 changes: 10 additions & 2 deletions src/main/app/src/Context/LandscapeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { IAssessment, IAssessmentProps, ILandscape, INotificationMessage } from '../interfaces';
import { IAssessment, IAssessmentProps, IChanges, ILandscape, INotificationMessage } from "../interfaces";
import { get } from '../utils/API/APIClient';
import { withBasePath } from '../utils/API/BasePath';
import { Client, StompSubscription } from '@stomp/stompjs';
Expand All @@ -9,6 +9,7 @@ export interface LandscapeContextType {
readonly assessment: IAssessment | null;
readonly identifier: string | null;
readonly notification: INotificationMessage | null;
readonly changes: IChanges | null;
next: (identifier: string | null) => void;
getAssessmentSummary: (fqi: string) => IAssessmentProps | null;
}
Expand All @@ -18,6 +19,7 @@ export const LandscapeContext = React.createContext<LandscapeContextType>({
assessment: null,
identifier: null,
notification: null,
changes: null,
next: () => {},
getAssessmentSummary: () => {
return null;
Expand All @@ -33,10 +35,11 @@ export const LandscapeContext = React.createContext<LandscapeContextType>({
* @param props
* @constructor
*/
const LandscapeContextProvider: React.FC<{}> = (props) => {
const LandscapeContextProvider: React.FC = (props) => {
const [landscape, setLandscape] = useState<ILandscape | null>(null);
const [assessment, setAssessment] = useState<IAssessment | null>(null);
const [notification, setNotification] = useState<INotificationMessage | null>(null);
const [changes, setChanges] = useState<IChanges | null>(null);
const [identifier, setIdentifier] = useState<string | null>(null);

const backendUrl = withBasePath('/subscribe');
Expand All @@ -55,9 +58,13 @@ const LandscapeContextProvider: React.FC<{}> = (props) => {
const subscriptions: StompSubscription[] = [];
const eventSubscription = client.subscribe('/topic/events', (message) => {
const notificationMessage: INotificationMessage = JSON.parse(message.body);

if (notificationMessage.type === 'LayoutChangedEvent') {
setNotification(notificationMessage);
}
if (notificationMessage.type === 'ProcessingFinishedEvent') {
setChanges(notificationMessage.changelog.changes);
}
});

subscriptions.push(eventSubscription);
Expand Down Expand Up @@ -119,6 +126,7 @@ const LandscapeContextProvider: React.FC<{}> = (props) => {
assessment: assessment,
identifier: identifier,
notification: notification,
changes: changes,
next: (nextId) => {
if (identifier === nextId) return;
console.debug('New identifier', nextId);
Expand Down
7 changes: 6 additions & 1 deletion src/main/app/src/utils/testing/LandscapeContextValue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAssessment, IGroup, IItem, ILandscape } from '../../interfaces';
import { IAssessment, IChanges, IGroup, IItem, ILandscape } from "../../interfaces";
import { LandscapeContextType } from '../../Context/LandscapeContext';

const items: IItem[] = [
Expand Down Expand Up @@ -70,10 +70,15 @@ const assessments: IAssessment = {
},
};

const changes: IChanges = {

}

const landscapeContextValue: LandscapeContextType = {
identifier: 'test',
landscape: landscape,
assessment: assessments,
changes: changes,
next: typeof jest != 'undefined' ? jest.fn() : () => {},
getAssessmentSummary: (fqi) => {
return assessments.results[fqi].find((assessmentResult) => assessmentResult.summary) || null;
Expand Down
15 changes: 4 additions & 11 deletions src/main/java/de/bonndan/nivio/notification/EventNotification.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,17 @@ public class EventNotification {
* @throws NullPointerException if a required processing event field is empty
*/
public static EventNotification from(ProcessingEvent processingEvent) {
return new EventNotification(
processingEvent.getSource(),
processingEvent.getType(),
processingEvent.getLevel(),
processingEvent.getTimestamp(),
processingEvent.getMessage(),
null
);
}

public static EventNotification from(ProcessingFinishedEvent processingEvent) {
var changelog = (processingEvent instanceof ProcessingFinishedEvent) ?
((ProcessingFinishedEvent)processingEvent).getChangelog() : null;

return new EventNotification(
processingEvent.getSource(),
processingEvent.getType(),
processingEvent.getLevel(),
processingEvent.getTimestamp(),
processingEvent.getMessage(),
processingEvent.getChangelog()
changelog
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void onLayoutChangedEvent(LayoutChangedEvent event) {
public void broadcast(ProcessingEvent event) {
EventNotification eventNotification = EventNotification.from(event);
fifo.add(eventNotification);
LOGGER.debug(String.format("Broadcasting %s event.", event.getClass().getSimpleName()));
LOGGER.debug("Broadcasting {} event.", event.getClass().getSimpleName());
this.template.convertAndSend(WebSocketConfig.TOPIC + EVENTS, eventNotification);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ void onProcessingFinishedEvent() {
assertThat(value.getLevel()).isEqualTo("info");
assertThat(value.getType()).isEqualTo("ProcessingFinishedEvent");
assertThat(value.getLandscape()).isEqualTo("test");
assertThat(value.getChangelog()).isNotNull();
}

@Test
Expand Down

0 comments on commit 8c292b8

Please sign in to comment.