-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e80e547
commit 6828832
Showing
16 changed files
with
520 additions
and
73 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 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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<component type="addon"> | ||
<id>org.opensuse.cockpit-repos.metainfo.xml</id> | ||
<metadata_license>CC0-1.0</metadata_license> | ||
<name>Repositories</name> | ||
<summary>A cockpit module for managing repositories.</summary> | ||
<description> | ||
<p> | ||
A cockpit module for managing repositories. | ||
</p> | ||
</description> | ||
<extends>org.cockpit_project.cockpit</extends> | ||
<launchable type="cockpit-manifest">repositories</launchable> | ||
<url type="homepage">https://github.com/openSUSE/cockpit-repos</url> | ||
<url type="bugtracker">https://github.com/openSUSE/cockpit-repos/issues</url> | ||
<developer id="org.opensuse"> | ||
<name>openSUSE</name> | ||
</developer> | ||
</component> |
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,6 +1,6 @@ | ||
{ | ||
"name": "starter-kit", | ||
"description": "Scaffolding for a cockpit module", | ||
"name": "cockpit-repos", | ||
"description": "A cockpit module for managing system repositories", | ||
"type": "module", | ||
"main": "index.js", | ||
"repository": "[email protected]:cockpit/starter-kit.git", | ||
|
@@ -54,6 +54,7 @@ | |
"@patternfly/react-core": "5.4.11", | ||
"@patternfly/react-icons": "5.4.2", | ||
"@patternfly/react-styles": "5.4.1", | ||
"@patternfly/react-table": "^6.1.0", | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1" | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
packaging/cockpit-starter-kit.spec.in → packaging/cockpit-repos.spec.in
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,5 +1,17 @@ | ||
@use "@patternfly/patternfly/patternfly-addons"; | ||
@use "page.scss"; | ||
|
||
p { | ||
font-weight: bold; | ||
} | ||
|
||
.pf-v6-c-table tr { | ||
> td, th { | ||
--pf-v5-c-table--cell--PaddingTop: var(--pf-v5-global--spacer--xs); | ||
--pf-v5-c-table--cell--PaddingBottom: var(--pf-v5-global--spacer--xs); | ||
|
||
padding-block: var(--pf-v5-c-table--cell--PaddingTop) var(--pf-v5-c-table--cell--PaddingBottom); | ||
|
||
padding-inline: var(--pf-v5-c-table--cell--PaddingLeft) var(--pf-v5-c-table--cell--PaddingRight); | ||
} | ||
} |
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,34 @@ | ||
// enum RepoType { | ||
// ftp, | ||
// http, | ||
// https, | ||
// smb_cifs, | ||
// nfs, | ||
// cd, | ||
// dvd, | ||
// hard_disk, | ||
// usb, | ||
// local_directory, | ||
// local_iso_image, | ||
// } | ||
|
||
type Repo = { | ||
index: number, | ||
alias: string, | ||
name: string, | ||
// type: RepoType, | ||
priority: number, | ||
enabled: boolean, | ||
autorefresh: boolean, | ||
gpgcheck: boolean, | ||
uri: string, | ||
} | ||
|
||
interface Backend { | ||
getRepos(): Promise<Repo[]>, | ||
addRepo(repo: Repo): Promise<any> | ||
deleteRepo(repo: Repo): Promise<any> | ||
modifyRepo(repo: Repo): Promise<any> | ||
} | ||
|
||
export { Repo, Backend }; |
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 @@ | ||
import cockpit from "cockpit"; | ||
|
||
import { Backend, Repo } from "./backend"; | ||
|
||
export class Zypp implements Backend { | ||
deleteRepo(repo: Repo): Promise<any> { | ||
return cockpit.spawn(["zypper", "removerepo", repo.index.toString()], { superuser: "require" }); | ||
} | ||
|
||
async getRepos(): Promise<Repo[]> { | ||
return cockpit.spawn(["zypper", "--xmlout", "repos"]).then((response) => { | ||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(response, "text/xml"); | ||
let index = 1; | ||
const repos = Array.from(doc.documentElement.querySelectorAll("repo")).map( | ||
(repo): Repo => { | ||
const definedRepo = { | ||
index, | ||
alias: repo.getAttribute("alias") || "", | ||
name: repo.getAttribute("name") || "", | ||
priority: parseInt(repo.getAttribute("priority") || ""), | ||
enabled: repo.getAttribute("enabled") === "1", | ||
autorefresh: repo.getAttribute("autorefresh") === "1", | ||
gpgcheck: repo.getAttribute("gpgcheck") === "1", | ||
uri: repo.querySelector("url")?.textContent || "", | ||
}; | ||
|
||
index++; | ||
return definedRepo; | ||
}, | ||
); | ||
return repos; | ||
}); | ||
} | ||
|
||
addRepo(repo: Repo): Promise<any> { | ||
const args = ["-n", repo.name, "-p", repo.priority.toString()]; | ||
if (repo.enabled) { | ||
args.push("--enable"); | ||
} else { | ||
args.push("--disable"); | ||
} | ||
if (repo.autorefresh) { | ||
args.push("--refresh"); | ||
} else { | ||
args.push("--no-refresh"); | ||
} | ||
if (repo.gpgcheck) { | ||
args.push("--gpgcheck"); | ||
} else { | ||
args.push("--no-gpgcheck"); | ||
} | ||
return cockpit.spawn(["zypper", "addrepo", ...args, repo.uri, repo.alias], { superuser: "require" }); | ||
} | ||
|
||
modifyRepo(repo: Repo): Promise<any> { | ||
const args = ["-n", repo.name, "-p", repo.priority.toString()]; | ||
if (repo.enabled) { | ||
args.push("--enable"); | ||
} else { | ||
args.push("--disable"); | ||
} | ||
if (repo.autorefresh) { | ||
args.push("--refresh"); | ||
} else { | ||
args.push("--no-refresh"); | ||
} | ||
if (repo.gpgcheck) { | ||
args.push("--gpgcheck"); | ||
} else { | ||
args.push("--no-gpgcheck"); | ||
} | ||
return cockpit.spawn(["zypper", "modifyrepo", ...args, repo.index.toString()], { superuser: "require" }); | ||
} | ||
} |
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,30 @@ | ||
import React from "react"; | ||
import { Modal } from "@patternfly/react-core"; | ||
import cockpit from "cockpit"; | ||
|
||
import { useDialogs } from "dialogs.jsx"; | ||
import RepoForm from "./repo_form"; | ||
import { Backend, Repo } from "../backends/backend"; | ||
|
||
const _ = cockpit.gettext; | ||
|
||
export const RepoDialog = ({ | ||
backend, | ||
repo, | ||
}: { | ||
backend: Backend; | ||
repo: null | Repo; | ||
}) => { | ||
const Dialogs = useDialogs(); | ||
|
||
return ( | ||
<Modal | ||
title={_("Add a repo")} | ||
variant="small" | ||
onClose={Dialogs.close} | ||
isOpen | ||
> | ||
<RepoForm backend={backend} repo={repo} close={Dialogs.close} /> | ||
</Modal> | ||
); | ||
}; |
Oops, something went wrong.