generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(supernova): refactor localItems, client.js, serviceApi, and …
…processingStatus to use React Query (#680) * refactor(supernova): reactQuery expire silence * refactor(supernova): recreate and createSilence with reactQuery * refactor(supernova): scheduledSilences are now ReactQuery * feat(supernova): make messages dismissable and instant close messages * refactor(supernova): rollback to message in modal through lack of sticky message * refactor(supernova): delete apiService, Client, states, and localitems * fix(supernova): fix loading silences * chore(supernova): bump version * chore(supernova): reduce duplicates in Store * refactor(supernova): optimistic expire * feat(supernova): optimistic updates Recreate Silence and Expire Silence * feat(supernova): optimistic updates * fix(supernova): fix scheduledSilence * fix(supernova): getMappingSilences are working again * fix(supernova): fix get mapping state * fix(supernova): correct padding * chore(supernova): del pending * refactor(supernova): useEndlessScrollList instead of own implementation * chore(supernova): messages are now lasting * refactor(supernova): name change * fix(supernova): Allow pending silences to expire * refactor(supernova): change MessageProvider * chore(supernova): decouples alerts list from alerts detail view * fix(supernova): give the error response to the messageprovider for clearer messages --------- Co-authored-by: Arturo Reuschenbach Puncernau <[email protected]>
- Loading branch information
1 parent
2191270
commit 92719cf
Showing
33 changed files
with
837 additions
and
1,891 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@cloudoperators/juno-app-supernova": minor | ||
--- | ||
|
||
Refactored fetch with ReactQuery and minor UI improvements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { deleteSilences, createSilences } from "./silences" | ||
|
||
export const MUTATION_FUNCTIONS = { | ||
deleteSilences: deleteSilences, | ||
createSilences: createSilences, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export const fetchSilences = async (endpoint) => { | ||
try { | ||
const response = await fetch(`${endpoint}/silences`) | ||
|
||
if (!response.ok) { | ||
// Parse the error object from the response body | ||
const errorObject = await response.json().catch(() => { | ||
throw new Error(`Unexpected error: Unable to parse error response.`) | ||
}) | ||
|
||
// Throw the error object directly | ||
throw errorObject | ||
} | ||
|
||
const items = await response.json() // Parse JSON data | ||
|
||
// Return the structured result | ||
return { | ||
silences: items, | ||
} | ||
} catch (error) { | ||
console.error(error) | ||
throw error // Let React Query handle the error | ||
} | ||
} | ||
|
||
export const deleteSilences = async (variables) => { | ||
try { | ||
const response = await fetch(`${variables.endpoint}/silence/${variables.id}`, { | ||
method: "DELETE", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
}, | ||
}) | ||
|
||
if (!response.ok) { | ||
const errorDetails = await response.json().catch(() => null) | ||
const errorMessage = errorDetails?.message || errorDetails || `Error ${response.status}: ${response.statusText}` | ||
throw new Error(errorMessage) | ||
} | ||
return await response | ||
} catch (error) { | ||
console.error(error) | ||
throw error // Let React Query handle the error | ||
} | ||
} | ||
|
||
export const createSilences = async (variables) => { | ||
try { | ||
const response = await fetch(`${variables.endpoint}/silences`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
Accept: "application/json", | ||
}, | ||
body: JSON.stringify(variables.silence), | ||
}) | ||
|
||
if (!response.ok) { | ||
const errorDetails = await response.json().catch(() => null) | ||
const errorMessage = errorDetails?.message || errorDetails || `Error ${response.status}: ${response.statusText}` | ||
throw new Error(errorMessage) | ||
} | ||
return await response.json() | ||
} catch (error) { | ||
console.error(error) | ||
throw error // Let React Query handle the error | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.