Skip to content

Commit

Permalink
Merge branch 'development' into Tim_bm_materials_list_index
Browse files Browse the repository at this point in the history
  • Loading branch information
tdkent committed Oct 17, 2023
2 parents d1d6522 + 1d9c980 commit f4ea6f0
Show file tree
Hide file tree
Showing 51 changed files with 1,566 additions and 455 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ src/components/AutoReload/**
src/components/AutoUpdate/**
src/components/Badge/**
src/components/common/**
src/components/ForcePasswordUpdate/**
src/components/Header/**
src/components/Inventory/**
src/components/Login/**
Expand All @@ -50,4 +49,6 @@ src/components/Timelog/**
src/components/UpdatePassword/**
src/components/UserManagement/**
src/components/UserProfile/**
src/components/WeeklySummary/**
src/components/WeeklySummariesReport/**
src/components/MouseoverText/**
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module.exports = {
'react/react-in-jsx-scope': 'off',
'import/no-duplicates': 'off',
'import/no-named-as-default': 'off',
'no-alert': 'error',
'no-console': 'error',
},
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ src/components/AutoReload/**
src/components/AutoUpdate/**
src/components/Badge/**
src/components/common/**
src/components/ForcePasswordUpdate/**
src/components/Header/**
src/components/Inventory/**
src/components/Login/**
Expand All @@ -47,4 +46,6 @@ src/components/Timelog/**
src/components/UpdatePassword/**
src/components/UserManagement/**
src/components/UserProfile/**
src/components/WeeklySummary/**
src/components/WeeklySummariesReport/**
src/components/MouseoverText/**
30 changes: 15 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Define a imagem base
FROM node:14-alpine
# Set the working directory to /app
WORKDIR /app
# Copy the package.json and yarn.lock files to the container
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install
# Copy the rest of the app files to the container
COPY . ./
# Build the app
RUN yarn build
# Expose port 3000
EXPOSE 3000
# Set the startup command to run the app using Node.js
# Define a imagem base
FROM node:14-alpine
# Set the working directory to /app
WORKDIR /app
# Copy the package.json and yarn.lock files to the container
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install
# Copy the rest of the app files to the container
COPY . ./
# Build the app
RUN yarn build
# Expose port 3000
EXPOSE 3000
# Set the startup command to run the app using Node.js
CMD ["yarn", "start:local"]
19 changes: 16 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"redux-persist": "^5.10.0",
"redux-thunk": "^2.3.0",
"tinymce": "^5.10.7",
"uuid": "^9.0.1",
"websocket-extensions": ">=0.1.4"
},
"scripts": {
Expand Down
80 changes: 80 additions & 0 deletions src/__tests__/Teams/TeamMembersPopup.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import configureStore from 'redux-mock-store';
import TeamMembersPopup from 'components/Teams/TeamMembersPopup';
import thunk from 'redux-thunk';
import { authMock, userProfileMock, rolesMock } from '../../__tests__/mockStates';
import { render, screen, fireEvent } from '@testing-library/react';
import { Provider } from 'react-redux';

const mockStore = configureStore([thunk]);

const mockProps = {
members: { teamMembers: [] },
usersdata: { userProfiles: [] },
};

const renderComponent = props => {
const store = mockStore({
auth: authMock,
userProfile: userProfileMock,
role: rolesMock.role,
...props,
});

render(
<Provider store={store}>
<TeamMembersPopup {...props} />
</Provider>,
);
};

const initialState = {
open: true,
selectedTeamName: 'Test Team',
hasPermission: jest.fn(),
members: {
teamMembers: { toSorted: jest.fn(() => []) },
},
roles: [{}],
auth: {
user: {
role: 'Owner',
permissions: {
frontPermissions: ['assignTeamToUsers'],
},
},
},
userProfile: { userProfiles: [] },
requestorRole: '',
userPermissions: [],
onClose: jest.fn(),
onDeleteClick: jest.fn(),
};

const usersdata = { userProfiles: [] };

describe('TeamMembersPopup', () => {
it('should render correctly', () => {
renderComponent(mockProps);
});

it('should render "Add" button', () => {
renderComponent({ ...initialState, usersdata });
expect(screen.getByRole('button', { name: 'Add' })).toBeInTheDocument();
});

it('should render "Close" button', () => {
renderComponent({ ...initialState, usersdata });
expect(screen.getByText('Close')).toBeInTheDocument();
});

it('should call closePopup function', () => {
renderComponent({ ...initialState, usersdata });
fireEvent.click(screen.getByText('Close'));
expect(initialState.onClose).toHaveBeenCalledTimes(1);
});

it('displays the team name in the modal header', () => {
renderComponent({ ...initialState, usersdata });
expect(screen.getByText(`Members of ${initialState.selectedTeamName}`)).toBeInTheDocument();
});
});
77 changes: 77 additions & 0 deletions src/actions/rolePermissionPresets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import axios from 'axios';
import { ENDPOINTS } from '../utils/URL';
import * as types from "../constants/rolePermissionPresets";

export const fetchPresets = (presets) => {
return {
type: types.RECEIVE_PRESETS,
presets,
};
};

export const postNewPreset = payload => {
return {
type: types.ADD_NEW_PRESET,
payload,
};
};

export const deletePreset = presetId => {
return {
type: types.DELETE_PRESET,
presetId,
};
};

export const updatePreset = payload => {
return {
type: types.UPDATE_PRESET,
payload,
};
};

export const getPresetsByRole = (roleName) => async dispatch => {
const URL = ENDPOINTS.PRESETS_BY_ID(roleName);
const { data } = await axios.get(URL);
return dispatch(fetchPresets(data));
};

export const createNewPreset = newPreset => {
return async dispatch => {
try {
const res = await axios.post(ENDPOINTS.PRESETS(), newPreset);
if (res.status === 201){
dispatch(postNewPreset(res.data.newPreset));
}
} catch (error) {
console.log(error)
}
return status;
};
};

export const updatePresetById = (updatedPreset) => {
return async dispatch => {
try {
const res = await axios.put(ENDPOINTS.PRESETS_BY_ID(updatedPreset._id), updatedPreset);
if (res.status === 200){
dispatch(updatePreset(updatedPreset));
}
} catch (err) {
console.log(err);
}
};
};

export const deletePresetById = (presetId) => {
return async dispatch => {
try {
const res = await axios.delete(ENDPOINTS.PRESETS_BY_ID(presetId));
if (res.status === 200){
dispatch(deletePreset(presetId));
}
} catch (error) {
console.log(error);
}
};
};
47 changes: 47 additions & 0 deletions src/components/BMDashboard/BMDashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.bm-dashboard__header h1{
font-size: 1.5em;
text-align: center;
margin-top: 2em;
}

.bm-dashboard__button.btn.btn-secondary{
background-color: #2e5061;
}

@media (min-width: 650px){

.bm-dashboard__button.btn.btn-secondary{
padding-left: 0;
padding-right: 0;
max-height: 38px;
}
}

/* project summaries */
.projects-list{
width: 80%;
list-style-type: none;
max-height: 80vh;
overflow-x: hidden;
overflow-y: auto;
}

