Skip to content

Commit

Permalink
fix: fix review issues
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Dec 8, 2024
1 parent f1b923a commit 404ff20
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
16 changes: 9 additions & 7 deletions lib/gui/event-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ export class EventSource {
this._connections = [];
}

private _write(connection: Response, event: string, data?: unknown): void {
connection.write('event: ' + event + '\n');
connection.write('data: ' + stringify(data) + '\n');
connection.write('\n\n');
}

addConnection(connection: Response): void {
this._connections.push(connection);

connection.write('event: ' + ClientEvents.CONNECTED + '\n');
connection.write('data: 1\n');
connection.write('\n\n');
this._write(connection, ClientEvents.CONNECTED, 1);
}

emit(event: string, data?: unknown): void {
this._connections.forEach(function(connection) {
connection.write('event: ' + event + '\n');
connection.write('data: ' + stringify(data) + '\n');
connection.write('\n\n');
this._connections.forEach((connection) => {
this._write(connection, event, data);
});
}
}
1 change: 0 additions & 1 deletion lib/static/modules/actions/gui-server-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import actionNames from '@/static/modules/action-names';

type SetGuiServerConnectionStatusAction = Action<typeof actionNames.SET_GUI_SERVER_CONNECTION_STATUS, {
isConnected: boolean;
wasDisconnected?: boolean;
}>;
export const setGuiServerConnectionStatus = (payload: SetGuiServerConnectionStatusAction['payload']): SetGuiServerConnectionStatusAction =>
({type: actionNames.SET_GUI_SERVER_CONNECTION_STATUS, payload});
Expand Down
3 changes: 1 addition & 2 deletions lib/static/modules/default-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ export default Object.assign({config: configDefaults}, {
currentDirection: SortDirection.Asc
},
guiServerConnection: {
isConnected: false,
wasDisconnected: false
isConnected: false
}
},
ui: {
Expand Down
3 changes: 1 addition & 2 deletions lib/static/modules/reducers/gui-server-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export default (state: State, action: SomeAction): State => {
return applyStateUpdate(state, {
app: {
guiServerConnection: {
isConnected: action.payload.isConnected,
wasDisconnected: action.payload.wasDisconnected
isConnected: action.payload.isConnected
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/static/new-ui/app/gui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Gui(): ReactNode {
store.dispatch({type: actionNames.UPDATE_LOADING_TITLE, payload: 'Lost connection to Testplane UI server. Trying to reconnect'});
store.dispatch({type: actionNames.UPDATE_LOADING_VISIBILITY, payload: true});

store.dispatch(setGuiServerConnectionStatus({isConnected: false, wasDisconnected: true}));
store.dispatch(setGuiServerConnectionStatus({isConnected: false}));
};

eventSource.addEventListener(ClientEvents.BEGIN_SUITE, (e) => {
Expand Down
8 changes: 5 additions & 3 deletions lib/static/new-ui/components/InfoPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function InfoPanel(): ReactNode {

sections.push(<PanelSection
title={'Testplane UI v' + version}
description={<span>To get the most out of Testplane UI, try to keep it updated to the latest version. Check out fresh releases <a href={'https://github.com/gemini-testing/html-reporter/releases'}>on GitHub</a>.</span>}
description={<span>To get the most out of Testplane UI, try to keep it updated to the latest version. Check out fresh <a href={'https://github.com/gemini-testing/html-reporter/releases'}>releases on GitHub</a>.</span>}
/>);

const timestamp = useSelector(state => state.timestamp);
Expand Down Expand Up @@ -56,11 +56,13 @@ export function InfoPanel(): ReactNode {
</div>
</PanelSection>);

const lastSection = sections.pop();

return <AsidePanel title={'Info'} className={styles.infoPanel}>
{sections.slice(0, -1).map((section, index) => <React.Fragment key={index}>
{sections.map((section, index) => <React.Fragment key={index}>
{section}
<Divider orientation={'horizontal'} className={styles.divider}/>
</React.Fragment>)}
{sections[sections.length - 1]}
{lastSection}
</AsidePanel>;
}
1 change: 0 additions & 1 deletion lib/static/new-ui/types/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ export interface State {
};
guiServerConnection: {
isConnected: boolean;
wasDisconnected: boolean | undefined;
};
};
ui: {
Expand Down

0 comments on commit 404ff20

Please sign in to comment.