getMappings()

in app/assets/javascripts/filtered_search/available_dropdown_mappings.js [73:187]


  getMappings() {
    return {
      [TOKEN_TYPE_AUTHOR]: {
        reference: null,
        gl: DropdownUser,
        element: this.container.querySelector('#js-dropdown-author'),
      },
      [TOKEN_TYPE_ASSIGNEE]: {
        reference: null,
        gl: DropdownUser,
        element: this.container.querySelector('#js-dropdown-assignee'),
      },
      [TOKEN_TYPE_REVIEWER]: {
        reference: null,
        gl: DropdownUser,
        element: this.container.querySelector('#js-dropdown-reviewer'),
      },
      [TOKEN_TYPE_MERGE_USER]: {
        reference: null,
        gl: DropdownUser,
        element: this.container.querySelector('#js-dropdown-merge-user'),
      },
      attention: {
        reference: null,
        gl: DropdownUser,
        element: this.container.getElementById('js-dropdown-attention-requested'),
      },
      [TOKEN_TYPE_APPROVED_BY]: {
        reference: null,
        gl: DropdownUser,
        element: this.container.querySelector('#js-dropdown-approved-by'),
      },
      [TOKEN_TYPE_MILESTONE]: {
        reference: null,
        gl: DropdownNonUser,
        extraArguments: {
          endpoint: this.getMilestoneEndpoint(),
          symbol: '%',
          preprocessing: (milestones) => milestones.sort(sortMilestonesByDueDate),
        },
        element: this.container.querySelector('#js-dropdown-milestone'),
      },
      [TOKEN_TYPE_RELEASE]: {
        reference: null,
        gl: DropdownNonUser,
        extraArguments: {
          endpoint: this.getReleasesEndpoint(),
          symbol: '',

          // The DropdownNonUser class is hardcoded to look for and display a
          // "title" property, so we need to add this property to each release object
          preprocessing: (releases) => releases.map((r) => ({ ...r, title: r.tag })),
        },
        element: this.container.querySelector('#js-dropdown-release'),
      },
      [TOKEN_TYPE_LABEL]: {
        reference: null,
        gl: DropdownNonUser,
        extraArguments: {
          endpoint: this.getLabelsEndpoint(),
          symbol: '~',
          preprocessing: DropdownUtils.duplicateLabelPreprocessing,
        },
        element: this.container.querySelector('#js-dropdown-label'),
      },
      [TOKEN_TYPE_MY_REACTION]: {
        reference: null,
        gl: DropdownEmoji,
        element: this.container.querySelector('#js-dropdown-my-reaction'),
      },
      draft: {
        reference: null,
        gl: DropdownNonUser,
        element: this.container.querySelector('#js-dropdown-wip'),
      },
      approved: {
        reference: null,
        gl: DropdownNonUser,
        element: this.container.querySelector('#js-dropdown-approved'),
      },
      [TOKEN_TYPE_CONFIDENTIAL]: {
        reference: null,
        gl: DropdownNonUser,
        element: this.container.querySelector('#js-dropdown-confidential'),
      },
      [TOKEN_TYPE_TARGET_BRANCH]: {
        reference: null,
        gl: DropdownNonUser,
        extraArguments: {
          endpoint: this.getMergeRequestTargetBranchesEndpoint(),
          symbol: '',
        },
        element: this.container.querySelector('#js-dropdown-target-branch'),
      },
      [TOKEN_TYPE_SOURCE_BRANCH]: {
        reference: null,
        gl: DropdownNonUser,
        extraArguments: {
          endpoint: this.getMergeRequestSourceBranchesEndpoint(),
          symbol: '',
        },
        element: this.container.querySelector('#js-dropdown-source-branch'),
      },
      environment: {
        reference: null,
        gl: DropdownNonUser,
        extraArguments: {
          endpoint: this.getEnvironmentsEndpoint(),
          symbol: '',
          preprocessing: (data) => data.map((env) => ({ title: env })),
        },
        element: this.container.querySelector('#js-dropdown-environment'),
      },
    };
  }