Skip to content

Commit b8079fe

Browse files
authored
🐛 Close the status expandable if last app is removed from wave status (#1639)
https://issues.redhat.com/browse/MTA-1844 Signed-off-by: ibolton336 <[email protected]>
1 parent da92005 commit b8079fe

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

client/src/app/pages/migration-waves/components/wave-status-table.tsx

+35-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { MigrationWave, Ticket, WaveWithStatus } from "@app/api/models";
33
import { useTranslation } from "react-i18next";
44
import {
55
Button,
6-
ButtonVariant,
76
CodeBlock,
87
CodeBlockCode,
98
Modal,
@@ -22,22 +21,34 @@ import {
2221
TableRowContentWithControls,
2322
} from "@app/components/TableControls";
2423
import { SimplePagination } from "@app/components/SimplePagination";
25-
import { NoDataEmptyState } from "@app/components/NoDataEmptyState";
2624
import { useHistory } from "react-router-dom";
2725
import { useFetchTickets } from "@app/queries/tickets";
28-
import { Paths } from "@app/Paths";
2926
import { TicketIssue } from "./ticket-issue";
3027
import { useDeleteTicketMutation } from "@app/queries/migration-waves";
3128
import UnlinkIcon from "@patternfly/react-icons/dist/esm/icons/unlink-icon";
3229

30+
type SetCellExpandedArgs = {
31+
item: WaveWithStatus;
32+
isExpanding?: boolean;
33+
columnKey?:
34+
| "stakeholders"
35+
| "applications"
36+
| "name"
37+
| "startDate"
38+
| "endDate"
39+
| "status";
40+
};
41+
3342
export interface IWaveStatusTableProps {
3443
migrationWave: WaveWithStatus;
3544
removeApplication: (migrationWave: MigrationWave, id: number) => void;
45+
setCellExpanded: (args: SetCellExpandedArgs) => void;
3646
}
3747

3848
export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
3949
migrationWave,
4050
removeApplication,
51+
setCellExpanded,
4152
}) => {
4253
const { t } = useTranslation();
4354
const [codeModalState, setCodeModalState] = useState<
@@ -113,24 +124,6 @@ export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
113124
<ConditionalTableBody
114125
isNoData={migrationWave.applications.length === 0}
115126
numRenderedColumns={numRenderedColumns}
116-
noDataEmptyState={
117-
<div>
118-
<NoDataEmptyState title="Create a tracker and/or add applications to the migration wave." />
119-
<div className="pf-v5-u-text-align-center">
120-
<Button
121-
type="button"
122-
id="create-tracker"
123-
aria-label="Create Tracker"
124-
variant={ButtonVariant.primary}
125-
onClick={() => {
126-
history.push(Paths.jira);
127-
}}
128-
>
129-
Create Tracker
130-
</Button>
131-
</div>
132-
</div>
133-
}
134127
>
135128
<Tbody>
136129
{currentPageItems?.map((app, rowIndex) => {
@@ -181,7 +174,27 @@ export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
181174
<Button
182175
type="button"
183176
variant="plain"
184-
onClick={() => removeApplication(migrationWave, app.id)}
177+
onClick={() => {
178+
const updatedApplications =
179+
migrationWave.applications.filter(
180+
(application) => application.id !== app.id
181+
);
182+
183+
const updatedMigrationWave = {
184+
...migrationWave,
185+
applications: updatedApplications,
186+
};
187+
if (updatedApplications.length === 0) {
188+
removeApplication(migrationWave, app.id);
189+
setCellExpanded({
190+
item: updatedMigrationWave,
191+
isExpanding: false,
192+
columnKey: "status",
193+
});
194+
} else {
195+
removeApplication(migrationWave, app.id);
196+
}
197+
}}
185198
>
186199
<TrashIcon />
187200
</Button>

client/src/app/pages/migration-waves/migration-waves.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export const MigrationWaves: React.FC = () => {
234234
getTdProps,
235235
getExpandedContentTdProps,
236236
},
237-
expansionDerivedState: { isCellExpanded },
237+
expansionDerivedState: { isCellExpanded, setCellExpanded },
238238
} = tableControls;
239239

240240
// TODO: Check RBAC access
@@ -437,7 +437,7 @@ export const MigrationWaves: React.FC = () => {
437437
>
438438
{migrationWave.applications.length
439439
? migrationWave.status
440-
: "N/A"}
440+
: "--"}
441441
</Td>
442442
<Td isActionCell id="row-actions">
443443
<Dropdown
@@ -554,6 +554,7 @@ export const MigrationWaves: React.FC = () => {
554554
<WaveStatusTable
555555
migrationWave={migrationWave}
556556
removeApplication={removeApplication}
557+
setCellExpanded={setCellExpanded}
557558
/>
558559
)
559560
)}

0 commit comments

Comments
 (0)