Skip to content

Commit 3380a33

Browse files
committed
fix some types
1 parent e37670f commit 3380a33

File tree

10 files changed

+74
-56
lines changed

10 files changed

+74
-56
lines changed

www/src/components/cluster/ClusterConsole.tsx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
import { ReactElement } from 'react'
2-
3-
import LoadingIndicator from '../utils/LoadingIndicator'
1+
import { ClusterFragment, useRepositoryQuery } from '../../generated/graphql'
42
import { EmptyListMessage } from '../overview/clusters/misc'
5-
import { Cluster, useRepositoryQuery } from '../../generated/graphql'
3+
import LoadingIndicator from '../utils/LoadingIndicator'
64

7-
import { GqlError } from '../utils/Alert'
8-
import { useNavigate, useParams } from 'react-router-dom'
9-
import { useTheme } from 'styled-components'
105
import {
11-
IconFrame,
12-
Flex,
6+
ArrowTopRightIcon,
7+
Button,
138
Card,
149
Chip,
10+
Flex,
1511
GearTrainIcon,
16-
Button,
17-
ArrowTopRightIcon,
12+
IconFrame,
1813
} from '@pluralsh/design-system'
19-
import { Body1BoldP } from '../utils/Typography'
20-
import { ensureURLValidity } from '../../utils/url'
14+
import { useNavigate, useParams } from 'react-router-dom'
15+
import { useTheme } from 'styled-components'
2116
import { ignoreEvent } from '../../utils/ignore-event'
17+
import { ensureURLValidity } from '../../utils/url'
18+
import { GqlError } from '../utils/Alert'
19+
import { Body1BoldP } from '../utils/Typography'
2220

2321
const CONSOLE_APP_NAME = 'console'
2422

25-
type ClusterAppsProps = { cluster: Cluster }
26-
2723
export function ClusterConsole({
2824
cluster: { consoleUrl },
29-
}: ClusterAppsProps): ReactElement {
25+
}: {
26+
cluster: ClusterFragment
27+
}) {
3028
const theme = useTheme()
3129
const navigate = useNavigate()
3230
const { clusterId } = useParams()

www/src/components/cluster/ClusterDependencyModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useMutation } from '@apollo/client'
55

66
import subscriptionContext from '../../contexts/SubscriptionContext'
77

8-
import { Cluster } from '../../generated/graphql'
8+
import { ClusterFragment } from '../../generated/graphql'
99
import { ClusterPicker } from '../utils/ClusterPicker'
1010
import { GqlError } from '../utils/Alert'
1111

@@ -16,7 +16,7 @@ import UpgradeNeededModal from './UpgradeNeededModal'
1616
type ClusterDependencyModalProps = {
1717
open: boolean
1818
setOpen: Dispatch<boolean>
19-
destination: Cluster
19+
destination: ClusterFragment
2020
}
2121

