-
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.
individual refresh option working, but causing duplicateson webui
- Loading branch information
1 parent
0d8d064
commit a8a70d2
Showing
8 changed files
with
202 additions
and
13 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
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 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 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 |
---|---|---|
@@ -1,12 +1,50 @@ | ||
"use client"; | ||
import { CombinedData } from '@/types/workloads'; | ||
import {unstable_noStore as noStore} from "next/dist/server/web/spec-extension/unstable-no-store"; | ||
|
||
async function refreshSingleData(update: CombinedData) { | ||
'use server'; | ||
noStore(); | ||
console.log('refreshSingleData'); | ||
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL; | ||
if (!baseUrl) { | ||
console.warn('NEXT_PUBLIC_API_BASE_URL is not defined. Skipping fetch.'); | ||
return []; | ||
} | ||
const params = new URLSearchParams({ | ||
name: update.name, | ||
exclude_pattern: update.exclude_pattern, | ||
git_ops_repo: update.git_ops_repo, | ||
include_pattern: update.include_pattern, | ||
update_available: update.update_available, | ||
image: update.image, | ||
last_scanned: update.last_scanned, | ||
git_directory: update.git_directory, | ||
namespace: update.namespace, | ||
current_version: update.current_version, | ||
latest_version: update.latest_version, | ||
}); | ||
console.log(params.toString()); | ||
const res = await fetch(`${baseUrl}/api/update/workload?${params}`); | ||
if (!res.ok) { | ||
throw new Error('Failed to fetch data'); | ||
} | ||
return res.json(); | ||
|
||
const RefreshButton = () => { | ||
} | ||
|
||
const RefreshButton = ({update}: {update: CombinedData}) => { | ||
const handleRefresh = async () => { | ||
'use server'; | ||
console.log('Refresh clicked'); | ||
console.log(update); | ||
await refreshSingleData(update); | ||
} | ||
return ( | ||
<button onClick={() => {console.log('Refresh clicked')}}><b>Refresh</b></button> | ||
<div> | ||
<form action={handleRefresh}> | ||
<button>Refresh</button> | ||
</form> | ||
</div> | ||
); | ||
} | ||
|
||
|
||
|
||
export default RefreshButton; |
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,13 @@ | ||
export interface CombinedData { | ||
name: string, | ||
exclude_pattern: string, | ||
git_ops_repo: string, | ||
include_pattern: string, | ||
update_available: string, | ||
image: string, | ||
last_scanned: string, | ||
git_directory: string, | ||
namespace: string, | ||
current_version: string, | ||
latest_version: string, | ||
} |