Skip to content

Commit cff7df7

Browse files
author
sanmont3drepo
committed
ISSUE #4642 - Now if the de selected view in ticket doesn change it doesnt refresh the view, missing translation is no longer littering the console
1 parent ad0dcd5 commit cff7df7

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

frontend/src/main.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { Root as V5Root } from '@/v5/ui/routes';
3030

3131
import { UnityUtil } from '@/globals/unity-util';
3232
import { clientConfigService } from '@/v4/services/clientConfig';
33-
import { formatMessage, getIntlProviderProps, initializeIntl } from '@/v5/services/intl';
33+
import { formatMessage, getIntl, initializeIntl } from '@/v5/services/intl';
3434
import { initializeActionsDispatchers } from '@/v5/helpers/actionsDistpatchers.helper';
3535
import { IntlProvider } from 'react-intl';
3636
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
@@ -68,7 +68,7 @@ const render = () => {
6868
ReactDOM.render(
6969
<Provider store={store as any}>
7070
<ConnectedRouter history={history as History}>
71-
<IntlProvider {...getIntlProviderProps()}>
71+
<IntlProvider {...getIntl()}>
7272
<LocalizationProvider dateAdapter={AdapterDayjs}>
7373
<Switch>
7474
<Route exact path="/">

frontend/src/v4/routes/viewerGui/viewerGui.component.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
*/
1717

1818
import { Tickets } from '@/v5/ui/routes/viewer/tickets/tickets.component';
19-
import { isEmpty } from 'lodash';
19+
import { isEmpty, isEqual } from 'lodash';
2020
import { PureComponent } from 'react';
2121
import { Toolbar } from '@/v5/ui/routes/viewer/toolbar/toolbar.component';
22+
import { ITicket } from '@/v5/store/tickets/tickets.types';
23+
import { goToView } from '@/v5/helpers/viewpoint.helpers';
24+
import { AdditionalProperties } from '@/v5/ui/routes/viewer/tickets/tickets.constants';
2225
import { VIEWER_EVENTS } from '../../constants/viewer';
2326
import { getViewerLeftPanels, VIEWER_PANELS } from '../../constants/viewerGui';
2427
import { getWindowHeight, getWindowWidth, renderWhenTrue } from '../../helpers/rendering';
@@ -67,6 +70,7 @@ interface IProps {
6770
rightPanels: string[];
6871
draggablePanels: string[];
6972
disabledPanelButtons: Set<string>;
73+
selectedTicket: ITicket | null | undefined;
7074
stopListenOnSelections: () => void;
7175
stopListenOnModelLoaded: () => void;
7276
stopListenOnClickPin: () => void;
@@ -181,6 +185,14 @@ export class ViewerGui extends PureComponent<IProps, IState> {
181185
this.props.setPanelVisibility(VIEWER_PANELS.COMPARE, false);
182186
this.props.resetCompareComponent();
183187
}
188+
189+
const prevView = prevProps.selectedTicket?.properties?.[AdditionalProperties.DEFAULT_VIEW];
190+
const currView = this.props.selectedTicket?.properties?.[AdditionalProperties.DEFAULT_VIEW];
191+
192+
if (!isEqual(prevView, currView)) {
193+
// This is for not refreshing the view when exiting a selected ticket
194+
goToView(currView);
195+
}
184196
}
185197

186198
public componentWillUnmount() {

frontend/src/v4/routes/viewerGui/viewerGui.container.ts

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { TeamspacesActions } from '@/v4/modules/teamspaces';
1919
import { connect } from 'react-redux';
2020
import { bindActionCreators } from 'redux';
2121
import { createStructuredSelector } from 'reselect';
22+
import { selectSelectedTicket } from '@/v5/store/tickets/card/ticketsCard.selectors';
2223
import { CompareActions } from '../../modules/compare';
2324

2425
import { selectCurrentTeamspace, selectCurrentUser } from '../../modules/currentUser';
@@ -49,6 +50,7 @@ const mapStateToProps = createStructuredSelector({
4950
isFocusMode: selectIsFocusMode,
5051
disabledPanelButtons: selectDisabledPanelButtons,
5152
isPresentationActive: selectIsPresentationActive,
53+
selectedTicket: selectSelectedTicket,
5254
});
5355

5456
export const mapDispatchToProps = (dispatch) => bindActionCreators({

frontend/src/v5/services/intl.ts

+8-14
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,19 @@ export const initializeIntl = (locale: string) => {
4343
// Locale of the fallback defaultMessage
4444
defaultLocale: DEFAULT_LOCALE,
4545
messages,
46+
onError: (error) => {
47+
if (error.code === 'MISSING_TRANSLATION') {
48+
return;
49+
}
50+
51+
console.error(error);
52+
},
4653
},
4754
cache,
4855
);
4956
};
5057

51-
const getIntl = () => {
58+
export const getIntl = () => {
5259
if (!intlInternal) {
5360
initializeIntl(DEFAULT_LOCALE);
5461
}
@@ -70,16 +77,3 @@ export const formatRelativeTime: typeof intlInternal.formatRelativeTime = (value
7077

7178
// eslint-disable-next-line max-len
7279
export const formatPlural: typeof intlInternal.formatPlural = (value, opts?): Intl.LDMLPluralRule => getIntl().formatPlural(value, opts);
73-
74-
export const getIntlProviderProps = () => ({
75-
messages: getIntl().messages,
76-
defaultLocal: getIntl().defaultLocale,
77-
locale: getIntl().locale,
78-
onError: (error) => {
79-
if (error.code === 'MISSING_TRANSLATION' && getIntl().locale === DEFAULT_LOCALE) {
80-
return;
81-
}
82-
83-
console.error(error);
84-
},
85-
});

frontend/src/v5/ui/routes/viewer/tickets/ticketsList/ticketsList.component.tsx

-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { uniq, xor } from 'lodash';
2121
import { TicketsHooksSelectors, TicketsCardHooksSelectors } from '@/v5/services/selectorsHooks';
2222
import { TicketsActionsDispatchers, TicketsCardActionsDispatchers } from '@/v5/services/actionsDispatchers';
2323
import { FilterChip } from '@controls/chip/filterChip/filterChip.styles';
24-
import { goToView } from '@/v5/helpers/viewpoint.helpers';
2524
import { VIEWER_EVENTS } from '@/v4/constants/viewer';
2625
import { formatMessage } from '@/v5/services/intl';
2726
import { EmptyListMessage } from '@controls/dashedContainer/emptyListMessage/emptyListMessage.styles';
@@ -31,7 +30,6 @@ import { Viewer as ViewerService } from '@/v4/services/viewer/viewer';
3130
import { TicketItem } from './ticketItem/ticketItem.component';
3231
import { List, Filters, CompletedFilterChip } from './ticketsList.styles';
3332
import { ViewerParams } from '../../../routes.constants';
34-
import { AdditionalProperties } from '../tickets.constants';
3533
import { hasDefaultPin } from '../ticketsForm/properties/coordsProperty/coordsProperty.helpers';
3634
import { TicketSearchInput } from './ticketSearchInput/ticketSearchInput.component';
3735

@@ -69,11 +67,6 @@ export const TicketsList = ({ tickets }: TicketsListProps) => {
6967
TicketsActionsDispatchers.fetchTicketGroups(teamspace, project, containerOrFederation, ticket._id);
7068
};
7169

72-
useEffect(() => {
73-
const view = selectedTicket?.properties?.[AdditionalProperties.DEFAULT_VIEW];
74-
goToView(view);
75-
}, [selectedTicket?.properties?.[AdditionalProperties.DEFAULT_VIEW]]);
76-
7770
useEffect(() => {
7871
TicketsCardActionsDispatchers.setSelectedTicketPin(selectedTicket?._id);
7972

0 commit comments

Comments
 (0)