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

Repos global list on additional clusters #5466

Merged
merged 2 commits into from
Oct 17, 2022
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
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}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also disabled the "Add package repository" button if the cluster is not the default one.

/>,
]}
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