<commit_before>/*
 * Copyright (C) 2021 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

import {arrayOf, bool, number, shape, string} from 'prop-types'
import {Assignment} from './Assignment'
import {Attachment} from './Attachment'
import {Section} from './Section'
import {DiscussionPermissions} from './DiscussionPermissions'
import gql from 'graphql-tag'
import {User} from './User'
import {DiscussionEntry} from './DiscussionEntry'
import {DiscussionEntryDraft} from './DiscussionEntryDraft'
import {PageInfo} from './PageInfo'
import {ChildTopic} from './ChildTopic'
import {RootTopic} from './RootTopic'
import {GroupSet} from './GroupSet'

export const Discussion = {
  fragment: gql`
    fragment Discussion on Discussion {
      id
      _id
      title
      message
      createdAt
      updatedAt
      postedAt
      requireInitialPost
      initialPostRequiredForCurrentUser
      isSectionSpecific
      isAnnouncement
      discussionType
      allowRating
      onlyGradersCanRate
      delayedPostAt
      subscribed
      published
      canUnpublish
      lockAt
      lockedForUser
      entryCounts {
        unreadCount
        repliesCount
      }
      attachment {
        ...Attachment
      }
      assignment {
        ...Assignment
      }
      permissions {
        ...DiscussionPermissions
      }
      courseSections {
        ...Section
      }
      childTopics {
        ...ChildTopic
      }
      groupSet {
        ...GroupSet
      }
      rootTopic {
        ...RootTopic
      }
    }
    ${Attachment.fragment}
    ${Assignment.fragment}
    ${DiscussionPermissions.fragment}
    ${Section.fragment}
    ${ChildTopic.fragment}
    ${GroupSet.fragment}
    ${RootTopic.fragment}
  `,

  shape: shape({
    id: string,
    _id: string,
    title: string,
    message: string,
    createdAt: string,
    updatedAt: string,
    postedAt: string,
    requireInitialPost: bool,
    initialPostRequiredForCurrentUser: bool,
    isSectionSpecific: bool,
    isAnnouncement: bool,
    discussionType: string,
    allowRating: bool,
    onlyGradersCanRate: bool,
    delayedPostAt: string,
    lockAt: string,
    subscribed: bool,
    published: bool,
    canUnpublish: bool,
    searchEntryCount: number,
    lockedForUser: bool,
    entryCounts: shape({
      unreadCount: number,
      repliesCount: number
    }),
    author: User.shape,
    editor: User.shape,
    attachment: Attachment.shape,
    assignment: Assignment.shape,
    permissions: DiscussionPermissions.shape,
    courseSections: arrayOf(Section.shape),
    childTopics: arrayOf(ChildTopic.shape),
    groupSet: GroupSet.shape,
    rootTopic: RootTopic.shape,
    rootEntriesTotalPages: number,
    entriesTotalPages: number
  }),

  mock: ({
    id = 'RGlzY3Vzc2lvbi0x',
    _id = '1',
    title = 'X-Men Powers Discussion',
    message = 'This is a Discussion Topic Message',
    createdAt = '2020-11-23T11:40:44-07:00',
    updatedAt = '2021-04-22T12:41:56-06:00',
    postedAt = '2020-11-23T11:40:44-07:00',
    requireInitialPost = false,
    initialPostRequiredForCurrentUser = false,
    isSectionSpecific = false,
    isAnnouncement = false,
    discussionType = 'threaded',
    allowRating = true,
    onlyGradersCanRate = false,
    delayedPostAt = null,
    lockAt = null,
    subscribed = true,
    published = true,
    canUnpublish = false,
    searchEntryCount = 3,
    lockedForUser = false,
    entryCounts = {
      unreadCount: 2,
      repliesCount: 56,
      __typename: 'DiscussionEntryCounts'
    },
    author = User.mock({_id: '1', displayName: '<NAME>'}),
    editor = User.mock({_id: '1', displayName: '<NAME>'}),
    attachment = Attachment.mock(),
    assignment = Assignment.mock(),
    permissions = DiscussionPermissions.mock(),
    courseSections = [Section.mock()],
    childTopics = [ChildTopic.mock()],
    groupSet = GroupSet.mock(),
    rootTopic = RootTopic.mock(),
    entriesTotalPages = 2,
    discussionEntriesConnection = {
      nodes: [DiscussionEntry.mock()],
      pageInfo: PageInfo.mock(),
      __typename: 'DiscussionEntriesConnection'
    },
    discussionEntryDraftsConnection = {
      nodes: [DiscussionEntryDraft.mock()],
      pageInfo: PageInfo.mock(),
      __typename: 'DiscussionEntryDraftsConnection'
    }
  } = {}) => ({
    id,
    _id,
    title,
    message,
    createdAt,
    updatedAt,
    postedAt,
    requireInitialPost,
    initialPostRequiredForCurrentUser,
    isSectionSpecific,
    isAnnouncement,
    discussionType,
    allowRating,
    onlyGradersCanRate,
    delayedPostAt,
    lockAt,
    subscribed,
    published,
    canUnpublish,
    entryCounts,
    lockedForUser,
    author,
    editor,
    attachment,
    assignment,
    permissions,
    courseSections,
    childTopics,
    groupSet,
    rootTopic,
    searchEntryCount,
    entriesTotalPages,
    discussionEntriesConnection,
    discussionEntryDraftsConnection,
    __typename: 'Discussion'
  })
}

export const DefaultMocks = {
  Discussion: () => ({
    _id: '1',
    title: 'This is a Title'
  })
}<commit_msg>Change lockedForUser to availableForUser in discussion query<commit_after>/*
 * Copyright (C) 2021 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

import {arrayOf, bool, number, shape, string} from 'prop-types'
import {Assignment} from './Assignment'
import {Attachment} from './Attachment'
import {Section} from './Section'
import {DiscussionPermissions} from './DiscussionPermissions'
import gql from 'graphql-tag'
import {User} from './User'
import {DiscussionEntry} from './DiscussionEntry'
import {DiscussionEntryDraft} from './DiscussionEntryDraft'
import {PageInfo} from './PageInfo'
import {ChildTopic} from './ChildTopic'
import {RootTopic} from './RootTopic'
import {GroupSet} from './GroupSet'

export const Discussion = {
  fragment: gql`
    fragment Discussion on Discussion {
      id
      _id
      title
      message
      createdAt
      updatedAt
      postedAt
      requireInitialPost
      initialPostRequiredForCurrentUser
      isSectionSpecific
      isAnnouncement
      discussionType
      allowRating
      onlyGradersCanRate
      delayedPostAt
      subscribed
      published
      canUnpublish
      lockAt
      availableForUser
      entryCounts {
        unreadCount
        repliesCount
      }
      attachment {
        ...Attachment
      }
      assignment {
        ...Assignment
      }
      permissions {
        ...DiscussionPermissions
      }
      courseSections {
        ...Section
      }
      childTopics {
        ...ChildTopic
      }
      groupSet {
        ...GroupSet
      }
      rootTopic {
        ...RootTopic
      }
    }
    ${Attachment.fragment}
    ${Assignment.fragment}
    ${DiscussionPermissions.fragment}
    ${Section.fragment}
    ${ChildTopic.fragment}
    ${GroupSet.fragment}
    ${RootTopic.fragment}
  `,

  shape: shape({
    id: string,
    _id: string,
    title: string,
    message: string,
    createdAt: string,
    updatedAt: string,
    postedAt: string,
    requireInitialPost: bool,
    initialPostRequiredForCurrentUser: bool,
    isSectionSpecific: bool,
    isAnnouncement: bool,
    discussionType: string,
    allowRating: bool,
    onlyGradersCanRate: bool,
    delayedPostAt: string,
    lockAt: string,
    subscribed: bool,
    published: bool,
    canUnpublish: bool,
    searchEntryCount: number,
    availableForUser: bool,
    entryCounts: shape({
      unreadCount: number,
      repliesCount: number
    }),
    author: User.shape,
    editor: User.shape,
    attachment: Attachment.shape,
    assignment: Assignment.shape,
    permissions: DiscussionPermissions.shape,
    courseSections: arrayOf(Section.shape),
    childTopics: arrayOf(ChildTopic.shape),
    groupSet: GroupSet.shape,
    rootTopic: RootTopic.shape,
    rootEntriesTotalPages: number,
    entriesTotalPages: number
  }),

  mock: ({
    id = 'RGlzY3Vzc2lvbi0x',
    _id = '1',
    title = 'X-Men Powers Discussion',
    message = 'This is a Discussion Topic Message',
    createdAt = '2020-11-23T11:40:44-07:00',
    updatedAt = '2021-04-22T12:41:56-06:00',
    postedAt = '2020-11-23T11:40:44-07:00',
    requireInitialPost = false,
    initialPostRequiredForCurrentUser = false,
    isSectionSpecific = false,
    isAnnouncement = false,
    discussionType = 'threaded',
    allowRating = true,
    onlyGradersCanRate = false,
    delayedPostAt = null,
    lockAt = null,
    subscribed = true,
    published = true,
    canUnpublish = false,
    searchEntryCount = 3,
    availableForUser = true,
    entryCounts = {
      unreadCount: 2,
      repliesCount: 56,
      __typename: 'DiscussionEntryCounts'
    },
    author = User.mock({_id: '1', displayName: '<NAME>'}),
    editor = User.mock({_id: '1', displayName: '<NAME>'}),
    attachment = Attachment.mock(),
    assignment = Assignment.mock(),
    permissions = DiscussionPermissions.mock(),
    courseSections = [Section.mock()],
    childTopics = [ChildTopic.mock()],
    groupSet = GroupSet.mock(),
    rootTopic = RootTopic.mock(),
    entriesTotalPages = 2,
    discussionEntriesConnection = {
      nodes: [DiscussionEntry.mock()],
      pageInfo: PageInfo.mock(),
      __typename: 'DiscussionEntriesConnection'
    },
    discussionEntryDraftsConnection = {
      nodes: [DiscussionEntryDraft.mock()],
      pageInfo: PageInfo.mock(),
      __typename: 'DiscussionEntryDraftsConnection'
    }
  } = {}) => ({
    id,
    _id,
    title,
    message,
    createdAt,
    updatedAt,
    postedAt,
    requireInitialPost,
    initialPostRequiredForCurrentUser,
    isSectionSpecific,
    isAnnouncement,
    discussionType,
    allowRating,
    onlyGradersCanRate,
    delayedPostAt,
    lockAt,
    subscribed,
    published,
    canUnpublish,
    entryCounts,
    availableForUser,
    author,
    editor,
    attachment,
    assignment,
    permissions,
    courseSections,
    childTopics,
    groupSet,
    rootTopic,
    searchEntryCount,
    entriesTotalPages,
    discussionEntriesConnection,
    discussionEntryDraftsConnection,
    __typename: 'Discussion'
  })
}

export const DefaultMocks = {
  Discussion: () => ({
    _id: '1',
    title: 'This is a Title'
  })
}
{'fraction_non_alphanumeric': 0.0977101905261318, 'fraction_numerical': 0.012410417759133019, 'mean_word_length': 2.841221886539107, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4261192', 'n_tokens_mistral': 3425, 'n_tokens_neox': 3337, 'n_words': 866}