@@ -3,7 +3,6 @@ import { MigrationWave, Ticket, WaveWithStatus } from "@app/api/models";
3
3
import { useTranslation } from "react-i18next" ;
4
4
import {
5
5
Button ,
6
- ButtonVariant ,
7
6
CodeBlock ,
8
7
CodeBlockCode ,
9
8
Modal ,
@@ -22,22 +21,34 @@ import {
22
21
TableRowContentWithControls ,
23
22
} from "@app/components/TableControls" ;
24
23
import { SimplePagination } from "@app/components/SimplePagination" ;
25
- import { NoDataEmptyState } from "@app/components/NoDataEmptyState" ;
26
24
import { useHistory } from "react-router-dom" ;
27
25
import { useFetchTickets } from "@app/queries/tickets" ;
28
- import { Paths } from "@app/Paths" ;
29
26
import { TicketIssue } from "./ticket-issue" ;
30
27
import { useDeleteTicketMutation } from "@app/queries/migration-waves" ;
31
28
import UnlinkIcon from "@patternfly/react-icons/dist/esm/icons/unlink-icon" ;
32
29
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
+
33
42
export interface IWaveStatusTableProps {
34
43
migrationWave : WaveWithStatus ;
35
44
removeApplication : ( migrationWave : MigrationWave , id : number ) => void ;
45
+ setCellExpanded : ( args : SetCellExpandedArgs ) => void ;
36
46
}
37
47
38
48
export const WaveStatusTable : React . FC < IWaveStatusTableProps > = ( {
39
49
migrationWave,
40
50
removeApplication,
51
+ setCellExpanded,
41
52
} ) => {
42
53
const { t } = useTranslation ( ) ;
43
54
const [ codeModalState , setCodeModalState ] = useState <
@@ -113,24 +124,6 @@ export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
113
124
< ConditionalTableBody
114
125
isNoData = { migrationWave . applications . length === 0 }
115
126
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
- }
134
127
>
135
128
< Tbody >
136
129
{ currentPageItems ?. map ( ( app , rowIndex ) => {
@@ -181,7 +174,27 @@ export const WaveStatusTable: React.FC<IWaveStatusTableProps> = ({
181
174
< Button
182
175
type = "button"
183
176
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
+ } }
185
198
>
186
199
< TrashIcon />
187
200
</ Button >
0 commit comments