Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update digest #960

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ interface AdditionalPort {
/**
* ManageTraefikPorts is a component that provides a modal interface for managing
* additional port mappings for Traefik in a Docker Swarm environment.
*
*
* Features:
* - Add, remove, and edit port mappings
* - Configure target port, published port, and publish mode for each mapping
* - Persist port configurations through API calls
*
*
* @component
* @example
* ```tsx
Expand Down Expand Up @@ -121,7 +121,10 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => {
</DialogHeader>
<div className="grid gap-4 py-4">
{additionalPorts.map((port, index) => (
<div key={index} className="grid grid-cols-[120px_120px_minmax(120px,1fr)_80px] gap-4 items-end">
<div
key={index}
className="grid grid-cols-[120px_120px_minmax(120px,1fr)_80px] gap-4 items-end"
>
<div className="space-y-2">
<Label htmlFor={`target-port-${index}`}>
{t("settings.server.webServer.traefik.targetPort")}
Expand All @@ -132,7 +135,9 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => {
value={port.targetPort}
onChange={(e) => {
const newPorts = [...additionalPorts];
newPorts[index].targetPort = Number.parseInt(

// @ts-ignore
newPorts?.[index].targetPort = Number.parseInt(
e.target.value,
);
setAdditionalPorts(newPorts);
Expand All @@ -150,7 +155,8 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => {
value={port.publishedPort}
onChange={(e) => {
const newPorts = [...additionalPorts];
newPorts[index].publishedPort = Number.parseInt(
// @ts-ignore
newPorts?.[index].publishedPort = Number.parseInt(
e.target.value,
);
setAdditionalPorts(newPorts);
Expand All @@ -166,11 +172,15 @@ export const ManageTraefikPorts = ({ children, serverId }: Props) => {
value={port.publishMode}
onValueChange={(value: "ingress" | "host") => {
const newPorts = [...additionalPorts];
newPorts[index].publishMode = value;
// @ts-ignore
newPorts?.[index].publishMode = value;
setAdditionalPorts(newPorts);
}}
>
<SelectTrigger id={`publish-mode-${index}`} className="w-full">
<SelectTrigger
id={`publish-mode-${index}`}
className="w-full"
>
<SelectValue />
</SelectTrigger>
<SelectContent>
Expand Down
34 changes: 16 additions & 18 deletions packages/server/src/services/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const getUpdateData = async (): Promise<IUpdateData> => {
const baseUrl = "https://hub.docker.com/v2/repositories/dokploy/dokploy/tags";
let url: string | null = `${baseUrl}?page_size=100`;
let allResults: { digest: string; name: string }[] = [];

while (url) {
const response = await fetch(url, {
method: "GET",
Expand All @@ -81,30 +80,29 @@ export const getUpdateData = async (): Promise<IUpdateData> => {
url = data?.next;
}

const latestTagDigest = allResults.find(
(t) => t.name === getDokployImageTag(),
)?.digest;
const imageTag = getDokployImageTag();
const searchedDigest = allResults.find((t) => t.name === imageTag)?.digest;

if (!latestTagDigest) {
if (!searchedDigest) {
return DEFAULT_UPDATE_DATA;
}

const versionedTag = allResults.find(
(t) => t.digest === latestTagDigest && t.name.startsWith("v"),
);

if (!versionedTag) {
return DEFAULT_UPDATE_DATA;
}
if (imageTag === "latest") {
const versionedTag = allResults.find(
(t) => t.digest === searchedDigest && t.name.startsWith("v"),
);

const { name: latestVersion, digest } = versionedTag;
const updateAvailable = digest !== currentDigest;
if (!versionedTag) {
return DEFAULT_UPDATE_DATA;
}

return { latestVersion, updateAvailable };
};
const { name: latestVersion, digest } = versionedTag;
const updateAvailable = digest !== currentDigest;

export const getDokployVersion = () => {
// return packageInfo.version;
return { latestVersion, updateAvailable };
}
const updateAvailable = searchedDigest !== currentDigest;
return { latestVersion: imageTag, updateAvailable };
};

interface TreeDataItem {
Expand Down
Loading