2222
export function ClusterDependencyModal({
@@ -25,7 +25,7 @@ export function ClusterDependencyModal({
2525
destination,
2626
}: ClusterDependencyModalProps) {
2727
const { isPaidPlan, isTrialPlan } = useContext(subscriptionContext)
28-
const [source, setSource] = useState<Cluster | undefined>()
28+
const [source, setSource] = useState<ClusterFragment | undefined>()
2929

3030
const close = useCallback(() => {
3131
setOpen(false)
@@ -42,7 +42,7 @@ export function ClusterDependencyModal({
4242
)
4343

4444
const filterSources = useCallback(
45-
(s: Cluster) => {
45+
(s: ClusterFragment) => {
4646
const d = destination
4747

4848
return (

www/src/components/cluster/ClusterMetadataPanel.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { A } from 'honorable'
22
import moment from 'moment'
33
import { Tooltip } from '@pluralsh/design-system'
4-
import { Dispatch, ReactElement } from 'react'
4+
import { Dispatch } from 'react'
55
import { Link } from 'react-router-dom'
66

7-
import { Cluster } from '../../generated/graphql'
7+
import { ClusterFragment } from '../../generated/graphql'
88
import CopyButton from '../utils/CopyButton'
99
import ClusterHealth from '../overview/clusters/ClusterHealth'
1010
import ClusterOwner from '../overview/clusters/ClusterOwner'
1111
import { InfoPanel } from '../utils/InfoPanel'
1212
import Prop from '../utils/Prop'
1313

1414
type ClusterMetadataPanelProps = {
15-
cluster: Cluster
15+
cluster: ClusterFragment
1616
open: boolean
1717
setOpen: Dispatch<boolean>
1818
}
@@ -21,7 +21,7 @@ export default function ClusterMetadataPanel({
2121
cluster,
2222
open,
2323
setOpen,
24-
}: ClusterMetadataPanelProps): ReactElement | null {
24+
}: ClusterMetadataPanelProps) {
2525
if (!open) return null
2626

2727
return (

www/src/components/cluster/ClusterPromoteModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Dispatch, useCallback, useContext, useState } from 'react'
44
import isNil from 'lodash/isNil'
55
import { useMutation } from '@apollo/client'
66

7-
import { Cluster } from '../../generated/graphql'
7+
import { ClusterFragment } from '../../generated/graphql'
88
import { ClusterPicker } from '../utils/ClusterPicker'
99
import { GqlError } from '../utils/Alert'
1010
import { ensureURLValidity } from '../../utils/url'
@@ -18,7 +18,7 @@ import ClustersContext from '../../contexts/ClustersContext'
1818
type ClusterPromoteModalProps = {
1919
open: boolean
2020
setOpen: Dispatch<boolean>
21-
destination: Cluster
21+
destination: ClusterFragment
2222
}
2323

2424
export function ClusterPromoteModal({

www/src/components/cluster/ClusterSidecar.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
import { Sidecar, SidecarItem, Tooltip } from '@pluralsh/design-system'
12
import { A, Flex } from 'honorable'
23
import moment from 'moment'
3-
import { Button, Sidecar, SidecarItem, Tooltip } from '@pluralsh/design-system'
44
import { ReactElement } from 'react'
55
import { Link } from 'react-router-dom'
66

7-
import { Cluster } from '../../generated/graphql'
8-
import CopyButton from '../utils/CopyButton'
7+
import { ClusterFragment } from '../../generated/graphql'
98
import ClusterHealth from '../overview/clusters/ClusterHealth'
10-
import { ensureURLValidity } from '../../utils/url'
119
import ClusterOwner from '../overview/clusters/ClusterOwner'
10+
import CopyButton from '../utils/CopyButton'
1211

13-
type ClusterSidecarProps = { cluster: Cluster }
12+
type ClusterSidecarProps = { cluster: ClusterFragment }
1413

1514
export function ClusterSidecar({ cluster }: ClusterSidecarProps): ReactElement {
1615
return (

www/src/components/overview/ClusterUpgradeInfo.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { isEmpty } from 'lodash'
2-
import { Flex } from 'honorable'
31
import { CaretRightIcon, Chip, IconFrame } from '@pluralsh/design-system'
2+
import { Flex } from 'honorable'
3+
import { isEmpty } from 'lodash'
44
import { Link } from 'react-router-dom'
55

66
import { useTheme } from 'styled-components'
77

8-
import { Maybe, UpgradeInfo } from '../../generated/graphql'
8+
import { Maybe, UpgradeInfoFragment } from '../../generated/graphql'
99
import { getRepoIcon } from '../repository/misc'
1010

1111
type ClusterUpgradeInfoProps = {
1212
clusterId?: Maybe<string>
13-
upgradeInfo?: Maybe<Maybe<UpgradeInfo>[]>
13+
upgradeInfo?: Maybe<Maybe<UpgradeInfoFragment>[]>
1414
}
1515

1616
export function ClusterUpgradeInfo({

www/src/components/utils/ClusterPicker.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ import {
2020
import ClustersContext from '../../contexts/ClustersContext'
2121

2222
import { useCurrentUser } from '../../contexts/CurrentUserContext'
23-
import { Cluster, Maybe, Provider, UpgradeInfo } from '../../generated/graphql'
23+
import {
24+
ClusterFragment,
25+
Maybe,
26+
Provider,
27+
UpgradeInfoFragment,
28+
} from '../../generated/graphql'
2429
import ClusterHealth from '../overview/clusters/ClusterHealth'
2530

2631
import { ProviderIcon } from './ProviderIcon'
2732

28-
type ClusterPickerReadyChipProps = { upgradeInfo?: Maybe<UpgradeInfo>[] | null }
33+
type ClusterPickerReadyChipProps = {
34+
upgradeInfo?: Maybe<UpgradeInfoFragment>[] | null
35+
}
2936

3037
function ClusterPickerReadyChip({ upgradeInfo }: ClusterPickerReadyChipProps) {
3138
const ready = useMemo(() => isEmpty(upgradeInfo), [upgradeInfo])
@@ -42,8 +49,8 @@ function ClusterPickerReadyChip({ upgradeInfo }: ClusterPickerReadyChipProps) {
4249
}
4350

4451
type ClusterPickerProps = {
45-
cluster?: Cluster | null
46-
setCluster?: Dispatch<Cluster | undefined>
52+
cluster?: ClusterFragment | null
53+
setCluster?: Dispatch<ClusterFragment | undefined>
4754
onChange?: (Cluster) => void
4855
filter?: (Cluster) => boolean
4956
heading?: string
@@ -94,8 +101,10 @@ export function ClusterPicker({
94101
)
95102
}
96103

97-
type SelectBoxCluster = Pick<Cluster, 'id' | 'name'> &
98-
Partial<Pick<Cluster, 'pingedAt' | 'provider' | 'upgradeInfo' | 'owner'>> & {
104+
type SelectBoxCluster = Pick<ClusterFragment, 'id' | 'name'> &
105+
Partial<
106+
Pick<ClusterFragment, 'pingedAt' | 'provider' | 'upgradeInfo' | 'owner'>
107+
> & {
99108
icon?: ReactNode
100109
}
101110

@@ -235,16 +244,16 @@ type CloudShellClusterPickerProps = Omit<
235244
'clusters'
236245
> & { showCliClusters?: boolean }
237246

238-
export function clusterHasCloudShell(cluster: Cluster) {
247+
export function clusterHasCloudShell(cluster: ClusterFragment) {
239248
return !!cluster?.owner?.hasShell
240249
}
241250

242-
export function userCanAdminCluster(cluster: Cluster, userId: string) {
251+
export function userCanAdminCluster(cluster: ClusterFragment, userId: string) {
243252
return cluster.owner?.id === userId || !!cluster.owner?.serviceAccount
244253
}
245254

246255
export function clusterFilter(
247-
cluster: Cluster,
256+
cluster: ClusterFragment,
248257
currentUserId: string,
249258
{ showCliClusters = false }
250259
) {
@@ -269,7 +278,7 @@ export function CloudShellClusterPicker({
269278
() =>
270279
raw
271280
? raw.filter((cl) => clusterFilter(cl, userId, { showCliClusters }))
272-
: ([] as Cluster[]),
281+
: ([] as ClusterFragment[]),
273282
[raw, showCliClusters, userId]
274283
)
275284

www/src/components/utils/InstallAppButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Link } from 'react-router-dom'
2121

2222
import ClustersContext from '../../contexts/ClustersContext'
2323
import { useCurrentUser } from '../../contexts/CurrentUserContext'
24-
import { Cluster, Provider } from '../../generated/graphql'
24+
import { ClusterFragment, Provider } from '../../generated/graphql'
2525

2626
import {
2727
CloudShellClusterPicker,
@@ -225,7 +225,7 @@ function InstallModal({
225225
onClose,
226226
...props
227227
}: Omit<InstallAppButtonProps, 'loading'> & {
228-
clusters: Cluster[]
228+
clusters: ClusterFragment[]
229229
} & ComponentProps<typeof Modal>) {
230230
const [clusterId, setClusterId] = useState<string | undefined>(
231231
!isEmpty(clusters) ? clusters[0].id : undefined

www/src/generated/graphql.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5486,6 +5486,8 @@ export type UninstallChartMutation = { __typename?: 'RootMutationType', deleteCh
54865486

54875487
export type ClusterFragment = { __typename?: 'Cluster', id: string, name: string, provider: Provider, source?: Source | null, pingedAt?: Date | null, gitUrl?: string | null, consoleUrl?: string | null, owner?: { __typename?: 'User', id: string, name: string, email: string, avatar?: string | null, provider?: Provider | null, demoed?: boolean | null, onboarding?: OnboardingState | null, emailConfirmed?: boolean | null, emailConfirmBy?: Date | null, backgroundColor?: string | null, serviceAccount?: boolean | null, hasInstallations?: boolean | null, hasShell?: boolean | null, impersonationPolicy?: { __typename?: 'ImpersonationPolicy', id: string, bindings?: Array<{ __typename?: 'ImpersonationPolicyBinding', id: string, group?: { __typename?: 'Group', id: string, name: string } | null, user?: { __typename?: 'User', id: string, name: string, email: string } | null } | null> | null } | null, onboardingChecklist?: { __typename?: 'OnboardingChecklist', dismissed?: boolean | null, status?: OnboardingChecklistState | null } | null, invites?: Array<{ __typename?: 'Invite', id: string, email?: string | null } | null> | null, roles?: { __typename?: 'Roles', admin?: boolean | null } | null, groups?: Array<{ __typename?: 'Group', id: string, name: string, global?: boolean | null, description?: string | null } | null> | null } | null, queue?: { __typename?: 'UpgradeQueue', id: string, acked?: string | null, upgrades?: { __typename?: 'UpgradeConnection', edges?: Array<{ __typename?: 'UpgradeEdge', node?: { __typename?: 'Upgrade', id: string } | null } | null> | null } | null } | null, upgradeInfo?: Array<{ __typename?: 'UpgradeInfo', count?: number | null, installation?: { __typename?: 'Installation', id: string, context?: Map<string, unknown> | null, license?: string | null, licenseKey?: string | null, acmeKeyId?: string | null, acmeSecret?: string | null, autoUpgrade?: boolean | null, trackTag: string, pingedAt?: Date | null, synced?: boolean | null, locked?: boolean | null, repository?: { __typename?: 'Repository', id: string, name: string, icon?: string | null, darkIcon?: string | null, private?: boolean | null, trending?: boolean | null, verified?: boolean | null, category?: Category | null } | null, user?: { __typename?: 'User', id: string, name: string, email: string, avatar?: string | null, provider?: Provider | null, demoed?: boolean | null, onboarding?: OnboardingState | null, emailConfirmed?: boolean | null, emailConfirmBy?: Date | null, backgroundColor?: string | null, serviceAccount?: boolean | null, hasInstallations?: boolean | null, hasShell?: boolean | null, onboardingChecklist?: { __typename?: 'OnboardingChecklist', dismissed?: boolean | null, status?: OnboardingChecklistState | null } | null, invites?: Array<{ __typename?: 'Invite', id: string, email?: string | null } | null> | null, roles?: { __typename?: 'Roles', admin?: boolean | null } | null, groups?: Array<{ __typename?: 'Group', id: string, name: string, global?: boolean | null, description?: string | null } | null> | null, impersonationPolicy?: { __typename?: 'ImpersonationPolicy', id: string, bindings?: Array<{ __typename?: 'ImpersonationPolicyBinding', id: string, group?: { __typename?: 'Group', id: string, name: string } | null, user?: { __typename?: 'User', id: string, name: string, email: string } | null } | null> | null } | null } | null, oidcProvider?: { __typename?: 'OidcProvider', id: string, name?: string | null, description?: string | null, clientId: string, authMethod: OidcAuthMethod, clientSecret: string, redirectUris?: Array<string | null> | null, bindings?: Array<{ __typename?: 'OidcProviderBinding', id: string, user?: { __typename?: 'User', id: string, name: string, email: string, avatar?: string | null, provider?: Provider | null, demoed?: boolean | null, onboarding?: OnboardingState | null, emailConfirmed?: boolean | null, emailConfirmBy?: Date | null, backgroundColor?: string | null, serviceAccount?: boolean | null, hasInstallations?: boolean | null, hasShell?: boolean | null, onboardingChecklist?: { __typename?: 'OnboardingChecklist', dismissed?: boolean | null, status?: OnboardingChecklistState | null } | null, invites?: Array<{ __typename?: 'Invite', id: string, email?: string | null } | null> | null, roles?: { __typename?: 'Roles', admin?: boolean | null } | null, groups?: Array<{ __typename?: 'Group', id: string, name: string, global?: boolean | null, description?: string | null } | null> | null, impersonationPolicy?: { __typename?: 'ImpersonationPolicy', id: string, bindings?: Array<{ __typename?: 'ImpersonationPolicyBinding', id: string, group?: { __typename?: 'Group', id: string, name: string } | null, user?: { __typename?: 'User', id: string, name: string, email: string } | null } | null> | null } | null } | null, group?: { __typename?: 'Group', id: string, name: string, global?: boolean | null, description?: string | null } | null } | null> | null, configuration?: { __typename?: 'OuathConfiguration', issuer?: string | null, authorizationEndpoint?: string | null, tokenEndpoint?: string | null, jwksUri?: string | null, userinfoEndpoint?: string | null } | null, invites?: Array<{ __typename?: 'Invite', id: string, email?: string | null } | null> | null } | null } | null } | null> | null, dependency?: { __typename?: 'ClusterDependency', dependency?: { __typename?: 'Cluster', id: string, name: string, provider: Provider } | null } | null };
54885488

5489+
export type UpgradeInfoFragment = { __typename?: 'UpgradeInfo', count?: number | null, installation?: { __typename?: 'Installation', id: string, context?: Map<string, unknown> | null, license?: string | null, licenseKey?: string | null, acmeKeyId?: string | null, acmeSecret?: string | null, autoUpgrade?: boolean | null, trackTag: string, pingedAt?: Date | null, synced?: boolean | null, locked?: boolean | null, repository?: { __typename?: 'Repository', id: string, name: string, icon?: string | null, darkIcon?: string | null, private?: boolean | null, trending?: boolean | null, verified?: boolean | null, category?: Category | null } | null, user?: { __typename?: 'User', id: string, name: string, email: string, avatar?: string | null, provider?: Provider | null, demoed?: boolean | null, onboarding?: OnboardingState | null, emailConfirmed?: boolean | null, emailConfirmBy?: Date | null, backgroundColor?: string | null, serviceAccount?: boolean | null, hasInstallations?: boolean | null, hasShell?: boolean | null, onboardingChecklist?: { __typename?: 'OnboardingChecklist', dismissed?: boolean | null, status?: OnboardingChecklistState | null } | null, invites?: Array<{ __typename?: 'Invite', id: string, email?: string | null } | null> | null, roles?: { __typename?: 'Roles', admin?: boolean | null } | null, groups?: Array<{ __typename?: 'Group', id: string, name: string, global?: boolean | null, description?: string | null } | null> | null, impersonationPolicy?: { __typename?: 'ImpersonationPolicy', id: string, bindings?: Array<{ __typename?: 'ImpersonationPolicyBinding', id: string, group?: { __typename?: 'Group', id: string, name: string } | null, user?: { __typename?: 'User', id: string, name: string, email: string } | null } | null> | null } | null } | null, oidcProvider?: { __typename?: 'OidcProvider', id: string, name?: string | null, description?: string | null, clientId: string, authMethod: OidcAuthMethod, clientSecret: string, redirectUris?: Array<string | null> | null, bindings?: Array<{ __typename?: 'OidcProviderBinding', id: string, user?: { __typename?: 'User', id: string, name: string, email: string, avatar?: string | null, provider?: Provider | null, demoed?: boolean | null, onboarding?: OnboardingState | null, emailConfirmed?: boolean | null, emailConfirmBy?: Date | null, backgroundColor?: string | null, serviceAccount?: boolean | null, hasInstallations?: boolean | null, hasShell?: boolean | null, onboardingChecklist?: { __typename?: 'OnboardingChecklist', dismissed?: boolean | null, status?: OnboardingChecklistState | null } | null, invites?: Array<{ __typename?: 'Invite', id: string, email?: string | null } | null> | null, roles?: { __typename?: 'Roles', admin?: boolean | null } | null, groups?: Array<{ __typename?: 'Group', id: string, name: string, global?: boolean | null, description?: string | null } | null> | null, impersonationPolicy?: { __typename?: 'ImpersonationPolicy', id: string, bindings?: Array<{ __typename?: 'ImpersonationPolicyBinding', id: string, group?: { __typename?: 'Group', id: string, name: string } | null, user?: { __typename?: 'User', id: string, name: string, email: string } | null } | null> | null } | null } | null, group?: { __typename?: 'Group', id: string, name: string, global?: boolean | null, description?: string | null } | null } | null> | null, configuration?: { __typename?: 'OuathConfiguration', issuer?: string | null, authorizationEndpoint?: string | null, tokenEndpoint?: string | null, jwksUri?: string | null, userinfoEndpoint?: string | null } | null, invites?: Array<{ __typename?: 'Invite', id: string, email?: string | null } | null> | null } | null } | null };
5490+
54895491
export type ClustersQueryVariables = Exact<{
54905492
first?: InputMaybe<Scalars['Int']['input']>;
54915493
}>;
@@ -6946,6 +6948,14 @@ export const InstallationFragmentDoc = gql`
69466948
${InstallationRepoFragmentDoc}
69476949
${UserFragmentDoc}
69486950
${OidcProviderFragmentDoc}`;
6951+
export const UpgradeInfoFragmentDoc = gql`
6952+
fragment UpgradeInfo on UpgradeInfo {
6953+
installation {
6954+
...Installation
6955+
}
6956+
count
6957+
}
6958+
${InstallationFragmentDoc}`;
69496959
export const ClusterFragmentDoc = gql`
69506960
fragment Cluster on Cluster {
69516961
id
@@ -6973,10 +6983,7 @@ export const ClusterFragmentDoc = gql`
69736983
}
69746984
}
69756985
upgradeInfo {
6976-
installation {
6977-
...Installation
6978-
}
6979-
count
6986+
...UpgradeInfo
69806987
}
69816988
dependency {
69826989
dependency {
@@ -6988,7 +6995,7 @@ export const ClusterFragmentDoc = gql`
69886995
}
69896996
${UserFragmentDoc}
69906997
${ImpersonationPolicyFragmentDoc}
6991-
${InstallationFragmentDoc}`;
6998+
${UpgradeInfoFragmentDoc}`;
69926999
export const DnsRecordFragmentDoc = gql`
69937000
fragment DnsRecord on DnsRecord {
69947001
id
@@ -13021,6 +13028,7 @@ export const namedOperations = {
1302113028
ScanError: 'ScanError',
1302213029
PackageScan: 'PackageScan',
1302313030
Cluster: 'Cluster',
13031+
UpgradeInfo: 'UpgradeInfo',
1302413032
DnsRecord: 'DnsRecord',
1302513033
DockerRepo: 'DockerRepo',
1302613034
DockerRepository: 'DockerRepository',

www/src/graph/cluster.graphql

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ fragment Cluster on Cluster {
2424
}
2525
}
2626
upgradeInfo {
27-
installation {
28-
...Installation
29-
}
30-
count
27+
...UpgradeInfo
3128
}
3229
dependency {
3330
dependency {
@@ -38,6 +35,13 @@ fragment Cluster on Cluster {
3835
}
3936
}
4037

38+
fragment UpgradeInfo on UpgradeInfo {
39+
installation {
40+
...Installation
41+
}
42+
count
43+
}
44+
4145
query Clusters($first: Int = 100) {
4246
clusters(first: $first) {
4347
pageInfo {

0 commit comments

Comments
 (0)