Skip to content

Commit

Permalink
Fix review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophNiehoff committed Jul 6, 2023
1 parent def50e9 commit 5da0ae6
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/client/components/board/board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class Board extends React.Component {
/>
)}
{this.props.G.modelType === ModelType.PRIVACY_ENHANCED && (
<PrivacyEnhancedModel modelRef={this.props.G.modelRef} />
<PrivacyEnhancedModel modelReference={this.props.G.modelReference} />
)}
<div className="player-wrap">
<div className="playingCardsContainer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ describe('privacy enhanced model', () => {
it('should provide link to model', () => {
const linkToModel = 'https://link/to/model';

render(<PrivacyEnhancedModel modelRef={linkToModel} />);
render(<PrivacyEnhancedModel modelReference={linkToModel} />);

screen.getByText(linkToModel);
screen.getByRole('link');
});

it('should not provide link to model if there is no modelRef', () => {
render(<PrivacyEnhancedModel modelRef={undefined} />);
it('should not provide link to model if there is no modelReference', () => {
render(<PrivacyEnhancedModel modelReference={undefined} />);

expect(screen.queryByRole('link')).toBeNull();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import type React from 'react';
import './privacyEnhancedModel.css';

interface PrivacyEnhancedModelProps {
modelRef?: string;
modelReference?: string;
}

const PrivacyEnhancedModel: React.FC<PrivacyEnhancedModelProps> = ({
modelRef,
modelReference,
}) => {
if (modelRef) {
if (modelReference) {
return (
<div className="model modelContainer">
<h2>Threat Modelling</h2>
<p>
{modelRef && (
{modelReference && (
<>
<p>
The model is hosted externally:&nbsp;
<a href={modelRef}>{modelRef}</a>
<a href={modelReference}>{modelReference}</a>
{/* Note: React takes care about sanitization of user input above to prevent XSS */}
</p>
</>
Expand Down
4 changes: 2 additions & 2 deletions src/client/components/threatmodal/threatmodal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ class ThreatModal extends React.Component {
return (
<ModalBody>
<FormGroup>
<Label for="ref">
<Label for="referenceInputField">
Reference <em>(e.g. link to external bug tracking system)</em>
</Label>
<Input
type="text"
name="ref"
name="referenceInputField"
disabled={!this.isOwner}
autoComplete="off"
value={this.state.title}
Expand Down
10 changes: 5 additions & 5 deletions src/client/pages/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ interface CreateState {
turnDuration: number;
provideModelThruAlternativeChannel: boolean;
gameMode: GameMode;
modelRef?: string;
modelReference?: string;
}

class Create extends React.Component<CreateProps, CreateState> {
Expand Down Expand Up @@ -89,7 +89,7 @@ class Create extends React.Component<CreateProps, CreateState> {
turnDuration: DEFAULT_TURN_DURATION,
provideModelThruAlternativeChannel: false,
gameMode: DEFAULT_GAME_MODE,
modelRef: undefined,
modelReference: undefined,
};

this.onPlayersUpdated = this.onPlayersUpdated.bind(this);
Expand Down Expand Up @@ -138,8 +138,8 @@ class Create extends React.Component<CreateProps, CreateState> {
formData.append('startSuit', this.state.startSuit);
formData.append('turnDuration', `${this.state.turnDuration}`);
formData.append('gameMode', this.state.gameMode);
if (this.state.modelRef) {
formData.append('modelRef', this.state.modelRef);
if (this.state.modelReference) {
formData.append('modelReference', this.state.modelReference);
}

// Use Fetch API (not superagent)
Expand Down Expand Up @@ -251,7 +251,7 @@ class Create extends React.Component<CreateProps, CreateState> {
onModelRefUpdated(e: ChangeEvent<HTMLInputElement>): void {
this.setState({
...this.state,
modelRef: e.target.value,
modelReference: e.target.value,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/styles/create.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ table {
}

.text-input-wide {
width: 150%;
width: 100%;
}
2 changes: 1 addition & 1 deletion src/game/gameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export interface GameState {
gameMode: GameMode;
turnDuration: number;
modelType: ModelType;
modelRef?: string;
modelReference?: string;
turnFinishTargetTime?: number;
}
2 changes: 1 addition & 1 deletion src/game/setupData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface SetupData {
modelType: ModelType;
turnDuration: number;
spectatorCredential: string;
modelRef?: string;
modelReference?: string;
}
4 changes: 2 additions & 2 deletions src/game/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function setupGame(ctx: Ctx, setupData?: SetupData): GameState {
const gameMode = setupData?.gameMode ?? DEFAULT_GAME_MODE;
const modelType = setupData?.modelType ?? ModelType.PRIVACY_ENHANCED;
const turnDuration = setupData?.turnDuration ?? DEFAULT_TURN_DURATION;
const modelRef = setupData?.modelRef;
const modelReference = setupData?.modelReference;

const deck = getAllCards(gameMode);
const startingCard = getStartingCard(gameMode, startSuit);
Expand Down Expand Up @@ -57,7 +57,7 @@ export function setupGame(ctx: Ctx, setupData?: SetupData): GameState {
gameMode: gameMode,
turnDuration: turnDuration,
modelType,
modelRef,
modelReference,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const createGame = (gameServer) => async (ctx) => {
turnDuration: ctx.request.body.turnDuration,
gameMode: ctx.request.body.gameMode,
modelType: ctx.request.body.modelType,
modelRef: ctx.request.body.modelRef,
modelReference: ctx.request.body.modelReference,
spectatorCredential,
},
});
Expand Down

0 comments on commit 5da0ae6

Please sign in to comment.