mattermost-mobile-upstream/app/constants/classification.ts
Pablo Vélez 54731fa6ac
Mm 70299 channel labels display phase 1 (#10113)
* MM-70299 - display channel attributes in header, info and banner

* cover and expand channel attributes feature with UI and E2E tests

* Implement channel attributes lock and update related tests and API methods

* Enhance error logging and improve type definitions for channel attributes

* Handle error from setAccessControlGroupId in fetchAccessControlAttributeFields

* Refactor fetchAccessControlAttributeFields to include system ID handling and improve batch record persistence

* Address code review feedback: extract feature-flag constants, move DB-only helpers to query/local layers, refactor attribute chip styles, fix colour spelling, and add test coverage for value pruning and subtitle component

* Fix error handling in removeStoredFields function and delete obsolete end-to-end test file

* Add tests for removeStoredFields function and enhance property queries

* Fix removeStoredFields to recover group ID from classification anchor and clean all owned fields

* Fix batchRecords silently swallowing write errors in fetchAccessControlAttributeFields

* Remove unused visibility check for ChannelAttributeLabels in e2e tests

* Fix classification fetch cache and channel-attributes E2E lock contention

Do not stamp the classification banner cache when both access-control flags
are off, so turning a flag back on after a reload refetches fields.

Share the classification lock with the channel-attributes Detox suite and
stop unsetting ClassificationMarkings. Skip flag-on tests when the server
cannot enable ChannelAttributes.

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Scope access_control field prune to owned object types

handlePropertyFields(groupId) deletes every field in the group. The fetch
only returns system and channel fields, so same-group user/session rows
were removed on each refresh. Prune only system and channel fields, matching
removeStoredFields.

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* fail channel attributes tests when feature enablement fails instead of silently reporting them as passed

* Compose all channel attribute values in banners with template resolution, mixed field support, and matching web colors

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: mattermost-code <matty-code@mattermost.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2026-09-17 21:37:43 +02:00

55 lines
2.7 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ---------------------------------------------------------------------------
// Classification-markings constants
//
// The classification system uses two linked property-field "object types":
//
// 1. System field — drives the GLOBAL banner. Linked to the server-side
// template and inherits its options/colors.
// 2. Channel field — drives PER-CHANNEL banners. Also linked to the
// template and inherits its options/colors.
//
// Both fields share the same field name on the server and are distinguished
// only by their object_type ('system' vs 'channel'). They are also scoped
// server-side as system fields, so they share the same field-level target
// attributes (`target_type='system'`, `target_id=''`). Property *values* for
// the system field are stored on the dedicated system endpoint and use the
// sentinel target_id 'system'.
// ---------------------------------------------------------------------------
// Property-field group identifying all classification-markings entities.
// Classification is one tenant of the shared access_control group, so the name
// and the banner actions are defined once, alongside the generic channel
// attributes, and re-exported here for the existing classification callers.
export {
ACCESS_CONTROL_GROUP_NAME as CLASSIFICATIONS_GROUP_NAME,
DISPLAY_BANNER_TOP,
DISPLAY_BANNER_BOTTOM,
} from '@constants/channel_attributes';
// Field-level target attributes shared by system and channel fields.
// `target_type` is always 'system'; `target_id` is empty for system-scoped
// field definitions (the server canonicalizes both).
export const CLASSIFICATIONS_FIELD_TARGET_TYPE = 'system';
export const CLASSIFICATIONS_FIELD_TARGET_ID = '';
// Shared field name for both the system and channel classification fields.
export const CLASSIFICATIONS_FIELD_NAME = 'classification';
// System field — drives the global banner. Property *values* live on the
// dedicated system endpoint and use the sentinel target_id 'system'.
export const CLASSIFICATIONS_SYSTEM_OBJECT_TYPE = 'system';
export const CLASSIFICATIONS_SYSTEM_VALUE_TARGET_ID = 'system';
// Channel field — drives the per-channel banner.
export const CLASSIFICATIONS_CHANNEL_OBJECT_TYPE = 'channel';
// How long a successful classification-field fetch stays fresh in the in-memory
// cache before the global banner mount effect will request it again (1 hour).
export const CLASSIFICATION_BANNER_CACHE_TTL = 60 * 60 * 1000;
// Feature flag config key for the classification markings system.
export const FEATURE_FLAG_CLASSIFICATION_MARKINGS = 'FeatureFlagClassificationMarkings';