mattermost-mobile-upstream/types/api/properties.d.ts
Pablo Vélez 4d842026f6
Some checks failed
ci / lint-typecheck (push) Has been cancelled
ci / detox-lint-typecheck (push) Has been cancelled
ci / test (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Mm 70564 channel labels use in channel creation (#10146)
* MM-70516 - Add ability to edit channel attribute values from Channel Info

* Add API methods for patching property fields and setting channel attribute requirements

* Update channel attribute clearing behavior for required and non-required fields

* MM-70564 - use channel attributes on channel creation

* Fix undefined propertyValues and ternary formatting in channel attributes

* Fix spelling of "colour" to "color" in attribute chip tests and related comments

* Add visibility checks for channel attribute labels in tests

* Fix data-integrity, permission, and accessibility issues in channel attributes: scoped pruning, atomic writes, race serialization, required clear/stale-option guards

* Fix handling of null values in apiGetChannelAttributeValue and update test assertions for channel attributes

* Improve channel attribute editor sizing for long labels, keep Save visible, and prevent keyboard overlap on Android

* Address CodeRabbit feedback for nullable values, bottom-sheet state, async validation, and reliable E2E cleanup

* lock-safe field fetch, create-time gate recheck, scoped value pruning, and tappable header chips

* Address CodeRabbit feedback: drop queued attribute saves on channel switch and use page object selectors in E2E

* Respect the ChannelAttributesRequired flag on channel creation and enable it for channel attribute E2E

* Skip required channel attribute E2E tests and stop enabling ChannelAttributesRequired on the shared server until  they move to SITE_3

* Fix clearing channel attributes on iOS by sending an empty value instead of null, and stop E2E suites from turning  off the ChannelAttributes flag mid-run

* Refactor getEmptyPropertyValue to accept string type for fieldType parameter

* E2E: give channel attribute test fields a suite-unique suffix

Pool shards may only create optional property fields named <name>_<6 hex>; fixed names were blocked by the pool guard.

* E2E: restore channel attribute cleanup checks; name network error codes

Brings back the PR's afterEach/afterAll error handling that the main merge replaced, and makes a no-response error show its codes (an AggregateError has an empty message).

* E2E: run channel attribute creation and editing specs on server B

Their 11 required-attribute tests could not run on the shared servers. Both specs now run on the mutation server with ChannelAttributesRequired on for their run, and the tests are re-enabled. setChannelAttributesRequired moves to the shared helper.

* Check header chips instead of their wrapper and use toExist for the create screen in channel attribute E2E

---------

Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
2026-10-30 15:03:55 +01:00

131 lines
4.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
type PropertyFieldType =
| 'text'
| 'select'
| 'multiselect'
| 'rank'
| 'date'
| 'user'
| 'multiuser'
| 'checkbox'
| 'number'
| 'url';
// Canonical server values are 'post' | 'channel' | 'user' (see managed_categories WS handler,
// REST property endpoints). 'card' is a mobile/boards-only domain alias — boards cards are
// backed by 'post' on the server, so API object_type is 'post'; keep 'card' only for
// mobile-local representations. 'system' and 'template' are used by the classification-markings
// fields (see @constants/classification).
type PropertyFieldObjectType = 'card' | 'post' | 'channel' | 'user' | 'system' | 'template';
type PropertyFieldTargetLevel = 'system' | 'team' | 'channel';
// Mirrors model.PermissionLevel. An empty string means the server fills in the
// default for the field's object type, which for a channel field is 'member'
// (see defaultPermissionValuesForObjectType in the server's property hooks).
type PermissionLevel = 'none' | 'sysadmin' | 'admin' | 'member' | '';
// How a channel attribute's value may move once it is set, mirroring
// attrs.change_policy. The directional policies compare option ranks, so the
// server strips them from any field that is not rank-typed.
type PropertyChangePolicy = 'any' | 'raise_only' | 'lower_only' | 'never';
type PropertyFieldOption = {
id: string;
name: string;
color?: string;
rank?: number;
};
type PropertyFieldAction = 'display_banner_top' | 'display_banner_bottom' | 'display_label_header' | 'display_label_info';
type PropertyFieldAttrs = {
sort_order?: number;
options?: PropertyFieldOption[];
// Where a channel attribute's value displays. Server-validated allow-list;
// see @constants/channel_attributes. An empty array means an administrator
// chose no locations, which is not the same as the key being absent.
// Unknown values from a future server are retained via the index signature below.
actions?: PropertyFieldAction[];
// Channel-attribute configuration written by the System Console's Channels
// resource row. `editable` predates `change_policy`; false reads as 'never'.
required?: boolean;
change_policy?: PropertyChangePolicy;
editable?: boolean;
// Admin-facing override for the field's CEL-safe machine name. Not copied
// onto linked fields by the server, so channel fields usually lack it.
display_name?: string;
[key: string]: unknown;
};
type PropertyField = {
id: string;
group_id: string;
name: string;
type: PropertyFieldType;
attrs?: PropertyFieldAttrs;
object_type: PropertyFieldObjectType;
target_id: string;
target_type: PropertyFieldTargetLevel;
linked_field_id?: string;
protected?: boolean;
permission_field?: PermissionLevel;
permission_values?: PermissionLevel;
permission_options?: PermissionLevel;
create_at: number;
update_at: number;
delete_at: number;
created_by?: string;
updated_by?: string;
};
type PropertyFieldSearchOpts = {
object_types: PropertyFieldObjectType[];
channel_id?: string;
team_id?: string;
target_type?: PropertyFieldTargetLevel;
target_id?: string;
since?: number;
cursor_id?: string;
cursor_create_at?: number;
cursor_update_at?: number;
per_page?: number;
};
type PropertyValue<T = unknown> = {
id: string;
field_id: string;
target_id: string;
target_type: string;
group_id: string;
value: T;
create_at: number;
update_at: number;
delete_at: number;
created_by?: string;
updated_by?: string;
};
type PropertyValuePatch<T = unknown> = Partial<Pick<PropertyValue<T>, 'value'>>;
// One item of the PATCH values body. The route takes a bare array of these, and
// a null value is how a value is cleared: the server answers a clear with an
// upserted null-valued row rather than a delete.
type PropertyValuePatchItem<T = unknown> = {
field_id: string;
value: T | null;
};
type PropertyValuesUpdatedData = {
object_type?: string;
target_id?: string;
field_id?: string;
values: string;
};