Skip to content

Commit

Permalink
fix: Kubernetes Dashboard cluster selector should respect project sel…
Browse files Browse the repository at this point in the history
…ection (#1152)
  • Loading branch information
maciaszczykm authored Jul 8, 2024
1 parent d4f2f02 commit fa0d5f3
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 173 deletions.
6 changes: 3 additions & 3 deletions assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"private": true,
"scripts": {
"start": "vite",
"start:dev": "BASE_URL=console.cd-demo.onplural.sh yarn start",
"start:dev": "BASE_URL=console.plrl-dev-aws.onplural.sh yarn start",
"start:cd": "BASE_URL=console.boot-aws.onplural.sh yarn start",
"start:prod": "yarn build && BASE_URL=console.cd-demo.onplural.sh vite preview",
"start:prod": "yarn build && BASE_URL=console.plrl-dev-aws.onplural.sh vite preview",
"build": "tsc && vite build",
"test": "vitest --run",
"test:watch": "vitest",
Expand Down Expand Up @@ -46,7 +46,7 @@
"@nivo/pie": "0.83.0",
"@nivo/radial-bar": "0.83.0",
"@nivo/tooltip": "0.83.0",
"@pluralsh/design-system": "^3.54.0",
"@pluralsh/design-system": "3.54.0",
"@react-hooks-library/core": "0.6.0",
"@tanstack/react-virtual": "3.0.1",
"anser": "2.1.1",
Expand Down
3 changes: 3 additions & 0 deletions assets/src/components/kubernetes/Cluster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useNamespacesQuery } from '../../generated/graphql-kubernetes'
import { KubernetesClient } from '../../helpers/kubernetes.client'
import LoadingIndicator from '../utils/LoadingIndicator'
import { GqlError } from '../utils/Alert'
import { useProjectId } from '../contexts/ProjectsContext'

type ClusterContextT = {
clusters: KubernetesClusterFragment[]
Expand Down Expand Up @@ -84,13 +85,15 @@ export const useNamespaces = () => {

export default function Cluster() {
const theme = useTheme()
const projectId = useProjectId()
const { clusterId } = useParams()
const { search } = useLocation()
const navigate = useNavigate()

const { data, error, refetch, loading } = useKubernetesClustersQuery({
pollInterval: 120_000,
fetchPolicy: 'cache-and-network',
variables: { projectId },
})

const clusters = useMemo(
Expand Down
17 changes: 12 additions & 5 deletions assets/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8892,14 +8892,16 @@ export type UpgradeStatisticsQueryVariables = Exact<{ [key: string]: never; }>;

export type UpgradeStatisticsQuery = { __typename?: 'RootQueryType', upgradeStatistics?: { __typename?: 'UpgradeStatistics', upgradeable?: number | null, count?: number | null, latest?: number | null, compliant?: number | null } | null };

export type KubernetesClusterFragment = { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, pinnedCustomResources?: Array<{ __typename?: 'PinnedCustomResource', id: string, name: string, kind: string, version: string, group: string, displayName: string, namespaced?: boolean | null, cluster?: { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null } | null } | null> | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null };
export type KubernetesClusterFragment = { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, project?: { __typename?: 'Project', id: string, name: string, default?: boolean | null, description?: string | null } | null, pinnedCustomResources?: Array<{ __typename?: 'PinnedCustomResource', id: string, name: string, kind: string, version: string, group: string, displayName: string, namespaced?: boolean | null, cluster?: { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null } | null } | null> | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null };

export type PinnedCustomResourceFragment = { __typename?: 'PinnedCustomResource', id: string, name: string, kind: string, version: string, group: string, displayName: string, namespaced?: boolean | null, cluster?: { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null } | null };

export type KubernetesClustersQueryVariables = Exact<{ [key: string]: never; }>;
export type KubernetesClustersQueryVariables = Exact<{
projectId?: InputMaybe<Scalars['ID']['input']>;
}>;


export type KubernetesClustersQuery = { __typename?: 'RootQueryType', clusters?: { __typename?: 'ClusterConnection', edges?: Array<{ __typename?: 'ClusterEdge', node?: { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, pinnedCustomResources?: Array<{ __typename?: 'PinnedCustomResource', id: string, name: string, kind: string, version: string, group: string, displayName: string, namespaced?: boolean | null, cluster?: { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null } | null } | null> | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null } | null } | null> | null } | null };
export type KubernetesClustersQuery = { __typename?: 'RootQueryType', clusters?: { __typename?: 'ClusterConnection', edges?: Array<{ __typename?: 'ClusterEdge', node?: { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, project?: { __typename?: 'Project', id: string, name: string, default?: boolean | null, description?: string | null } | null, pinnedCustomResources?: Array<{ __typename?: 'PinnedCustomResource', id: string, name: string, kind: string, version: string, group: string, displayName: string, namespaced?: boolean | null, cluster?: { __typename?: 'Cluster', id: string, name: string, self?: boolean | null, distro?: ClusterDistro | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null } | null } | null> | null, provider?: { __typename?: 'ClusterProvider', cloud: string } | null } | null } | null> | null } | null };

export type PinCustomResourceMutationVariables = Exact<{
attributes: PinnedCustomResourceAttributes;
Expand Down Expand Up @@ -10844,11 +10846,15 @@ export const PinnedCustomResourceFragmentDoc = gql`
export const KubernetesClusterFragmentDoc = gql`
fragment KubernetesCluster on Cluster {
...ClusterTiny
project {
...ProjectTiny
}
pinnedCustomResources {
...PinnedCustomResource
}
}
${ClusterTinyFragmentDoc}
${ProjectTinyFragmentDoc}
${PinnedCustomResourceFragmentDoc}`;
export const ArgoRolloutStatusFragmentDoc = gql`
fragment ArgoRolloutStatus on ArgoRolloutStatus {
Expand Down Expand Up @@ -17048,8 +17054,8 @@ export type UpgradeStatisticsLazyQueryHookResult = ReturnType<typeof useUpgradeS
export type UpgradeStatisticsSuspenseQueryHookResult = ReturnType<typeof useUpgradeStatisticsSuspenseQuery>;
export type UpgradeStatisticsQueryResult = Apollo.QueryResult<UpgradeStatisticsQuery, UpgradeStatisticsQueryVariables>;
export const KubernetesClustersDocument = gql`
query KubernetesClusters {
clusters(first: 200) {
query KubernetesClusters($projectId: ID) {
clusters(first: 200, projectId: $projectId) {
edges {
node {
...KubernetesCluster
Expand All @@ -17071,6 +17077,7 @@ export const KubernetesClustersDocument = gql`
* @example
* const { data, loading, error } = useKubernetesClustersQuery({
* variables: {
* projectId: // value for 'projectId'
* },
* });
*/
Expand Down
7 changes: 5 additions & 2 deletions assets/src/graph/kubernetes.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
fragment KubernetesCluster on Cluster {
...ClusterTiny
project {
...ProjectTiny
}
pinnedCustomResources {
...PinnedCustomResource
}
Expand All @@ -18,8 +21,8 @@ fragment PinnedCustomResource on PinnedCustomResource {
namespaced
}

query KubernetesClusters {
clusters(first: 200) {
query KubernetesClusters($projectId: ID) {
clusters(first: 200, projectId: $projectId) {
edges {
node {
...KubernetesCluster
Expand Down
Loading

0 comments on commit fa0d5f3

Please sign in to comment.