Skip to content

Commit

Permalink
Merge pull request #132 from kthcloud/beta
Browse files Browse the repository at this point in the history
Fix shared resources in deploy list
  • Loading branch information
pierrelefevre authored Dec 15, 2023
2 parents 055554a + a81b153 commit e7f7600
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
15 changes: 7 additions & 8 deletions src/contexts/ResourceContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const ResourceContextProvider = ({ children }) => {
};

const getTeamResourceIds = () => {
if (!teams) return;
if (!teams) return [];

let resourceIds = [];

Expand Down Expand Up @@ -127,17 +127,16 @@ export const ResourceContextProvider = ({ children }) => {
let userOwned = array.filter((row) => row.ownerId === user.id);

let teamResourceIds = getTeamResourceIds();
teamResourceIds.forEach((resourceId) => {
let sharedRow = array.find((row) => row.id === resourceId);

sharedRow.shared = true;
let sharedResources = array.filter((row) =>
teamResourceIds.includes(row.id)
);

if (sharedRow && !userOwned.includes(sharedRow)) {
userOwned.push(sharedRow);
}
sharedResources = sharedResources.map((row) => {
return { ...row, shared: true };
});

setUserRows(userOwned);
setUserRows(userOwned.concat(sharedResources));
};

const loadZones = async () => {
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
"explain-deployment": "Ideal for web apps. Provides the ability to easily run a single container. Allows for CI/CD through GitHub Actions and other pipelines. Your repo must have a Dockerfile.",
"explain-vm": "Provides the ability to run an operating system directly. More versatile but deployment and maintenance will be more difficult. Ideal for GPU compute.",
"choose-zone": "Choose zone",
"zone": "Zone",
"choose-zone-subheader-1": "Your chosen zone determines where your",
"choose-zone-subheader-2": "will be hosted. Selecting the closest zone to your users will improve performance",
"deploy-hidden": "This deployment is private, it is not visible on the Internet",
Expand Down
1 change: 1 addition & 0 deletions src/locales/se.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
"your-snapshots": "Dina avbildningar",
"proxies-subheader-2": "Det gör så du kommer åt den med en snygg länk istället för en slumpmässig port.",
"choose-zone": "Välj zon",
"zone": "Zon",
"overview": "Överblick",
"proxies-subheader-1": "Driftssätt en proxy till en exponerad port på din virtuella maskin.",
"your-snapshot-will-be-created-as": "Din avbildning skapas som",
Expand Down
15 changes: 11 additions & 4 deletions src/pages/deploy/Deploy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ export function Deploy() {
{ id: "name", label: t("admin-name"), alignRight: false },
{ id: "type", label: t("resource-type"), alignRight: false },
{ id: "status", label: t("admin-status"), alignRight: false },
{ id: "" },
{ id: "zone", label: t("zone"), alignRight: false },
{ id: "", label: "", alignRight: true },
];

const bulkDelete = async () => {
Expand All @@ -119,13 +120,11 @@ export function Deploy() {
try {
const promises = selected.map(async (id) => {
if (userRows.find((row) => row.id === id).type === "vm") {
console.log("deleting vm");
const res = await deleteVM(id, keycloak.token);
queueJob(res);
return;
}
if (userRows.find((row) => row.id === id).type === "deployment") {
console.log("deleting k8s");
const res = await deleteDeployment(id, keycloak.token);
queueJob(res);
return;
Expand Down Expand Up @@ -470,10 +469,18 @@ export function Deploy() {
>
{renderResourceStatus(row)}
{renderStatusCode(row)}
{renderZone(row)}
{renderShared(row)}
</Stack>
</TableCell>
<TableCell align="left">
<Stack
direction="row"
alignItems="center"
spacing={1}
>
{renderZone(row)}
</Stack>
</TableCell>

<TableCell align="right">
{renderResourceButtons(row)}
Expand Down
1 change: 0 additions & 1 deletion src/pages/edit/DangerZone.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const DangerZone = ({ resource }) => {
options = [...new Set(options)];
options.sort((a, b) => a.localeCompare(b));
setResultsTeam(options);
console.log(options);
};

const updateOwner = async () => {
Expand Down
3 changes: 0 additions & 3 deletions src/pages/edit/deployments/LogsView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export const LogsView = ({ deployment }) => {
}
);

console.log(eventSource);

setSse(eventSource);

eventSource.onerror = () => {
Expand All @@ -70,7 +68,6 @@ export const LogsView = ({ deployment }) => {
});

eventSource.onopen = (e) => {
console.log(e);
setConnection("connected");
};
};
Expand Down
6 changes: 1 addition & 5 deletions src/pages/profile/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,12 @@ export function Profile() {

try {
const data = mode === "keys" ? { publicKeys: user.publicKeys } : user;
const response = await updateUser(keycloak.subject, keycloak.token, data);
console.log(response);
await updateUser(keycloak.subject, keycloak.token, data);
setValidationError({});
enqueueSnackbar(t("successfully-updated") + " " + mode, {
variant: "success",
});
} catch (error) {
console.log(error);
if (error.validationErrors) setValidationError(error.validationErrors);

enqueueSnackbar(t("error-updating") + mode, {
Expand Down Expand Up @@ -225,8 +223,6 @@ export function Profile() {
)}

<div style={{ flexGrow: "1" }} />


</Stack>
</Stack>
</CardContent>
Expand Down
1 change: 0 additions & 1 deletion src/pages/teams/Teams.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ const Teams = () => {
setTeamDescription("");
setStale("created");
} catch (error) {
console.log(error);
errorHandler(error).forEach((e) =>
enqueueSnackbar(t("update-error") + e, {
variant: "error",
Expand Down

0 comments on commit e7f7600

Please sign in to comment.