File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
resources/scripts/components/server/network Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
66## v1.1.1
77### Fixed
88* Fixes allocation permissions checking on the frontend checking the wrong permission therefore leading to the item never showing up.
9+ * Fixes allocations not updating correctly when added or deleted and switching between pages.
910
1011## v1.1.0
1112This release ** requires** ` Wings@1.1.0 ` in order to work properly due to breaking internal API changes.
Original file line number Diff line number Diff line change @@ -13,15 +13,20 @@ interface Props {
1313}
1414
1515const DeleteAllocationButton = ( { allocation } : Props ) => {
16- const uuid = ServerContext . useStoreState ( state => state . server . data ! . uuid ) ;
1716 const [ confirm , setConfirm ] = useState ( false ) ;
17+
18+ const uuid = ServerContext . useStoreState ( state => state . server . data ! . uuid ) ;
19+ const setServerFromState = ServerContext . useStoreActions ( actions => actions . server . setServerFromState ) ;
20+
1821 const { mutate } = getServerAllocations ( ) ;
1922 const { clearFlashes, clearAndAddHttpError } = useFlash ( ) ;
2023
2124 const deleteAllocation = ( ) => {
2225 clearFlashes ( 'server:network' ) ;
2326
2427 mutate ( data => data ?. filter ( a => a . id !== allocation ) , false ) ;
28+ setServerFromState ( s => ( { ...s , allocations : s . allocations . filter ( a => a . id !== allocation ) } ) ) ;
29+
2530 deleteServerAllocation ( uuid , allocation )
2631 . catch ( error => clearAndAddHttpError ( { key : 'server:network' , error } ) ) ;
2732 } ;
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const NetworkContainer = () => {
1919 const allocationLimit = ServerContext . useStoreState ( state => state . server . data ! . featureLimits . allocations ) ;
2020 // @ts -ignore
2121 const allocations : Allocation [ ] = ServerContext . useStoreState ( state => state . server . data ! . allocations , isEqual ) ;
22+ const setServerFromState = ServerContext . useStoreActions ( actions => actions . server . setServerFromState ) ;
2223
2324 const { clearFlashes, clearAndAddHttpError } = useFlash ( ) ;
2425 const { data, error, mutate } = getServerAllocations ( ) ;
@@ -38,7 +39,10 @@ const NetworkContainer = () => {
3839
3940 setLoading ( true ) ;
4041 createServerAllocation ( uuid )
41- . then ( allocation => mutate ( data ?. concat ( allocation ) , false ) )
42+ . then ( allocation => {
43+ setServerFromState ( s => ( { ...s , allocations : s . allocations . concat ( allocation ) } ) ) ;
44+ return mutate ( data ?. concat ( allocation ) , false ) ;
45+ } )
4246 . catch ( error => clearAndAddHttpError ( { key : 'server:network' , error } ) )
4347 . then ( ( ) => setLoading ( false ) ) ;
4448 } ;
You can’t perform that action at this time.
0 commit comments