Skip to content

Commit

Permalink
Ensure all non-test Typescript files have < 600 lines (#1436)
Browse files Browse the repository at this point in the history
* mutations file code reduced

* Queries.ts file line reduced

* OrgList.tsx file line reduced

* Add TSDoc comments to enhance code documentation on mutations modules

* mutations.ts file reduced to 598 lines -done

* Queries.ts file line reduced to 574 line -done

* OrgList.tsx file reduced to 568 line -done

* Delete package-lock.json

* Restore Package-lock.json back to previous State

* pull-requests.yml file count line value set to 600 -done
  • Loading branch information
Sauradip07 authored Jan 15, 2024
1 parent f5fa13d commit 77b15d9
Show file tree
Hide file tree
Showing 11 changed files with 1,031 additions and 665 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Count number of lines
run: |
chmod +x ./.github/workflows/countline.py
./.github/workflows/countline.py --lines 1000 --exclude_files src/screens/LoginPage/LoginPage.tsx
./.github/workflows/countline.py --lines 600 --exclude_files src/screens/LoginPage/LoginPage.tsx
- name: Get changed TypeScript files
id: changed-files
Expand Down
58 changes: 58 additions & 0 deletions src/GraphQl/Mutations/CommentMutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import gql from 'graphql-tag';

/**
* GraphQL mutation to create a new comment on a post.
*
* @param comment - The text content of the comment.
* @param postId - The ID of the post to which the comment is being added.
* @returns The created comment object.
*/

export const CREATE_COMMENT_POST = gql`
mutation createComment($comment: String!, $postId: ID!) {
createComment(data: { text: $comment }, postId: $postId) {
_id
creator {
_id
firstName
lastName
email
}
likeCount
likedBy {
_id
}
text
}
}
`;

/**
* GraphQL mutation to like a comment.
*
* @param commentId - The ID of the comment to be liked.
* @returns The liked comment object.
*/

export const LIKE_COMMENT = gql`
mutation likeComment($commentId: ID!) {
likeComment(id: $commentId) {
_id
}
}
`;

/**
* GraphQL mutation to unlike a comment.
*
* @param commentId - The ID of the comment to be unliked.
* @returns The unliked comment object.
*/

export const UNLIKE_COMMENT = gql`
mutation unlikeComment($commentId: ID!) {
unlikeComment(id: $commentId) {
_id
}
}
`;
63 changes: 63 additions & 0 deletions src/GraphQl/Mutations/EventAttendeeMutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import gql from 'graphql-tag';

/**
* GraphQL mutation to add an attendee to an event.
*
* @param userId - The ID of the user being added as an attendee.
* @param eventId - The ID of the event to which the user is being added as an attendee.
* @returns The updated event object with the added attendee.
*/

export const ADD_EVENT_ATTENDEE = gql`
mutation addEventAttendee($userId: ID!, $eventId: ID!) {
addEventAttendee(data: { userId: $userId, eventId: $eventId }) {
_id
}
}
`;

/**
* GraphQL mutation to remove an attendee from an event.
*
* @param userId - The ID of the user being removed as an attendee.
* @param eventId - The ID of the event from which the user is being removed as an attendee.
* @returns The updated event object without the removed attendee.
*/

export const REMOVE_EVENT_ATTENDEE = gql`
mutation removeEventAttendee($userId: ID!, $eventId: ID!) {
removeEventAttendee(data: { userId: $userId, eventId: $eventId }) {
_id
}
}
`;

/**
* GraphQL mutation to mark a user's check-in at an event.
*
* @param userId - The ID of the user checking in.
* @param eventId - The ID of the event at which the user is checking in.
* @param allotedRoom - The room assigned to the user during check-in (optional).
* @param allotedSeat - The seat assigned to the user during check-in (optional).
* @returns The updated event object with the user's check-in information.
*/

export const MARK_CHECKIN = gql`
mutation checkIn(
$userId: ID!
$eventId: ID!
$allotedRoom: String
$allotedSeat: String
) {
checkIn(
data: {
userId: $userId
eventId: $eventId
allotedRoom: $allotedRoom
allotedSeat: $allotedSeat
}
) {
_id
}
}
`;
65 changes: 65 additions & 0 deletions src/GraphQl/Mutations/EventTaskMutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import gql from 'graphql-tag';

/**
* GraphQL mutation to update an event project task.
*
* @param title - The updated title of the task.
* @param description - The updated description of the task.
* @param taskId - The ID of the task to be updated.
* @param deadline - The updated deadline for the task.
* @param completed - The updated completion status of the task.
* @returns The updated task object.
*/

export const UPDATE_EVENT_PROJECT_TASK_MUTATION = gql`
mutation UpdateEventTask(
$title: String!
$description: String!
$taskId: ID!
$deadline: DateTime!
$completed: Boolean!
) {
updateTask(
id: $taskId
data: {
title: $title
description: $description
deadline: $deadline
completed: $completed
}
) {
_id
}
}
`;

/**
* GraphQL mutation to delete an event project task.
*
* @param id - The ID of the task to be deleted.
* @returns The deleted task object.
*/

export const DELETE_EVENT_TASK_MUTATION = gql`
mutation DeleteTask($id: ID!) {
removeTask(id: $id) {
_id
}
}
`;

/**
* GraphQL mutation to set volunteers for an event project task.
*
* @param id - The ID of the task for which volunteers are being set.
* @param volunteers - An array of user IDs representing the volunteers for the task.
* @returns The updated task object with the assigned volunteers.
*/

export const SET_TASK_VOLUNTEERS_MUTATION = gql`
mutation SetTaskVolunteers($id: ID!, $volunteers: [ID]!) {
setTaskVolunteers(id: $id, volunteers: $volunteers) {
_id
}
}
`;
145 changes: 145 additions & 0 deletions src/GraphQl/Mutations/OrganizationMutations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import gql from 'graphql-tag';

// Changes the role of a user in an organization
/**
* GraphQL mutation to update the role of a user in an organization.
*
* @param organizationId - The ID of the organization in which the user's role is being updated.
* @param userId - The ID of the user whose role is being updated.
* @param role - The new role to be assigned to the user in the organization.
* @returns The updated user object with the new role in the organization.
*/
export const UPDATE_USER_ROLE_IN_ORG_MUTATION = gql`
mutation updateUserRoleInOrganization(
$organizationId: ID!
$userId: ID!
$role: String!
) {
updateUserRoleInOrganization(
organizationId: $organizationId
userId: $userId
role: $role
) {
_id
}
}
`;

/**
* GraphQL mutation to create a sample organization.
*
* @returns The created sample organization object.
*/

export const CREATE_SAMPLE_ORGANIZATION_MUTATION = gql`
mutation {
createSampleOrganization
}
`;

/**
* GraphQL mutation to remove a sample organization.
*
* @returns The removed sample organization object.
*/

export const REMOVE_SAMPLE_ORGANIZATION_MUTATION = gql`
mutation {
removeSampleOrganization
}
`;

/**
* GraphQL mutation to create a direct chat between users in an organization.
*
* @param userIds - An array of user IDs participating in the direct chat.
* @param organizationId - The ID of the organization where the direct chat is created.
* @returns The created direct chat object.
*/

export const CREATE_DIRECT_CHAT = gql`
mutation createDirectChat($userIds: [ID!]!, $organizationId: ID!) {
createDirectChat(
data: { userIds: $userIds, organizationId: $organizationId }
) {
_id
}
}
`;
//Plugin WebSocket listner

/**
* GraphQL subscription to listen for updates on plugins.
*
* @returns An object containing information about the updated plugin.
*/

export const PLUGIN_SUBSCRIPTION = gql`
subscription onPluginUpdate {
onPluginUpdate {
pluginName
_id
pluginDesc
uninstalledOrgs
}
}
`;

/**
* GraphQL mutation to toggle the pinned status of a post.
*
* @param id - The ID of the post to be toggled.
* @returns The updated post object with the new pinned status.
*/

export const TOGGLE_PINNED_POST = gql`
mutation TogglePostPin($id: ID!) {
togglePostPin(id: $id) {
_id
}
}
`;

/**
* GraphQL mutation to add a custom field to an organization.
*
* @param organizationId - The ID of the organization where the custom field is being added.
* @param type - The type of the custom field (e.g., String, Number).
* @param name - The name of the custom field.
* @returns The added organization custom field object.
*/

export const ADD_CUSTOM_FIELD = gql`
mutation ($organizationId: ID!, $type: String!, $name: String!) {
addOrganizationCustomField(
organizationId: $organizationId
type: $type
name: $name
) {
name
type
}
}
`;

// Handles custom organization fields

/**
* GraphQL mutation to remove a custom field from an organization.
*
* @param organizationId - The ID of the organization from which the custom field is being removed.
* @param customFieldId - The ID of the custom field to be removed.
* @returns The removed organization custom field object.
*/

export const REMOVE_CUSTOM_FIELD = gql`
mutation ($organizationId: ID!, $customFieldId: ID!) {
removeOrganizationCustomField(
organizationId: $organizationId
customFieldId: $customFieldId
) {
type
name
}
}
`;
Loading

0 comments on commit 77b15d9

Please sign in to comment.