Commit c33a1314 authored by Magdalena Frankiewicz's avatar Magdalena Frankiewicz

Add availability to user status

To enable setting user availability,
for now only one value possible: busy
parent 403da044
# frozen_string_literal: true
module Types
class AvailabilityEnum < BaseEnum
graphql_name 'AvailabilityEnum'
description 'User availability status'
value 'BUSY', value: :busy
end
end
...@@ -11,5 +11,7 @@ module Types ...@@ -11,5 +11,7 @@ module Types
description: 'User status message' description: 'User status message'
field :emoji, GraphQL::STRING_TYPE, null: true, field :emoji, GraphQL::STRING_TYPE, null: true,
description: 'String representation of emoji' description: 'String representation of emoji'
field :availability, Types::AvailabilityEnum, null: true,
description: 'User availability status'
end end
end end
...@@ -9,6 +9,8 @@ class UserStatus < ApplicationRecord ...@@ -9,6 +9,8 @@ class UserStatus < ApplicationRecord
belongs_to :user belongs_to :user
enum availability: { busy: 0 }
validates :user, presence: true validates :user, presence: true
validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names } validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names }
validates :message, length: { maximum: 100 }, allow_blank: true validates :message, length: { maximum: 100 }, allow_blank: true
......
---
title: Add availability to user status
merge_request: 45888
author:
type: added
# frozen_string_literal: true
class AddAvailabilityToUserStatuses < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :user_statuses, :availability, :integer, limit: 2
end
end
aa15aad0b51f313f3cd59e1065023146fe53c6bd50319656ae992f8f43e1525e
\ No newline at end of file
...@@ -16782,7 +16782,8 @@ CREATE TABLE user_statuses ( ...@@ -16782,7 +16782,8 @@ CREATE TABLE user_statuses (
cached_markdown_version integer, cached_markdown_version integer,
emoji character varying DEFAULT 'speech_balloon'::character varying NOT NULL, emoji character varying DEFAULT 'speech_balloon'::character varying NOT NULL,
message character varying(100), message character varying(100),
message_html character varying message_html character varying,
availability smallint
); );
CREATE SEQUENCE user_statuses_user_id_seq CREATE SEQUENCE user_statuses_user_id_seq
......
...@@ -927,6 +927,13 @@ type AlertTodoCreatePayload { ...@@ -927,6 +927,13 @@ type AlertTodoCreatePayload {
todo: Todo todo: Todo
} }
"""
User availability status
"""
enum AvailabilityEnum {
BUSY
}
""" """
An emoji awarded by a user An emoji awarded by a user
""" """
...@@ -21359,6 +21366,11 @@ enum UserState { ...@@ -21359,6 +21366,11 @@ enum UserState {
} }
type UserStatus { type UserStatus {
"""
User availability status
"""
availability: AvailabilityEnum
""" """
String representation of emoji String representation of emoji
""" """
......
...@@ -2391,6 +2391,23 @@ ...@@ -2391,6 +2391,23 @@
"enumValues": null, "enumValues": null,
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "ENUM",
"name": "AvailabilityEnum",
"description": "User availability status",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "BUSY",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
},
{ {
"kind": "OBJECT", "kind": "OBJECT",
"name": "AwardEmoji", "name": "AwardEmoji",
...@@ -61776,6 +61793,20 @@ ...@@ -61776,6 +61793,20 @@
"name": "UserStatus", "name": "UserStatus",
"description": null, "description": null,
"fields": [ "fields": [
{
"name": "availability",
"description": "User availability status",
"args": [
],
"type": {
"kind": "ENUM",
"name": "AvailabilityEnum",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "emoji", "name": "emoji",
"description": "String representation of emoji", "description": "String representation of emoji",
...@@ -2979,6 +2979,7 @@ Autogenerated return type of UpdateSnippet. ...@@ -2979,6 +2979,7 @@ Autogenerated return type of UpdateSnippet.
| Field | Type | Description | | Field | Type | Description |
| ----- | ---- | ----------- | | ----- | ---- | ----------- |
| `availability` | AvailabilityEnum | User availability status |
| `emoji` | String | String representation of emoji | | `emoji` | String | String representation of emoji |
| `message` | String | User status message | | `message` | String | User status message |
| `messageHtml` | String | HTML of the user status message | | `messageHtml` | String | HTML of the user status message |
...@@ -3307,6 +3308,14 @@ Alert status values. ...@@ -3307,6 +3308,14 @@ Alert status values.
| `RESOLVED` | Resolved status | | `RESOLVED` | Resolved status |
| `TRIGGERED` | Triggered status | | `TRIGGERED` | Triggered status |
### AvailabilityEnum
User availability status.
| Value | Description |
| ----- | ----------- |
| `BUSY` | |
### BlobViewersType ### BlobViewersType
Types of blob viewers. Types of blob viewers.
......
...@@ -5,6 +5,7 @@ module API ...@@ -5,6 +5,7 @@ module API
class UserStatus < Grape::Entity class UserStatus < Grape::Entity
expose :emoji expose :emoji
expose :message expose :message
expose :availability
expose :message_html do |entity| expose :message_html do |entity|
MarkupHelper.markdown_field(entity, :message) MarkupHelper.markdown_field(entity, :message)
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['AvailabilityEnum'] do
specify { expect(described_class.graphql_name).to eq('AvailabilityEnum') }
it 'exposes all the existing access levels' do
expect(described_class.values.keys).to match_array(%w[BUSY])
end
end
...@@ -10,6 +10,7 @@ RSpec.describe Types::UserStatusType do ...@@ -10,6 +10,7 @@ RSpec.describe Types::UserStatusType do
emoji emoji
message message
message_html message_html
availability
] ]
expect(described_class).to have_graphql_fields(*expected_fields) expect(described_class).to have_graphql_fields(*expected_fields)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment