From 1edbfe4f21fc0d8b0d2f96392bb3bd0371694449 Mon Sep 17 00:00:00 2001 From: Sboonny <88248797+Sboonny@users.noreply.github.com> Date: Mon, 13 Mar 2023 08:41:59 +0200 Subject: [PATCH] remove resolver and the logic around it --- client/graphql.schema.json | 159 ------------------ client/src/generated/graphql.tsx | 159 ------------------ .../InstanceSettings/graphql/mutations.ts | 11 -- .../InstanceSettings/graphql/queries.ts | 12 -- common/permissions.ts | 2 - .../src/controllers/InstanceSettings/input.ts | 14 -- .../controllers/InstanceSettings/resolver.ts | 29 ---- server/src/controllers/index.ts | 2 - server/src/graphql-types/InstanceSettings.ts | 14 -- server/src/graphql-types/index.ts | 1 - 10 files changed, 403 deletions(-) delete mode 100644 client/src/modules/dashboard/InstanceSettings/graphql/mutations.ts delete mode 100644 client/src/modules/dashboard/InstanceSettings/graphql/queries.ts delete mode 100644 server/src/controllers/InstanceSettings/input.ts delete mode 100644 server/src/controllers/InstanceSettings/resolver.ts delete mode 100644 server/src/graphql-types/InstanceSettings.ts diff --git a/client/graphql.schema.json b/client/graphql.schema.json index 04e17869b1..7837bab751 100644 --- a/client/graphql.schema.json +++ b/client/graphql.schema.json @@ -3826,116 +3826,6 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "OBJECT", - "name": "InstanceSettings", - "description": null, - "fields": [ - { - "name": "code_of_conduct_url", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "policy_url", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "terms_of_services_url", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "InstanceSettingsInputs", - "description": null, - "fields": null, - "inputFields": [ - { - "name": "code_of_conduct_url", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "policy_url", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "terms_of_services_url", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, { "kind": "SCALAR", "name": "Int", @@ -5139,39 +5029,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "updateInstanceSettings", - "description": null, - "args": [ - { - "name": "data", - "description": null, - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "InstanceSettingsInputs", - "ofType": null - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "InstanceSettings", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "updateMe", "description": null, @@ -5788,22 +5645,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "instanceSettings", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "InstanceSettings", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, { "name": "me", "description": null, diff --git a/client/src/generated/graphql.tsx b/client/src/generated/graphql.tsx index 3ac2293631..d7bc73f251 100644 --- a/client/src/generated/graphql.tsx +++ b/client/src/generated/graphql.tsx @@ -365,20 +365,6 @@ export type InstanceRolePermission = { instance_permission: InstancePermission; }; -export type InstanceSettings = { - __typename?: 'InstanceSettings'; - code_of_conduct_url?: Maybe; - id: Scalars['Int']; - policy_url?: Maybe; - terms_of_services_url?: Maybe; -}; - -export type InstanceSettingsInputs = { - code_of_conduct_url?: InputMaybe; - policy_url?: InputMaybe; - terms_of_services_url?: InputMaybe; -}; - export type Mutation = { __typename?: 'Mutation'; attendEvent: EventUserWithRelations; @@ -412,7 +398,6 @@ export type Mutation = { unsubscribeFromEvent: EventUser; updateChapter: Chapter; updateEvent: Event; - updateInstanceSettings: InstanceSettings; updateMe: User; updateSponsor: Sponsor; updateVenue: Venue; @@ -544,10 +529,6 @@ export type MutationUpdateEventArgs = { id: Scalars['Int']; }; -export type MutationUpdateInstanceSettingsArgs = { - data: InstanceSettingsInputs; -}; - export type MutationUpdateMeArgs = { data: UpdateUserInputs; }; @@ -586,7 +567,6 @@ export type Query = { event?: Maybe; eventRoles: Array; instanceRoles: Array; - instanceSettings: InstanceSettings; me?: Maybe; paginatedEventsWithTotal: PaginatedEventsWithChapters; sponsorWithEvents: SponsorWithEvents; @@ -1472,33 +1452,6 @@ export type ChapterVenuesQuery = { chapterVenues: Array<{ __typename?: 'Venue'; id: number; name: string }>; }; -export type UpdateInstanceSettingsMutationVariables = Exact<{ - data: InstanceSettingsInputs; -}>; - -export type UpdateInstanceSettingsMutation = { - __typename?: 'Mutation'; - updateInstanceSettings: { - __typename?: 'InstanceSettings'; - policy_url?: string | null; - terms_of_services_url?: string | null; - code_of_conduct_url?: string | null; - }; -}; - -export type InstanceSettingsQueryVariables = Exact<{ [key: string]: never }>; - -export type InstanceSettingsQuery = { - __typename?: 'Query'; - instanceSettings: { - __typename?: 'InstanceSettings'; - id: number; - policy_url?: string | null; - terms_of_services_url?: string | null; - code_of_conduct_url?: string | null; - }; -}; - export type CreateSponsorMutationVariables = Exact<{ data: CreateSponsorInputs; }>; @@ -4145,118 +4098,6 @@ export type ChapterVenuesQueryResult = Apollo.QueryResult< ChapterVenuesQuery, ChapterVenuesQueryVariables >; -export const UpdateInstanceSettingsDocument = gql` - mutation updateInstanceSettings($data: InstanceSettingsInputs!) { - updateInstanceSettings(data: $data) { - policy_url - terms_of_services_url - code_of_conduct_url - } - } -`; -export type UpdateInstanceSettingsMutationFn = Apollo.MutationFunction< - UpdateInstanceSettingsMutation, - UpdateInstanceSettingsMutationVariables ->; - -/** - * __useUpdateInstanceSettingsMutation__ - * - * To run a mutation, you first call `useUpdateInstanceSettingsMutation` within a React component and pass it any options that fit your needs. - * When your component renders, `useUpdateInstanceSettingsMutation` returns a tuple that includes: - * - A mutate function that you can call at any time to execute the mutation - * - An object with fields that represent the current status of the mutation's execution - * - * @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2; - * - * @example - * const [updateInstanceSettingsMutation, { data, loading, error }] = useUpdateInstanceSettingsMutation({ - * variables: { - * data: // value for 'data' - * }, - * }); - */ -export function useUpdateInstanceSettingsMutation( - baseOptions?: Apollo.MutationHookOptions< - UpdateInstanceSettingsMutation, - UpdateInstanceSettingsMutationVariables - >, -) { - const options = { ...defaultOptions, ...baseOptions }; - return Apollo.useMutation< - UpdateInstanceSettingsMutation, - UpdateInstanceSettingsMutationVariables - >(UpdateInstanceSettingsDocument, options); -} -export type UpdateInstanceSettingsMutationHookResult = ReturnType< - typeof useUpdateInstanceSettingsMutation ->; -export type UpdateInstanceSettingsMutationResult = - Apollo.MutationResult; -export type UpdateInstanceSettingsMutationOptions = Apollo.BaseMutationOptions< - UpdateInstanceSettingsMutation, - UpdateInstanceSettingsMutationVariables ->; -export const InstanceSettingsDocument = gql` - query instanceSettings { - instanceSettings { - id - policy_url - terms_of_services_url - code_of_conduct_url - } - } -`; - -/** - * __useInstanceSettingsQuery__ - * - * To run a query within a React component, call `useInstanceSettingsQuery` and pass it any options that fit your needs. - * When your component renders, `useInstanceSettingsQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useInstanceSettingsQuery({ - * variables: { - * }, - * }); - */ -export function useInstanceSettingsQuery( - baseOptions?: Apollo.QueryHookOptions< - InstanceSettingsQuery, - InstanceSettingsQueryVariables - >, -) { - const options = { ...defaultOptions, ...baseOptions }; - return Apollo.useQuery( - InstanceSettingsDocument, - options, - ); -} -export function useInstanceSettingsLazyQuery( - baseOptions?: Apollo.LazyQueryHookOptions< - InstanceSettingsQuery, - InstanceSettingsQueryVariables - >, -) { - const options = { ...defaultOptions, ...baseOptions }; - return Apollo.useLazyQuery< - InstanceSettingsQuery, - InstanceSettingsQueryVariables - >(InstanceSettingsDocument, options); -} -export type InstanceSettingsQueryHookResult = ReturnType< - typeof useInstanceSettingsQuery ->; -export type InstanceSettingsLazyQueryHookResult = ReturnType< - typeof useInstanceSettingsLazyQuery ->; -export type InstanceSettingsQueryResult = Apollo.QueryResult< - InstanceSettingsQuery, - InstanceSettingsQueryVariables ->; export const CreateSponsorDocument = gql` mutation createSponsor($data: CreateSponsorInputs!) { createSponsor(data: $data) { diff --git a/client/src/modules/dashboard/InstanceSettings/graphql/mutations.ts b/client/src/modules/dashboard/InstanceSettings/graphql/mutations.ts deleted file mode 100644 index c7d25ec89a..0000000000 --- a/client/src/modules/dashboard/InstanceSettings/graphql/mutations.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { gql } from '@apollo/client'; - -export const updateInstanceSettings = gql` - mutation updateInstanceSettings($data: InstanceSettingsInputs!) { - updateInstanceSettings(data: $data) { - policy_url - terms_of_services_url - code_of_conduct_url - } - } -`; diff --git a/client/src/modules/dashboard/InstanceSettings/graphql/queries.ts b/client/src/modules/dashboard/InstanceSettings/graphql/queries.ts deleted file mode 100644 index bb50537da1..0000000000 --- a/client/src/modules/dashboard/InstanceSettings/graphql/queries.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { gql } from '@apollo/client'; - -export const INSTANCE_SETTINGS = gql` - query instanceSettings { - instanceSettings { - id - policy_url - terms_of_services_url - code_of_conduct_url - } - } -`; diff --git a/common/permissions.ts b/common/permissions.ts index 24fb609ace..9e9c3d4494 100644 --- a/common/permissions.ts +++ b/common/permissions.ts @@ -28,8 +28,6 @@ export enum InstancePermission { UserInstanceRoleChange = 'user-instance-role-change', GoogleAuthenticate = 'google-authenticate', UsersView = 'users-view', - SettingView = 'setting-view', - SettingManage = 'setting-manage', } // Ideally this would be a new enum, but TS does not (to my knowledge) support diff --git a/server/src/controllers/InstanceSettings/input.ts b/server/src/controllers/InstanceSettings/input.ts deleted file mode 100644 index 1fdee066c1..0000000000 --- a/server/src/controllers/InstanceSettings/input.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Field, InputType } from 'type-graphql'; -import { InstanceSettings } from '../../graphql-types/InstanceSettings'; - -@InputType() -export class InstanceSettingsInputs implements Omit { - @Field(() => String, { nullable: true }) - policy_url: string; - - @Field(() => String, { nullable: true }) - terms_of_services_url: string; - - @Field(() => String, { nullable: true }) - code_of_conduct_url: string; -} diff --git a/server/src/controllers/InstanceSettings/resolver.ts b/server/src/controllers/InstanceSettings/resolver.ts deleted file mode 100644 index b00d094d9f..0000000000 --- a/server/src/controllers/InstanceSettings/resolver.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Prisma } from '@prisma/client'; -import { Arg, Authorized, Mutation, Query, Resolver } from 'type-graphql'; -import { Permission } from '../../../../common/permissions'; -import { InstanceSettings } from '../../graphql-types/InstanceSettings'; -import { prisma } from '../../prisma'; -import { InstanceSettingsInputs } from './input'; - -@Resolver() -export class InctanceSettingsResolver { - @Query(() => InstanceSettings) - async instanceSettings(): Promise { - return await prisma.instance_settings.findUniqueOrThrow({ - where: { id: 1 }, - }); - } - - @Authorized(Permission.SettingManage) - @Mutation(() => InstanceSettings) - async updateInstanceSettings( - @Arg('data') data: InstanceSettingsInputs, - ): Promise { - const instanceSettingData: Prisma.instance_settingsUpdateInput = data; - - return await prisma.instance_settings.update({ - where: { id: 1 }, - data: instanceSettingData, - }); - } -} diff --git a/server/src/controllers/index.ts b/server/src/controllers/index.ts index cfa2ab1312..0a0581fe4a 100644 --- a/server/src/controllers/index.ts +++ b/server/src/controllers/index.ts @@ -12,7 +12,6 @@ import { VenueResolver } from './Venue/resolver'; import { UnsubscribeResolver } from './Unsubscribe/resolver'; import { UsersResolver } from './Users/resolver'; import { UserWithPermissionsResolver } from './User/resolver'; -import { InctanceSettingsResolver } from './InstanceSettings/resolver'; const resolvers = [ AuthResolver, @@ -29,7 +28,6 @@ const resolvers = [ UnsubscribeResolver, UsersResolver, UserWithPermissionsResolver, - InctanceSettingsResolver, ] as const; export { resolvers }; diff --git a/server/src/graphql-types/InstanceSettings.ts b/server/src/graphql-types/InstanceSettings.ts deleted file mode 100644 index 38e42a4d68..0000000000 --- a/server/src/graphql-types/InstanceSettings.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Field, ObjectType } from 'type-graphql'; -import { BaseObject } from './BaseObject'; - -@ObjectType() -export class InstanceSettings extends BaseObject { - @Field(() => String, { nullable: true }) - policy_url: string | null; - - @Field(() => String, { nullable: true }) - terms_of_services_url: string | null; - - @Field(() => String, { nullable: true }) - code_of_conduct_url: string | null; -} diff --git a/server/src/graphql-types/index.ts b/server/src/graphql-types/index.ts index cae5440dea..45b6e7a57c 100644 --- a/server/src/graphql-types/index.ts +++ b/server/src/graphql-types/index.ts @@ -14,4 +14,3 @@ export * from './TokenStatus'; export * from './User'; export * from './UserBan'; export * from './Venue'; -export * from './InstanceSettings';