Skip to content

Commit d6cf026

Browse files
authored
fix: correct selecting "all" app deployments when creating an access token (#6924)
1 parent d5218b8 commit d6cf026

6 files changed

Lines changed: 47 additions & 23 deletions

File tree

.changeset/late-rules-fail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': patch
3+
---
4+
5+
Fix selecting "All" app deployments in target when creating an access token

packages/services/api/src/modules/organization/resolvers/Organization.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,12 @@ export const Organization: Pick<
207207
availableMemberPermissionGroups: () => {
208208
return OrganizationMemberPermissions.permissionGroups;
209209
},
210-
availableOrganizationAccessTokenPermissionGroups: () => {
211-
return OrganizationAccessTokensPermissions.permissionGroups;
210+
availableOrganizationAccessTokenPermissionGroups: async organization => {
211+
const permissionGroups = OrganizationAccessTokensPermissions.permissionGroups;
212+
if (!organization.featureFlags.appDeployments) {
213+
return permissionGroups.filter(p => p.id !== 'app-deployments');
214+
}
215+
return permissionGroups;
212216
},
213217
accessTokens: async (organization, args, { injector }) => {
214218
return injector.get(OrganizationAccessTokens).getPaginated({

packages/web/app/src/components/organization/members/resource-selector.tsx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ export function ResourceSelector(props: {
517517
const targetId = targetState.activeTarget.targetSelection.targetId;
518518

519519
if (
520-
targetState.activeTarget.targetSelection.services.mode ===
520+
targetState.activeTarget.targetSelection.appDeployments.mode ===
521521
GraphQLSchema.ResourceAssignmentModeType.All
522522
) {
523523
return {
@@ -700,25 +700,30 @@ export function ResourceSelector(props: {
700700
)}
701701
</span>
702702
{/** Service All / Granular Toggle */}
703-
{serviceState && serviceState !== 'none' && (
704-
<div className="ml-auto text-xs">
705-
<button
706-
className={cn(serviceState.selection !== '*' && 'text-orange-500')}
707-
onClick={serviceState.setGranular}
708-
>
709-
Select
710-
</button>
711-
{' / '}
712-
<button
713-
className={cn('mr-1', serviceState.selection === '*' && 'text-orange-500')}
714-
onClick={serviceState.setAll}
715-
>
716-
All
717-
</button>
718-
</div>
719-
)}
703+
{serviceState &&
704+
serviceState !== 'none' &&
705+
serviceAppsState === ServicesAppsState.service && (
706+
<div className="ml-auto text-xs">
707+
<button
708+
className={cn(serviceState.selection !== '*' && 'text-orange-500')}
709+
onClick={serviceState.setGranular}
710+
>
711+
Select
712+
</button>
713+
{' / '}
714+
<button
715+
className={cn(
716+
'mr-1',
717+
serviceState.selection === '*' && 'text-orange-500',
718+
)}
719+
onClick={serviceState.setAll}
720+
>
721+
All
722+
</button>
723+
</div>
724+
)}
720725
{/** Apps All / Granular Toggle */}
721-
{appsState && (
726+
{appsState && serviceAppsState === ServicesAppsState.apps && (
722727
<div className="ml-auto text-xs">
723728
<button
724729
className={cn(appsState.selection !== '*' && 'text-orange-500')}
@@ -949,7 +954,7 @@ export function ResourceSelector(props: {
949954
</div>
950955
) : appsState.selection === '*' ? (
951956
<div className="text-muted-foreground px-2 text-xs">
952-
Access to all services in target granted.
957+
Access to all apps in target granted.
953958
</div>
954959
) : (
955960
<>

packages/web/app/src/components/organization/settings/access-tokens/create-access-token-sheet-content.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ export function CreateAccessTokenSheetContent(
171171
}
172172
return;
173173
}
174+
if (result.error) {
175+
toast({
176+
variant: 'destructive',
177+
title: 'An error occured',
178+
description: 'Something went wrong. Try again later.',
179+
});
180+
return;
181+
}
174182
}
175183

176184
return (

packages/web/docs/src/content/gateway/logging-and-error-handling.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ only log info, warn and error messages.
7474
By default, Hive Gateway uses the built-in `console` logger. However, you can also integrate Hive
7575
Gateway with [Winston](https://github.com/winstonjs/winston) on Node.js environments.
7676

77-
You need to install `winston` and `@graphql-hive/logger-winston` packages to use Winston with Hive Gateway.
77+
You need to install `winston` and `@graphql-hive/logger-winston` packages to use Winston with Hive
78+
Gateway.
7879

7980
```sh npm2yarn
8081
npm i winston @graphql-hive/logger-winston

pnpm-lock.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)