.project-summary{
background-color: #e8f4f9;
min-height: 20vh;
height: auto;
margin-bottom: 2em;
padding: 1em;
border-radius: 5px;
}

.project-summary_header{
font-size: clamp(1em, 3vw, 1.3em);
font-weight: bold;
}

.project-summary p{
margin: 0;
font-size: clamp(0.9em, 2.5vw, 1em);
}

36 changes: 33 additions & 3 deletions src/components/BMDashboard/BMDashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
import { Container } from 'reactstrap';
import ProjectsList from './Projects/ProjectsList';
import ProjectSelectForm from './Projects/ProjectSelectForm';
import './BMDashboard.css';

const dummyProjects = [
{
projectId: 1,
projectName: 'Big project',
},
{
projectId: 2,
projectName: 'Bigger project',
},
{
projectId: 3,
projectName: 'Very important project',
},
{
projectId: 4,
projectName: 'Super important project',
},
];

export function BMDashboard() {
return (
<div style={{ textAlign: 'center', marginTop: '5rem' }}>
<h2>Building and Inventory Management Dashboard</h2>
</div>
<Container className="justify-content-center align-items-center mw-80 px-4">
<header className="bm-dashboard__header">
<h1>Building and Inventory Management Dashboard</h1>
</header>
<main>
<ProjectSelectForm projects={dummyProjects} />
<ProjectsList projects={dummyProjects} />
</main>
</Container>
);
}

Expand Down
Loading

0 comments on commit f4ea6f0

Please sign in to comment.