Skip to content

Commit

Permalink
ISSUE #5392 - Fixed white screen when loading tickets from deprecated…
Browse files Browse the repository at this point in the history
… templates
  • Loading branch information
sanmont3drepo committed Mar 3, 2025
1 parent a19f9c0 commit 1f0768b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 16 deletions.
13 changes: 12 additions & 1 deletion frontend/src/v5/services/api/tickets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,19 @@ export const fetchContainerTemplates = async (
projectId: string,
containerId: string,
getDetails?: boolean,
showDeprecated?: boolean,
): Promise<FetchTemplatesResponse> => {
const { data } = await api.get(`teamspaces/${teamspace}/projects/${projectId}/containers/${containerId}/tickets/templates?getDetails=${getDetails}`);
const urlSearchParams = new URLSearchParams();

if (getDetails) {
urlSearchParams.set('getDetails', getDetails.toString());
}

if (showDeprecated) {
urlSearchParams.set('showDeprecated', showDeprecated.toString());
}

const { data } = await api.get(`teamspaces/${teamspace}/projects/${projectId}/containers/${containerId}/tickets/templates?${urlSearchParams}`);
return data.templates;
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/v5/store/projects/projects.sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function* fetchTemplates({ teamspace, projectId, getDetails = false }) {
const modelId = models[0]._id;
const isFed = !!(yield select(selectFederationById, modelId));
const fetchModelTemplates = isFed ? API.Tickets.fetchFederationTemplates : API.Tickets.fetchContainerTemplates;
const templates = yield fetchModelTemplates(teamspace, projectId, modelId, getDetails);
const templates = yield fetchModelTemplates(teamspace, projectId, modelId, getDetails, true);
yield put(ProjectsActions.fetchTemplatesSuccess(projectId, templates));
} catch (error) {
yield put(DialogsActions.open('alert', {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/v5/store/tickets/tickets.sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function* fetchTemplates({ teamspace, projectId, modelId, isFederation, g
const fetchModelTemplates = isFederation
? API.Tickets.fetchFederationTemplates
: API.Tickets.fetchContainerTemplates;
const templates = yield fetchModelTemplates(teamspace, projectId, modelId, getDetails);
const templates = yield fetchModelTemplates(teamspace, projectId, modelId, getDetails, true);

yield put(TicketsActions.fetchTemplatesSuccess(modelId, templates));
} catch (error) {
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/v5/store/tickets/tickets.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const selectTemplates = createSelector(
(state, modelId) => state.templatesByModelId[modelId] || [],
);

export const selectActiveTemplates = createSelector(
selectTemplates,
(templates) => templates.filter(({ deprecated }) => !deprecated),
);

export const selectTemplateById = createSelector(
selectTicketsDomain,
selectTemplates,
Expand Down
1 change: 1 addition & 0 deletions frontend/src/v5/store/tickets/tickets.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export interface ITemplate {
code: string;
properties?: PropertyDefinition[];
modules?: TemplateModule[];
deprecated?: boolean;
config?: {
comments?: boolean;
defaultView?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,20 @@ export const TicketsTable = () => {
<SearchInput
placeholder={formatMessage({ id: 'ticketsTable.search.placeholder', defaultMessage: 'Search...' })}
/>
<NewTicketMenu
TriggerButton={(
<NewTicketButton
startIcon={<AddCircleIcon />}
disabled={newTicketButtonIsDisabled}
>
<FormattedMessage id="ticketsTable.button.newTicket" defaultMessage="New Ticket" />
</NewTicketButton>
)}
disabled={newTicketButtonIsDisabled}
onContainerOrFederationClick={setTicketValue}
/>
{!selectedTemplate.deprecated
&&
<NewTicketMenu
TriggerButton={(
<NewTicketButton
startIcon={<AddCircleIcon />}
disabled={newTicketButtonIsDisabled}
>
<FormattedMessage id="ticketsTable.button.newTicket" defaultMessage="New Ticket" />
</NewTicketButton>
)}
disabled={newTicketButtonIsDisabled}
onContainerOrFederationClick={setTicketValue}
/>}
</FlexContainer>
</FiltersContainer>
<TicketsTableContent setTicketValue={setTicketValue} selectedTicketId={ticketId} groupBy={groupBy}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import { useSelectedModels } from '../../newTicketMenu/useSelectedModels';
import { SetTicketValue } from '../../ticketsTable.helper';
import { ResizableTableCell } from '@controls/resizableTableContext/resizableTableCell/resizableTableCell.component';
import { ResizableTableContext } from '@controls/resizableTableContext/resizableTableContext';
import { ProjectsHooksSelectors } from '@/v5/services/selectorsHooks';
import { DashboardTicketsParams } from '@/v5/ui/routes/routes.constants';
import { useParams } from 'react-router';

const SortingTableHeader = ({ name, children, disableSorting = false, ...props }) => {
const { isDescendingOrder, onColumnClick, sortingColumn } = useContext(SortedTableContext);
Expand Down Expand Up @@ -67,6 +70,8 @@ type TicketsTableGroupProps = {
onNewTicket: (modelId: string) => void;
};
export const TicketsTableGroup = ({ tickets, onEditTicket, onNewTicket, selectedTicketId }: TicketsTableGroupProps) => {
const { template: templateId } = useParams<DashboardTicketsParams>();
const template = ProjectsHooksSelectors.selectCurrentProjectTemplateById(templateId);
const { getRowWidth } = useContext(ResizableTableContext);
const models = useSelectedModels();
const newTicketButtonIsDisabled = !models.filter(({ role }) => isCommenterRole(role)).length;
Expand Down Expand Up @@ -126,6 +131,7 @@ export const TicketsTableGroup = ({ tickets, onEditTicket, onNewTicket, selected
selected={selectedTicketId === ticket._id}
/>
))}
{!template.deprecated &&
<NewTicketMenu
disabled={newTicketButtonIsDisabled}
TriggerButton={(
Expand All @@ -142,6 +148,7 @@ export const TicketsTableGroup = ({ tickets, onEditTicket, onNewTicket, selected
useMousePosition
onContainerOrFederationClick={onNewTicket}
/>
}
</Group>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { ViewerParams } from '../../../../routes.constants';

export const NewTicketMenu = () => {
const { containerOrFederation } = useParams<ViewerParams>();
const templates = TicketsHooksSelectors.selectTemplates(containerOrFederation);
const templates = TicketsHooksSelectors.selectActiveTemplates(containerOrFederation);

const goToNewTicket = ({ _id }) => {
TicketsCardActionsDispatchers.setSelectedTemplate(_id);
Expand Down

0 comments on commit 1f0768b

Please sign in to comment.