Skip to content

Commit

Permalink
fix: Ensure OIDC provider UI can handle OIDC providers w/o installati…
Browse files Browse the repository at this point in the history
…ons (#1375)
  • Loading branch information
maciaszczykm authored Oct 8, 2024
1 parent 4736a67 commit 77523a9
Show file tree
Hide file tree
Showing 39 changed files with 900 additions and 779 deletions.
2 changes: 1 addition & 1 deletion www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@nivo/geo": "0.83.0",
"@nivo/line": "0.83.0",
"@octokit/core": "4.2.1",
"@pluralsh/design-system": "3.74.2",
"@pluralsh/design-system": "3.74.3",
"@react-spring/web": "9.7.3",
"@stripe/react-stripe-js": "2.1.0",
"@stripe/stripe-js": "1.54.0",
Expand Down
1 change: 0 additions & 1 deletion www/src/components/account/Roles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function Role({ role, q }: any) {
<Box
fill="horizontal"
direction="row"
align="center"
>
<Info
text={role.name}
Expand Down
2 changes: 1 addition & 1 deletion www/src/components/account/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function UserInfo({
size="xsmall"
hue={hue}
/>
<Box>
<Box align="start">
<Span fontWeight="bold">{name}</Span>
<Span
color="text-light"
Expand Down
55 changes: 0 additions & 55 deletions www/src/components/account/billing/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,6 @@ export const PLATFORM_PLANS_QUERY = gql`
}
`

export const SUBSCRIPTION_QUERY = gql`
query Subscription {
account {
billingCustomerId
grandfatheredUntil
delinquentAt
userCount
clusterCount
trialed
availableFeatures {
userManagement
audit
}
subscription {
id
trialUntil
plan {
id
period
lineItems {
dimension
cost
}
name
}
}
billingAddress {
name
line1
line2
zip
state
city
country
}
}
}
`

export const UPDATE_ACCOUNT_BILLING_MUTATION = gql`
mutation UpdateAccountBilling($attributes: AccountAttributes!) {
updateAccount(attributes: $attributes) {
id
}
}
`

export const UPGRADE_TO_PROFESSIONAL_PLAN_MUTATION = gql`
mutation UpgradeToProfessionalPlan($planId: ID!) {
createPlatformSubscription(planId: $planId) {
id
}
}
`

export const DOWNGRADE_TO_FREE_PLAN_MUTATION = gql`
mutation DowngradeToFreePlanMutation {
deletePlatformSubscription {
Expand Down
45 changes: 0 additions & 45 deletions www/src/components/account/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
DnsDomainFragment,
DnsRecordFragment,
InviteFragment,
OidcLoginFragment,
} from '../../models/account'
import { PageInfo } from '../../models/misc'
import {
Expand Down Expand Up @@ -82,15 +81,6 @@ export const SEARCH_GROUPS = gql`
${GroupFragment}
`

export const EDIT_USER = gql`
mutation UpdateUser($id: ID, $attributes: UserAttributes!) {
updateUser(id: $id, attributes: $attributes) {
...UserFragment
}
}
${UserFragment}
`

export const CREATE_INVITE = gql`
mutation CreateInvite($attributes: InviteAttributes!) {
createInvite(attributes: $attributes) {
Expand Down Expand Up @@ -187,41 +177,6 @@ export const AUDITS_Q = gql`
${AuditFragment}
`

export const LOGINS_Q = gql`
query Logins($cursor: String) {
oidcLogins(first: 50, after: $cursor) {
pageInfo {
...PageInfo
}
edges {
node {
...OidcLoginFragment
}
}
}
}
${PageInfo}
${OidcLoginFragment}
`

export const AUDIT_METRICS = gql`
query {
auditMetrics {
country
count
}
}
`

export const LOGIN_METRICS = gql`
query {
loginMetrics {
country
count
}
}
`

export const IMPERSONATE_SERVICE_ACCOUNT = gql`
mutation Impersonate($id: ID) {
impersonateServiceAccount(id: $id) {
Expand Down
14 changes: 8 additions & 6 deletions www/src/components/app/oidc/OIDC.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMutation } from '@apollo/client'
import {
Card,
CheckIcon,
Expand Down Expand Up @@ -33,13 +32,16 @@ import { deepUpdate, updateCache } from '../../../utils/graphql'
import InviteUserModal from '../../account/invite/InviteUserModal'
import { BindingInput, fetchGroups, fetchUsers } from '../../account/Typeaheads'
import { sanitize } from '../../account/utils'
import { CREATE_PROVIDER, UPDATE_PROVIDER } from '../../oidc/queries'
import { AuthMethod } from '../../oidc/types'
import { REPO_Q } from '../../repository/packages/queries'
import { GqlError } from '../../utils/Alert'
import CreateGroupModal from '../../utils/group/CreateGroupModal'
import ImpersonateServiceAccount from '../../utils/ImpersonateServiceAccount'
import { AppHeaderActions } from '../AppHeaderActions'
import {
useCreateProviderMutation,
useUpdateProviderMutation,
} from '../../../generated/graphql'

export function UrlsInput({ uriFormat = '', urls, setUrls }: any) {
const [baseScheme, basePath] = ['https://', '/oauth2/callback']
Expand Down Expand Up @@ -310,20 +312,20 @@ export function CreateProvider({ installation }: any) {
authMethod: settings.authMethod || AuthMethod.POST,
})
const [bindings, setBindings] = useState([])
const [mutation, { loading, error }] = useMutation(CREATE_PROVIDER, {
const [mutation, { loading, error }] = useCreateProviderMutation({
variables: {
id: installation.id,
attributes: { ...attributes, bindings: bindings.map(sanitize) },
},
update: (cache, { data: { createOidcProvider } }) =>
update: (cache, { data }) =>
updateCache(cache, {
query: REPO_Q,
variables: { repositoryId: installation.repository.id },
update: (prev) =>
deepUpdate(
prev,
'repository.installation.oidcProvider',
() => createOidcProvider
() => data?.createOidcProvider
),
}),
})
Expand Down Expand Up @@ -380,7 +382,7 @@ export function UpdateProvider({ installation }: any) {
ModalSelection.None
)

const [mutation, { loading, error }] = useMutation(UPDATE_PROVIDER, {
const [mutation, { loading, error }] = useUpdateProviderMutation({
variables: {
id: installation.id,
attributes: {
Expand Down
31 changes: 0 additions & 31 deletions www/src/components/app/queries.ts

This file was deleted.

19 changes: 1 addition & 18 deletions www/src/components/audits/queries.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
import { gql } from '@apollo/client'

import { AuditFragment, OidcLoginFragment } from '../../models/account'
import { OidcLoginFragment } from '../../models/account'
import { PageInfo } from '../../models/misc'

export const AUDITS_Q = gql`
query Audits($cursor: String) {
audits(first: 50, after: $cursor) {
pageInfo {
...PageInfo
}
edges {
node {
...AuditFragment
}
}
}
}
${PageInfo}
${AuditFragment}
`

export const LOGINS_Q = gql`
query Logins($cursor: String) {
oidcLogins(first: 50, after: $cursor) {
Expand Down
Loading

0 comments on commit 77523a9

Please sign in to comment.