Skip to content

Commit

Permalink
Rename modelType
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophNiehoff committed Jun 9, 2023
1 parent 75e89eb commit 9508928
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 14 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 @@ -121,7 +121,7 @@ class Board extends React.Component {
onSelectComponent={this.props.moves.selectComponent}
/>
)}
{this.props.G.modelType === ModelType.DEFAULT && (
{this.props.G.modelType === ModelType.PRIVACY_ENHANCED && (
<PrivacyEnhancedModel modelRef={this.props.G.modelRef} />
)}
<div className="player-wrap">
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/threatmodal/threatmodal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class ThreatModal extends React.Component {
}

get isPrivacyEnhancedMode() {
return this.props.G.modelType === ModelType.DEFAULT;
return this.props.G.modelType === ModelType.PRIVACY_ENHANCED;
}

threatDetailModalBody() {
Expand Down
12 changes: 8 additions & 4 deletions src/client/pages/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Create extends React.Component<CreateProps, CreateState> {

formData.append('players', `${this.state.players}`);
formData.append('modelType', this.state.modelType);
if (this.state.modelType !== ModelType.DEFAULT) {
if (this.state.modelType !== ModelType.PRIVACY_ENHANCED) {
formData.append(
'model',
this.state.modelType === ModelType.IMAGE
Expand Down Expand Up @@ -497,14 +497,18 @@ class Create extends React.Component<CreateProps, CreateState> {
<Input
id="radio-button-default-model"
type="radio"
value={ModelType.DEFAULT}
value={ModelType.PRIVACY_ENHANCED}
name="model-type"
onChange={this.updateModelType}
checked={this.state.modelType === ModelType.DEFAULT}
checked={
this.state.modelType === ModelType.PRIVACY_ENHANCED
}
/>
Privacy enhanced mode.
<Input
disabled={this.state.modelType !== ModelType.DEFAULT}
disabled={
this.state.modelType !== ModelType.PRIVACY_ENHANCED
}
type="text"
placeholder="Provide link to model (e.g. in wiki)"
className="text-input-wide"
Expand Down
2 changes: 1 addition & 1 deletion src/game/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('utils', () => {
[
{
testCase: 'the default model',
modelType: ModelType.DEFAULT,
modelType: ModelType.PRIVACY_ENHANCED,
},
{
testCase: 'a Threat Dragon model',
Expand Down
2 changes: 1 addition & 1 deletion src/game/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { SetupData } from './setupData';
export function setupGame(ctx: Ctx, setupData?: SetupData): GameState {
const startSuit = setupData?.startSuit ?? DEFAULT_START_SUIT;
const gameMode = setupData?.gameMode ?? DEFAULT_GAME_MODE;
const modelType = setupData?.modelType ?? ModelType.DEFAULT;
const modelType = setupData?.modelType ?? ModelType.PRIVACY_ENHANCED;
const turnDuration = setupData?.turnDuration ?? DEFAULT_TURN_DURATION;
const modelRef = setupData?.modelRef;

Expand Down
2 changes: 1 addition & 1 deletion src/server/__tests__/server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ describe('authentificaton', () => {
.post('/game/create')
.field('players', players)
.field('names[]', ['P1', 'P2', 'P3'])
.field('modelType', ModelType.DEFAULT);
.field('modelType', ModelType.PRIVACY_ENHANCED);

expect(response.body.game).toBeDefined();
expect(response.body.credentials.length).toBe(players);
Expand Down
6 changes: 3 additions & 3 deletions src/server/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const createGame = (gameServer) => async (ctx) => {
break;
}

case ModelType.DEFAULT: {
case ModelType.PRIVACY_ENHANCED: {
await gameServer.db.setModel(gameId, DEFAULT_MODEL);
break;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ export const downloadThreatDragonModel = (gameServer) => async (ctx) => {
model: true,
});
const isJsonModel =
game.state.G.modelType == ModelType.DEFAULT ||
game.state.G.modelType == ModelType.PRIVACY_ENHANCED ||
game.state.G.modelType == ModelType.THREAT_DRAGON;

if (!isJsonModel) {
Expand Down Expand Up @@ -222,7 +222,7 @@ export const downloadThreatsMarkdownFile = (gameServer) => async (ctx) => {
});

const isJsonModel =
game.state.G.modelType == ModelType.DEFAULT ||
game.state.G.modelType == ModelType.PRIVACY_ENHANCED ||
game.state.G.modelType == ModelType.THREAT_DRAGON;
const threats = getThreats(
game.state,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export enum ModelType {
THREAT_DRAGON = 'Threat Dragon',
DEFAULT = 'Default',
PRIVACY_ENHANCED = 'Default',
IMAGE = 'Image',
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function logEvent(message: string): void {

export function isModelType(value: string): value is ModelType {
return (
value === ModelType.DEFAULT ||
value === ModelType.PRIVACY_ENHANCED ||
value === ModelType.IMAGE ||
value === ModelType.THREAT_DRAGON
);
Expand Down

0 comments on commit 9508928

Please sign in to comment.