Skip to content

Commit

Permalink
Repos global list on additional clusters (#5466)
Browse files Browse the repository at this point in the history
* Repos global list on additional clusters

Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>

* List global repos from main cluster

Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>

Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
  • Loading branch information
castelblanque authored Oct 17, 2022
1 parent 1fd6a76 commit cf90f8a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 31 deletions.
7 changes: 4 additions & 3 deletions dashboard/src/actions/repos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ export const fetchRepoSummaries = (
return async (dispatch, getState) => {
const {
clusters: { currentCluster },
config: { helmGlobalNamespace, carvelGlobalNamespace },
config: { kubeappsCluster, helmGlobalNamespace, carvelGlobalNamespace },
} = getState();
try {
dispatch(requestRepoSummaries(namespace));
const repos = await PackageRepositoriesService.getPackageRepositorySummaries({
cluster: currentCluster,
cluster: namespace ? currentCluster : kubeappsCluster,
namespace: namespace,
});
if (!listGlobal || [helmGlobalNamespace, carvelGlobalNamespace].includes(namespace)) {
Expand All @@ -85,8 +85,9 @@ export const fetchRepoSummaries = (
// however, this can cause issues when using unprivileged users, see #5215
let totalRepos = repos.packageRepositorySummaries;
dispatch(requestRepoSummaries(""));
// Global repos are only related to the Kubeapps cluster
const globalRepos = await PackageRepositoriesService.getPackageRepositorySummaries({
cluster: currentCluster,
cluster: kubeappsCluster,
namespace: "",
});
// Avoid adding duplicated repos: if two repos have the same uid, filter out
Expand Down
71 changes: 43 additions & 28 deletions dashboard/src/components/Config/PkgRepoList/PkgRepoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,30 @@ function PkgRepoList() {
});
};

const getGlobalReposTable = (
globalRepos: PackageRepositorySummary[],
disableControls: boolean,
) => {
return (
<>
<h3>Global Repositories:</h3>
<p>Global Package Repositories are available for all Kubeapps users.</p>
{globalRepos.length ? (
<Table
valign="center"
columns={tableColumns}
data={getTableData(globalRepos, disableControls)}
/>
) : (
<p>
There are no <i>global</i> Package Repositories yet. Click on the "Add Package
Repository" button to create one.
</p>
)}
</>
);
};

/* eslint-disable jsx-a11y/label-has-associated-control */
return (
<>
Expand All @@ -172,6 +196,7 @@ function PkgRepoList() {
namespace={currentNamespace}
helmGlobalNamespace={helmGlobalNamespace}
carvelGlobalNamespace={carvelGlobalNamespace}
disabled={!supportedCluster}
/>,
]}
filter={
Expand All @@ -189,20 +214,23 @@ function PkgRepoList() {
/>
<div className="catalog-container">
{!supportedCluster ? (
<Alert theme="warning">
<h5>Package Repositories can't be managed from this cluster.</h5>
<p>
Currently, the Package Repositories must be managed from the default cluster (the one
on which Kubeapps has been installed).
</p>
<p>
Any <i>global</i> Package Repository defined in the default cluster can be later used
across any target cluster.
<br />
However, <i>namespaced</i> Package Repositories can only be used on the default
cluster.
</p>
</Alert>
<div className="page-content">
<Alert theme="warning">
<h5>Package Repositories can't be managed from this cluster.</h5>
<p>
Currently, the Package Repositories must be managed from the default cluster (the
one on which Kubeapps has been installed).
</p>
<p>
Any <i>global</i> Package Repository defined in the default cluster can be later
used across any target cluster.
<br />
However, <i>namespaced</i> Package Repositories can only be used on the default
cluster.
</p>
</Alert>
{getGlobalReposTable(globalRepos, true)}
</div>
) : (
<div className="page-content">
{errors.fetch && (
Expand All @@ -222,20 +250,7 @@ function PkgRepoList() {
loadingText="Fetching Package Repositories..."
loaded={!isFetching}
>
<h3>Global Repositories:</h3>
<p>Global Package Repositories are available for all Kubeapps users.</p>
{globalRepos.length ? (
<Table
valign="center"
columns={tableColumns}
data={getTableData(globalRepos, !canEditGlobalRepos)}
/>
) : (
<p>
There are no <i>global</i> Package Repositories yet. Click on the "Add Package
Repository" button to create one.
</p>
)}
{getGlobalReposTable(globalRepos, !canEditGlobalRepos)}
{![helmGlobalNamespace, carvelGlobalNamespace].includes(namespace) && (
<>
<h3>Namespaced Repositories: {namespace}</h3>
Expand Down

0 comments on commit cf90f8a

Please sign in to comment.