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
description: 'User status message'
field :emoji, GraphQL::STRING_TYPE, null: true,
description: 'String representation of emoji'
field :availability, Types::AvailabilityEnum, null: true,
description: 'User availability status'
end
end
......@@ -9,6 +9,8 @@ class UserStatus < ApplicationRecord
belongs_to :user
enum availability: { busy: 0 }
validates :user, presence: true
validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names }
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 (
cached_markdown_version integer,
emoji character varying DEFAULT 'speech_balloon'::character varying NOT NULL,
message character varying(100),
message_html character varying
message_html character varying,
availability smallint
);
CREATE SEQUENCE user_statuses_user_id_seq
......
......@@ -927,6 +927,13 @@ type AlertTodoCreatePayload {
todo: Todo
}
"""
User availability status
"""
enum AvailabilityEnum {
BUSY
}
"""
An emoji awarded by a user
"""
......@@ -21359,6 +21366,11 @@ enum UserState {
}
type UserStatus {
"""
User availability status
"""
availability: AvailabilityEnum
"""
String representation of emoji
"""
......
......@@ -2391,6 +2391,23 @@
"enumValues": 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",
"name": "AwardEmoji",
......@@ -61776,6 +61793,20 @@
"name": "UserStatus",
"description": null,
"fields": [
{
"name": "availability",
"description": "User availability status",
"args": [
],
"type": {
"kind": "ENUM",
"name": "AvailabilityEnum",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "emoji",
"description": "String representation of emoji",
......@@ -2979,6 +2979,7 @@ Autogenerated return type of UpdateSnippet.
| Field | Type | Description |
| ----- | ---- | ----------- |
| `availability` | AvailabilityEnum | User availability status |
| `emoji` | String | String representation of emoji |
| `message` | String | User status message |
| `messageHtml` | String | HTML of the user status message |
......@@ -3307,6 +3308,14 @@ Alert status values.
| `RESOLVED` | Resolved status |
| `TRIGGERED` | Triggered status |
### AvailabilityEnum
User availability status.
| Value | Description |
| ----- | ----------- |
| `BUSY` | |
### BlobViewersType
Types of blob viewers.
......
......@@ -5,6 +5,7 @@ module API
class UserStatus < Grape::Entity
expose :emoji
expose :message
expose :availability
expose :message_html do |entity|
MarkupHelper.markdown_field(entity, :message)
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
emoji
message
message_html
availability
]
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