Skip to content

Commit 26be776

Browse files
committed
feat: integration gql mutation
1 parent b9c73ff commit 26be776

File tree

4 files changed

+109
-1
lines changed

4 files changed

+109
-1
lines changed

packages/app/src/app/components/WorkspaceSetup/steps/SelectUsecases.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import styled from 'styled-components';
55
import { StepHeader } from '../StepHeader';
66
import { AnimatedStep } from '../elements';
77
import { StepProps } from '../types';
8+
import { useAppState, useEffects } from 'app/overmind';
89

910
const USE_CASES = [
1011
'Conduct interviews',
@@ -25,6 +26,8 @@ export const SelectUsecases: React.FC<StepProps> = ({
2526
currentStep,
2627
numberOfSteps,
2728
}) => {
29+
const { activeTeam } = useAppState();
30+
const effects = useEffects();
2831
const [usecases, setUsecases] = useState<Record<string, boolean>>(
2932
USE_CASES.reduce((res, usecase) => {
3033
res[usecase] = false;
@@ -34,7 +37,13 @@ export const SelectUsecases: React.FC<StepProps> = ({
3437

3538
const handleSubmit = async e => {
3639
e.preventDefault();
37-
console.log('submit', usecases);
40+
const selectedUseCases = Object.keys(usecases).filter(k => usecases[k]);
41+
if (selectedUseCases.length > 0) {
42+
effects.gql.mutations.setTeamMetadata({
43+
teamId: activeTeam,
44+
useCases: selectedUseCases,
45+
});
46+
}
3847
onNextStep();
3948
};
4049

packages/app/src/app/graphql/types.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ export type Team = {
390390
legacy: Scalars['Boolean'];
391391
limits: TeamLimits;
392392
members: Array<TeamMember>;
393+
/** Additional user-provided metadata about the workspace */
394+
metadata: TeamMetadata;
393395
name: Scalars['String'];
394396
privateRegistry: Maybe<PrivateRegistry>;
395397
/**
@@ -535,6 +537,13 @@ export type TeamMember = {
535537
username: Scalars['String'];
536538
};
537539

540+
/** Additional user-provided metadata about a workspace */
541+
export type TeamMetadata = {
542+
__typename?: 'TeamMetadata';
543+
/** Use-cases for the workspace provided during creation */
544+
useCases: Array<Scalars['String']>;
545+
};
546+
538547
/** A private package registry */
539548
export type PrivateRegistry = {
540549
__typename?: 'PrivateRegistry';
@@ -2071,6 +2080,8 @@ export type RootMutationType = {
20712080
setTeamDescription: Team;
20722081
/** Set user-editable limits for the workspace */
20732082
setTeamLimits: Scalars['String'];
2083+
/** Set user-provided metadata about the workspace */
2084+
setTeamMetadata: Team;
20742085
/** Set minimum privacy level for workspace */
20752086
setTeamMinimumPrivacy: WorkspaceSandboxSettings;
20762087
/** Set the name of the team */
@@ -2595,6 +2606,11 @@ export type RootMutationTypeSetTeamLimitsArgs = {
25952606
teamId: Scalars['UUID4'];
25962607
};
25972608

2609+
export type RootMutationTypeSetTeamMetadataArgs = {
2610+
metadata: TeamMetadataInput;
2611+
teamId: Scalars['UUID4'];
2612+
};
2613+
25982614
export type RootMutationTypeSetTeamMinimumPrivacyArgs = {
25992615
minimumPrivacy: Scalars['Int'];
26002616
teamId: Scalars['UUID4'];
@@ -2812,6 +2828,12 @@ export type BillingDetails = {
28122828
date: Scalars['String'];
28132829
};
28142830

2831+
/** Additional user-provided metadata about a workspace */
2832+
export type TeamMetadataInput = {
2833+
/** Use-cases for the workspace */
2834+
useCases: Array<Scalars['String']>;
2835+
};
2836+
28152837
export type RootSubscriptionType = {
28162838
__typename?: 'RootSubscriptionType';
28172839
/** Receive updates for events related to the specified branch. */
@@ -4792,6 +4814,7 @@ export type CurrentTeamInfoFragmentFragment = {
47924814
ubbBeta: boolean;
47934815
friendOfCsb: boolean;
47944816
};
4817+
metadata: { __typename?: 'TeamMetadata'; useCases: Array<string> };
47954818
};
47964819

47974820
export type BranchFragment = {
@@ -5603,6 +5626,63 @@ export type UpdateProjectVmTierMutation = {
56035626
};
56045627
};
56055628

5629+
export type SetTeamMetadataMutationVariables = Exact<{
5630+
teamId: Scalars['UUID4'];
5631+
useCases: Array<Scalars['String']> | Scalars['String'];
5632+
}>;
5633+
5634+
export type SetTeamMetadataMutation = {
5635+
__typename?: 'RootMutationType';
5636+
setTeamMetadata: {
5637+
__typename?: 'Team';
5638+
id: any;
5639+
name: string;
5640+
type: TeamType;
5641+
description: string | null;
5642+
creatorId: any | null;
5643+
avatarUrl: string | null;
5644+
legacy: boolean;
5645+
frozen: boolean;
5646+
insertedAt: string;
5647+
settings: {
5648+
__typename?: 'WorkspaceSandboxSettings';
5649+
minimumPrivacy: number;
5650+
} | null;
5651+
userAuthorizations: Array<{
5652+
__typename?: 'UserAuthorization';
5653+
userId: any;
5654+
authorization: TeamMemberAuthorization;
5655+
teamManager: boolean;
5656+
}>;
5657+
users: Array<{
5658+
__typename?: 'User';
5659+
id: any;
5660+
name: string | null;
5661+
username: string;
5662+
avatarUrl: string;
5663+
}>;
5664+
invitees: Array<{
5665+
__typename?: 'User';
5666+
id: any;
5667+
name: string | null;
5668+
username: string;
5669+
avatarUrl: string;
5670+
}>;
5671+
subscription: {
5672+
__typename?: 'ProSubscription';
5673+
origin: SubscriptionOrigin | null;
5674+
type: SubscriptionType;
5675+
status: SubscriptionStatus;
5676+
paymentProvider: SubscriptionPaymentProvider | null;
5677+
} | null;
5678+
featureFlags: {
5679+
__typename?: 'TeamFeatureFlags';
5680+
ubbBeta: boolean;
5681+
friendOfCsb: boolean;
5682+
};
5683+
};
5684+
};
5685+
56065686
export type RecentlyDeletedTeamSandboxesQueryVariables = Exact<{
56075687
teamId: Scalars['UUID4'];
56085688
}>;
@@ -6305,6 +6385,7 @@ export type GetTeamQuery = {
63056385
ubbBeta: boolean;
63066386
friendOfCsb: boolean;
63076387
};
6388+
metadata: { __typename?: 'TeamMetadata'; useCases: Array<string> };
63086389
} | null;
63096390
} | null;
63106391
};

packages/app/src/app/overmind/effects/gql/dashboard/fragments.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ export const currentTeamInfoFragment = gql`
268268
ubbBeta
269269
friendOfCsb
270270
}
271+
272+
metadata {
273+
useCases
274+
}
271275
}
272276
`;
273277

packages/app/src/app/overmind/effects/gql/dashboard/mutations.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ import {
6161
UpdateProjectVmTierMutation,
6262
UpdateUsageSubscriptionMutationVariables,
6363
UpdateUsageSubscriptionMutation,
64+
SetTeamMetadataMutation,
65+
SetTeamMetadataMutationVariables,
6466
} from 'app/graphql/types';
6567
import { gql, Query } from 'overmind-graphql';
6668

@@ -476,3 +478,15 @@ export const updateProjectVmTier: Query<
476478
}
477479
}
478480
`;
481+
482+
export const setTeamMetadata: Query<
483+
SetTeamMetadataMutation,
484+
SetTeamMetadataMutationVariables
485+
> = gql`
486+
mutation SetTeamMetadata($teamId: UUID4!, $useCases: [String!]!) {
487+
setTeamMetadata(teamId: $teamId, metadata: { useCases: $useCases }) {
488+
...teamFragmentDashboard
489+
}
490+
}
491+
${teamFragmentDashboard}
492+
`;

0 commit comments

Comments
 (0)