Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/3drepo/3drepo.io into IS…
Browse files Browse the repository at this point in the history
…SUE_4712
  • Loading branch information
Amantini1997 committed Jan 30, 2024
2 parents 450d34e + 105c71f commit c31d238
Show file tree
Hide file tree
Showing 32 changed files with 170 additions and 189 deletions.
2 changes: 1 addition & 1 deletion backend/VERSION.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ "VERSION" : "5.6.3",
{ "VERSION" : "5.7.1",
"unity" : {
"current" : "2.20.0",
"supported": []
Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3drepo.io",
"version": "5.6.3",
"version": "5.7.1",
"engines": {
"node": "18.x.x"
},
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v4/routes/apidoc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "5.6.3"
"version": "5.7.1"
}
2 changes: 1 addition & 1 deletion backend/src/v5/schemas/tickets/templates.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ TemplateConstants.defaultProperties = [
createPropertyEntry('Owner', propTypes.TEXT, undefined, undefined, true),
createPropertyEntry('Created at', propTypes.DATE, undefined, undefined, true),
createPropertyEntry('Updated at', propTypes.DATE, undefined, undefined, true),
createPropertyEntry('Status', propTypes.ONE_OF, ['Open', 'In Progress', 'For Approval', 'Closed', 'Void'], 'Open'),
createPropertyEntry('Default Image', propTypes.IMAGE, undefined, undefined, undefined, ({ defaultImage }) => defaultImage),
createPropertyEntry('Default View', propTypes.VIEW, undefined, undefined, undefined, ({ defaultView }) => defaultView),
createPropertyEntry('Priority', propTypes.ONE_OF, ['None', 'Low', 'Medium', 'High'], 'None', undefined, ({ issueProperties }) => issueProperties),
createPropertyEntry('Status', propTypes.ONE_OF, ['Open', 'In Progress', 'For Approval', 'Closed', 'Void'], 'Open', undefined, ({ issueProperties }) => issueProperties),
createPropertyEntry('Assignees', propTypes.MANY_OF, presetEnumValues.JOBS_AND_USERS, undefined, undefined, ({ issueProperties }) => issueProperties),
createPropertyEntry('Due Date', propTypes.DATE, undefined, undefined, undefined, ({ issueProperties }) => issueProperties),
createPropertyEntry('Pin', propTypes.COORDS, undefined, undefined, undefined, ({ pin }) => pin),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ const testUpdateTicket = () => {
expect(updatedTicket).toHaveProperty('number');
expect(updatedTicket.properties).toHaveProperty(basePropertyLabels.UPDATED_AT);
expect(updatedTicket.properties).toHaveProperty(basePropertyLabels.CREATED_AT);
expect(updatedTicket.properties).toHaveProperty(basePropertyLabels.STATUS);
expect(updatedTicket.properties).toHaveProperty(basePropertyLabels.OWNER);
expect(updatedTicket.properties[basePropertyLabels.UPDATED_AT])
.not.toEqual(ticket.properties[basePropertyLabels.UPDATED_AT]);
Expand All @@ -729,6 +730,7 @@ const testUpdateTicket = () => {
...ticket.properties,
[basePropertyLabels.UPDATED_AT]: updatedTicket.properties[basePropertyLabels.UPDATED_AT],
[basePropertyLabels.CREATED_AT]: updatedTicket.properties[basePropertyLabels.CREATED_AT],
[basePropertyLabels.STATUS]: updatedTicket.properties[basePropertyLabels.STATUS],
[basePropertyLabels.OWNER]: updatedTicket.properties[basePropertyLabels.OWNER],
...(payloadChanges?.properties ?? {}),
[imagePropName]: updatedTicket.properties[imagePropName],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const ticketAddedTest = () => {
new Date(getRes.body.properties[basePropertyLabels.UPDATED_AT]).getTime(),
[basePropertyLabels.CREATED_AT]:
new Date(getRes.body.properties[basePropertyLabels.CREATED_AT]).getTime(),
[basePropertyLabels.STATUS]: getRes.body.properties[basePropertyLabels.STATUS],
},
number: 1,
},
Expand Down Expand Up @@ -138,6 +139,7 @@ const ticketAddedTest = () => {
new Date(getRes.body.properties[basePropertyLabels.UPDATED_AT]).getTime(),
[basePropertyLabels.CREATED_AT]:
new Date(getRes.body.properties[basePropertyLabels.CREATED_AT]).getTime(),
[basePropertyLabels.STATUS]: getRes.body.properties[basePropertyLabels.STATUS],
},
number: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const testGetApplicableDefaultProperties = () => {
const basicProp = [{ name: 'Description', type: TemplateConstants.propTypes.LONG_TEXT },
{ name: 'Owner', type: TemplateConstants.propTypes.TEXT, readOnly: true },
{ name: 'Created at', type: TemplateConstants.propTypes.DATE, readOnly: true },
{ name: 'Updated at', type: TemplateConstants.propTypes.DATE, readOnly: true }];
{ name: 'Updated at', type: TemplateConstants.propTypes.DATE, readOnly: true },
{ name: 'Status', type: TemplateConstants.propTypes.ONE_OF, values: ['Open', 'In Progress', 'For Approval', 'Closed', 'Void'], default: 'Open' }];

const issueProp = [{ name: 'Priority', type: TemplateConstants.propTypes.ONE_OF, values: ['None', 'Low', 'Medium', 'High'], default: 'None' },
{ name: 'Status', type: TemplateConstants.propTypes.ONE_OF, values: ['Open', 'In Progress', 'For Approval', 'Closed', 'Void'], default: 'Open' },
{ name: 'Assignees', type: TemplateConstants.propTypes.MANY_OF, values: TemplateConstants.presetEnumValues.JOBS_AND_USERS },
{ name: 'Due Date', type: TemplateConstants.propTypes.DATE }];
test('Should only return the basic properties if none of the optional flags are configured', () => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { theme as V5Theme } from '@/v5/ui/themes/theme';
import { theme as V5ViewerTheme } from '@/v5/ui/routes/viewer/theme';
import { IntlProvider } from 'react-intl';
import { getIntlProviderProps } from '@/v5/services/intl';
import { getIntl } from '@/v5/services/intl';
import { GlobalStyle } from '@/v5/ui/themes/global';
import { ThemeProvider as MuiThemeProvider } from '@mui/material';
import { ThemeProvider, createGlobalStyle } from 'styled-components';
Expand Down Expand Up @@ -73,7 +73,7 @@ const withThemeProvider = (Story, context)=>{
export const decorators = [
withThemeProvider,
(Story) => (
<IntlProvider {...getIntlProviderProps()}>
<IntlProvider {...getIntl()}>
<Story />
</IntlProvider>
),
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3drepo.io-frontend",
"version": "5.6.3",
"version": "5.7.1",
"description": "The frontend for 3drepo.io",
"engines": {
"node": "18.x.x"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { Root as V5Root } from '@/v5/ui/routes';

import { UnityUtil } from '@/globals/unity-util';
import { clientConfigService } from '@/v4/services/clientConfig';
import { formatMessage, getIntlProviderProps, initializeIntl } from '@/v5/services/intl';
import { formatMessage, getIntl, initializeIntl } from '@/v5/services/intl';
import { initializeActionsDispatchers } from '@/v5/helpers/actionsDistpatchers.helper';
import { IntlProvider } from 'react-intl';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
Expand Down Expand Up @@ -68,7 +68,7 @@ const render = () => {
ReactDOM.render(
<Provider store={store as any}>
<ConnectedRouter history={history as History}>
<IntlProvider {...getIntlProviderProps()}>
<IntlProvider {...getIntl()}>
<LocalizationProvider dateAdapter={AdapterDayjs}>
<Switch>
<Route exact path="/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ComponentType, useEffect } from 'react';
import { DatePickerProps } from '@mui/lab/DatePicker';
import { DateTimePickerProps } from '@mui/lab/DateTimePicker';
import { TextField } from '@mui/material';
import { useState } from 'react';
import { StyledDatePicker, StyledDateTimePicker } from './dateField.styles';
import { useEffect, useState } from 'react';
import { DateTimePicker } from '@controls/inputs/datePicker/dateTimePicker.component';
import { DatePicker } from '@controls/inputs/datePicker/datePicker.component';

interface IProps {
value?: any;
Expand All @@ -44,11 +42,10 @@ export const DateField = ({
placeholder,
dateTime,
defaultValue,
className,
...dateFieldProps
}: IProps) => {
const [value, setValue] = useState(propValue || null);
const Picker: ComponentType<DatePickerProps | DateTimePickerProps> = dateTime ? StyledDateTimePicker : StyledDatePicker;
const Picker = dateTime ? DateTimePicker : DatePicker;

const handleAccept = (newValue) => {
if (newValue) {
Expand All @@ -72,14 +69,15 @@ export const DateField = ({
onAccept={handleAccept}
onChange={() => {}}
disableHighlightToday
// @ts-ignore
inputProps={{ readOnly: true, placeholder }}
components={{ ActionBar: null }}
renderInput={(props) => (
<TextField
placeholder={placeholder}
defaultValue={defaultValue}
name={name}
onBlur={onBlur}
className={className}
{...props}
InputProps={{ endAdornment: null }}
/>
)}
{...dateFieldProps}
Expand Down
32 changes: 0 additions & 32 deletions frontend/src/v4/routes/components/dateField/dateField.styles.ts

This file was deleted.

3 changes: 2 additions & 1 deletion frontend/src/v4/routes/viewerGui/viewerGui.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Tickets } from '@/v5/ui/routes/viewer/tickets/tickets.component';
import { isEmpty } from 'lodash';
import { isEmpty, isEqual } from 'lodash';
import { PureComponent } from 'react';
import { Toolbar } from '@/v5/ui/routes/viewer/toolbar/toolbar.component';
import { VIEWER_EVENTS } from '../../constants/viewer';
Expand Down Expand Up @@ -181,6 +181,7 @@ export class ViewerGui extends PureComponent<IProps, IState> {
this.props.setPanelVisibility(VIEWER_PANELS.COMPARE, false);
this.props.resetCompareComponent();
}

}

public componentWillUnmount() {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/v4/routes/viewerGui/viewerGui.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { TeamspacesActions } from '@/v4/modules/teamspaces';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { createStructuredSelector } from 'reselect';
import { selectSelectedTicket } from '@/v5/store/tickets/card/ticketsCard.selectors';
import { CompareActions } from '../../modules/compare';

import { selectCurrentTeamspace, selectCurrentUser } from '../../modules/currentUser';
Expand Down
79 changes: 39 additions & 40 deletions frontend/src/v5/helpers/viewpoint.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ import { generateViewpoint as generateViewpointV4, getNodesIdsFromSharedIds, toS
import { formatMessage } from '@/v5/services/intl';
import { dispatch, getState } from '@/v4/modules/store';
import { isEmpty, isString } from 'lodash';
import { Viewer as ViewerService } from '@/v4/services/viewer/viewer';
import { TreeActions } from '@/v4/modules/tree';
import { ViewerGuiActions } from '@/v4/modules/viewerGui';
import { selectCurrentTeamspace } from '../store/teamspaces/teamspaces.selectors';
import { TicketsCardActionsDispatchers } from '../services/actionsDispatchers';
import { ViewpointsActions } from '@/v4/modules/viewpoints';

export const convertToV5GroupNodes = (objects) => objects.map((object) => ({
container: object.model as string,
Expand Down Expand Up @@ -73,6 +70,12 @@ const convertToV5GroupOverride = (group: any, type: ViewpointGroupOverrideType):
override.opacity = opacity;
}

if (group.transformation) {
const { transformation } = group;
override.transformation = transformation;
}


return override;
};

Expand Down Expand Up @@ -103,10 +106,8 @@ export const getViewerState = async () => {
return state;
};

const mergeGroups = (groups: any[]) => ({ objects: groups.flatMap((group) => group.objects) });

const convertToV4Group = (groupOverride: GroupOverride) => {
const { color, opacity, group: v5Group } = groupOverride;
const { color, opacity, transformation, group: v5Group } = groupOverride;

if (isString(v5Group)) {
return { color: [0, 0, 0, 0], objects: [] }; // theres no info yet so I say us an empty group
Expand All @@ -124,9 +125,15 @@ const convertToV4Group = (groupOverride: GroupOverride) => {
group.opacity = opacity;
}

if (transformation) {
group.transformation = transformation;
}

return group;
};

const mergeGroups = (groups: any[]) => ({ objects: groups.flatMap((group) => group.objects) });

export const viewpointV5ToV4 = (viewpoint: Viewpoint) => {
let v4Viewpoint:any = {};
if (viewpoint.camera) {
Expand All @@ -143,14 +150,15 @@ export const viewpointV5ToV4 = (viewpoint: Viewpoint) => {
v4Viewpoint.clippingPlanes = viewpoint.clippingPlanes;
}

if (!isEmpty(viewpoint.state?.colored)) {
v4Viewpoint.override_groups = viewpoint.state.colored.map(convertToV4Group);
}

if (!isEmpty(viewpoint.state?.transformed)) {
v4Viewpoint.transformation_groups = viewpoint.state.transformed.map(convertToV4Group);
}


if (!isEmpty(viewpoint.state?.colored)) {
v4Viewpoint.override_groups = viewpoint.state.colored.map(convertToV4Group);
}

if (!isEmpty(viewpoint.state?.hidden)) {
v4Viewpoint.hidden_group = mergeGroups(viewpoint.state.hidden.map(convertToV4Group));
}
Expand All @@ -163,19 +171,21 @@ export const meshObjectsToV5GroupNode = (objects) => objects.map((obj) => ({
_ids: obj.mesh_ids,
}));

export const toColorAndTransparencyDicts = (overrides: GroupOverride[]): OverridesDicts => {
const toMeshDictionary = (objects: V4GroupObjects, color: string, opacity: number): OverridesDicts => objects.shared_ids.reduce((dict, id) => {
if (color !== undefined) {
export const toGroupPropertiesDicts = (overrides: GroupOverride[]): OverridesDicts => {
const toMeshDictionary = (objects: V4GroupObjects, color: string, opacity: number): OverridesDicts =>
objects.shared_ids.reduce((dict, id) => {
if (color !== undefined) {
// eslint-disable-next-line no-param-reassign
dict.overrides[id] = color;
}
dict.overrides[id] = color;
}

if (opacity !== undefined) {
if (opacity !== undefined) {
// eslint-disable-next-line no-param-reassign
dict.transparencies[id] = opacity;
}
return dict;
}, { overrides: {}, transparencies: {} } as OverridesDicts);
dict.transparencies[id] = opacity;
}

return dict;
}, { overrides: {}, transparencies: {} } as OverridesDicts);

return overrides.reduce((acum, current) => {
const color = current.color ? getGroupHexColor(current.color) : undefined;
Expand All @@ -189,32 +199,21 @@ export const toColorAndTransparencyDicts = (overrides: GroupOverride[]): Overrid
dict.overrides = { ...dict.overrides, ...overrideDict.overrides };
// eslint-disable-next-line no-param-reassign
dict.transparencies = { ...dict.transparencies, ...overrideDict.transparencies };

return dict;
}, acum);
}, { overrides: {}, transparencies: {} } as OverridesDicts);
};

export const goToView = async (view: Viewpoint) => {
if (isEmpty(view?.state?.colored) && isEmpty(view?.state?.hidden) && isEmpty(view?.camera) && isEmpty(view?.clippingPlanes)) {
if (
isEmpty(view?.state?.colored) &&
isEmpty(view?.state?.hidden) &&
isEmpty(view?.state?.transformed) &&
isEmpty(view?.camera) &&
isEmpty(view?.clippingPlanes)) {
return;
}


dispatch(ViewerGuiActions.clearColorOverrides());
await ViewerService.setViewpoint(view);
const overrides = toColorAndTransparencyDicts(view?.state?.colored || []);
TicketsCardActionsDispatchers.setOverrides(overrides);

await ViewerService.clearHighlights();

if (view?.state) {
dispatch(TreeActions.setHiddenGeometryVisible(!!view.state.showHidden));
}

const v4HiddenObjects = convertToV4GroupNodes(view.state?.hidden?.flatMap((hiddenOverride) => (hiddenOverride.group as Group)?.objects || []));
if (v4HiddenObjects.length) {
dispatch(TreeActions.hideNodesBySharedIds(v4HiddenObjects, true));
} else {
dispatch(TreeActions.showAllNodes());
}
dispatch(ViewpointsActions.showViewpoint(null, null, viewpointV5ToV4(view)));
};
Loading

0 comments on commit c31d238

Please sign in to comment.