Skip to content

Commit

Permalink
Improve toast
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminleonard committed Oct 10, 2024
1 parent de46cd0 commit 1d5ad81
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/pages/project/instances/InstancesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export function InstancesPage() {
instance={resizeInstance}
project={project}
onDismiss={() => setResizeInstance(null)}
onSuccess={() => apiQueryClient.invalidateQueries('instanceList')}
onListView
/>
)}
</>
Expand Down
21 changes: 16 additions & 5 deletions app/pages/project/instances/instance/InstancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export function InstancePage() {
instance={instance}
project={instanceSelector.project}
onDismiss={() => setResizeInstance(false)}
onSuccess={() => apiQueryClient.invalidateQueries('instanceView')}
/>
)}
</>
Expand All @@ -248,18 +247,30 @@ export function ResizeInstanceModal({
instance,
project,
onDismiss,
onSuccess,
onListView = false,
}: {
instance: Instance
project: string
onDismiss: () => void
onSuccess: () => void
onListView?: boolean
}) {
const instanceUpdate = useApiMutation('instanceUpdate', {
onSuccess(_updatedInstance) {
onSuccess()
if (onListView) {
apiQueryClient.invalidateQueries('instanceList')
} else {
apiQueryClient.invalidateQueries('instanceView')
}
onDismiss()
addToast({ title: 'Instance resized' })
addToast({
content: `${instance.name} has been resized`,
cta: onListView
? {
text: `View instance`,
link: pb.instance({ project, instance: instance.name }),
}
: undefined, // Only link to the instance if we're not already on that page
})
},
onError: (err) => {
addToast({ title: 'Error', content: err.message, variant: 'error' })
Expand Down

0 comments on commit 1d5ad81

Please sign in to comment.