Skip to content

Commit

Permalink
add upload task json model, new nice modals and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReDBrother committed Jan 6, 2024
1 parent 3d3d57f commit dbd0d89
Show file tree
Hide file tree
Showing 49 changed files with 1,839 additions and 1,477 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test('test rendering GameList', async () => {
expect(getByText(/Lobby/)).toBeInTheDocument();
expect(getByText(/Online players: 2/)).toBeInTheDocument();
expect(getByText(/Tournaments/)).toBeInTheDocument();
expect(getByText(/Completed Games/)).toBeInTheDocument();
expect(getByText(/History/)).toBeInTheDocument();
expect(createGameButton).toBeInTheDocument();
});

Expand All @@ -206,7 +206,7 @@ test('test rendering create game dialog', async () => {
expect(getByRole('button', { name: 'Create battle' })).toBeInTheDocument();
});

test('test lobby completed games infinite scroll', async () => {
test('test lobby history infinite scroll', async () => {
const user = userEvent.setup();
const {
findByText,
Expand All @@ -223,7 +223,7 @@ test('test lobby completed games infinite scroll', async () => {

const axiosSpy = jest.spyOn(axios, 'get');

await user.click(await findByRole('tab', { name: 'Completed Games' }));
await user.click(await findByRole('tab', { name: 'History' }));

expect(await findByText(`Total games: ${pageInfo1.totalEntries}`)).toBeInTheDocument();
expect(axiosSpy).toHaveBeenCalledWith('/api/v1/games/completed?page_size=20');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import userTypes from '../widgets/config/userTypes';
import editor from '../widgets/machines/editor';
import game from '../widgets/machines/game';
import task from '../widgets/machines/task';
import RootContainer from '../widgets/pages/GameRoomWidget';
import RootContainer from '../widgets/pages/RoomWidget';
import reducers from '../widgets/slices';

jest.mock('@fortawesome/react-fontawesome', () => ({
Expand Down
33 changes: 20 additions & 13 deletions services/app/apps/codebattle/assets/js/widgets/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Suspense } from 'react';

import NiceModal from '@ebay/nice-modal-react';
import {
configureStore,
combineReducers,
Expand All @@ -14,6 +15,8 @@ import rollbar from '@/lib/rollbar';
import machines from '@/machines';
import reducers from '@/slices';

import PageNames from './config/pageNames';

const {
game: mainMachine,
editor: editorMachine,
Expand Down Expand Up @@ -51,7 +54,7 @@ const store = configureStore({
const persistor = persistStore(store);

const InvitesContainer = React.lazy(() => import('./components/InvitesContainer'));
const GameRoomWidget = React.lazy(() => import('./pages/GameRoomWidget'));
const GameRoomWidget = React.lazy(() => import('./pages/RoomWidget'));
const LobbyWidget = React.lazy(() => import('./pages/lobby'));
const RatingList = React.lazy(() => import('./pages/rating'));
const UserSettings = React.lazy(() => import('./pages/settings'));
Expand All @@ -70,12 +73,14 @@ export const Game = () => (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Suspense>
<GameRoomWidget
pageName="game"
mainMachine={mainMachine}
taskMachine={taskMachine}
editorMachine={editorMachine}
/>
<NiceModal.Provider>
<GameRoomWidget
pageName={PageNames.game}
mainMachine={mainMachine}
taskMachine={taskMachine}
editorMachine={editorMachine}
/>
</NiceModal.Provider>
</Suspense>
</PersistGate>
</Provider>
Expand All @@ -85,12 +90,14 @@ export const Builder = () => (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Suspense>
<GameRoomWidget
pageName="builder"
mainMachine={mainMachine}
taskMachine={taskMachine}
editorMachine={editorMachine}
/>
<NiceModal.Provider>
<GameRoomWidget
pageName={PageNames.builder}
mainMachine={mainMachine}
taskMachine={taskMachine}
editorMachine={editorMachine}
/>
</NiceModal.Provider>
</Suspense>
</PersistGate>
</Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ export default function ChatHeader({ showRooms = false, disabled = false }) {

const headerClassName = cn(
'd-flex align-items-center', {
'border-bottom': showRooms || currentUserIsAdmin,
'border-bottom': (showRooms || (currentUserIsAdmin && !disabled)),
},
);

return (
<div className={headerClassName}>
{showRooms && <Rooms disabled={disabled} />}
{currentUserIsAdmin && (
{currentUserIsAdmin && !disabled && (
<button
type="button"
className="btn btn-sm btn-link text-danger rounded-lg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import editorUserTypes from '../config/editorUserTypes';
import GameRoomModes from '../config/gameModes';
import languages from '../config/languages';
import sound from '../lib/sound';
import { addCursorListeners } from '../middlewares/Game';
import { addCursorListeners } from '../middlewares/Room';
import { gameIdSelector, gameModeSelector } from '../selectors/index';
import { actions } from '../slices';
import getLanguageTabSize, { shouldReplaceTabsWithSpaces } from '../utils/editor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useContext } from 'react';
import { useDispatch } from 'react-redux';

import { inTestingRoomSelector, openedReplayerSelector } from '../machines/selectors';
import { sendCurrentLangAndSetTemplate, updateCurrentLangAndSetTemplate } from '../middlewares/Game';
import { sendCurrentLangAndSetTemplate, updateCurrentLangAndSetTemplate } from '../middlewares/Room';
import useMachineStateSelector from '../utils/useMachineStateSelector';

import LanguagePickerView from './LanguagePickerView';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function Messages({ messages, displayMenu = () => {}, disabled = false }) {
<span className="d-flex text-muted position-absolute h-100 w-100 justify-content-center align-items-center">
<FontAwesomeIcon className="h-25 w-25" icon="comment-slash" />
</span>
<div className="position-absolute h-100 w-100 bg-dark cb-opacity-50" />
<div className="position-absolute h-100 w-100 bg-dark cb-opacity-50 rounded-left" />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const modalCodes = {
taskParamsModal: 'task_params_modal',
gameResultModal: 'game_results_modal',
taskConfigurationModal: 'task_configuration_modal',
taskDescriptionModal: 'task_description_modal',
tournamentStatisticsModal: 'tournament_statistics_modal',
premiumRestrictionModal: 'premium_restriction_modal',
};

export default modalCodes;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const pageNames = {
game: 'game',
builder: 'builder',
};

export default pageNames;
13 changes: 11 additions & 2 deletions services/app/apps/codebattle/assets/js/widgets/machines/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,14 @@ const machine = {
{ target: 'waiting', cond: 'isWaitingGame' },
{ target: 'builder', cond: 'isTaskBuilder' },
{ target: 'active', cond: 'isActiveGame' },
{ target: 'game_over', cond: 'isGameOver' },
{ target: 'game_over', cond: 'isTimeout' },
{
target: 'game_over',
cond: 'isGameOver',
},
{
target: 'game_over',
cond: 'isTimeout',
},
{ target: 'failure', action: 'throwError' },
],

Expand Down Expand Up @@ -215,6 +221,9 @@ const machine = {
target: 'active',
actions: ['soundTournamentGameCreated'],
},
'tournament:round_finished': {
target: 'game_over',
},
check_result: {
target: 'active',
actions: ['soundStartChecking'],
Expand Down
Loading

0 comments on commit dbd0d89

Please sign in to comment.