mirror of
https://github.com/mattermost/mattermost.git
synced 2026-04-15 05:57:37 -04:00
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Blocked by required conditions
Web App CI / check-types (push) Blocked by required conditions
Web App CI / test (platform) (push) Blocked by required conditions
Web App CI / test (mattermost-redux) (push) Blocked by required conditions
Web App CI / test (channels shard 1/4) (push) Blocked by required conditions
Web App CI / test (channels shard 2/4) (push) Blocked by required conditions
Web App CI / test (channels shard 3/4) (push) Blocked by required conditions
Web App CI / test (channels shard 4/4) (push) Blocked by required conditions
Web App CI / upload-coverage (push) Blocked by required conditions
Web App CI / build (push) Blocked by required conditions
* Respect user display preferences for date and time formatting User Preference Support: - Read isUseMilitaryTime preference from user settings - Apply 24-hour format when enabled (14:00 instead of 2:00 PM) - Apply 12-hour format when disabled (2:00 PM instead of 14:00) - Pass useTime prop to Timestamp component with correct hourCycle/hour12 Date Formatting Consistency: - Create formatDateForDisplay() utility in date_utils.ts - Centralize date formatting logic (month: 'short', day/year: 'numeric') - Use consistent "Jan 15, 2025" format across all date/datetime fields - Replace DateTime.fromJSDate().toLocaleString() which varies by browser Components Updated: - DateTimeInput: Use isMilitaryTime for dropdown and selected time display - DateTimeInput: Use formatDateForDisplay for date display - AppsFormDateField: Use formatDateForDisplay instead of inline Intl code Tests Added: - 4 tests for user preference handling (military time, locale) - 5 tests for formatDateForDisplay utility - Updated snapshot for Timestamp changes Benefits: - Single source of truth for date formatting - Easy to change format globally by updating one function - Respects user preferences consistently - Fixes inconsistency where datetime showed "1/1/2026" vs date showing "Jan 1, 2026" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Add timezone and manual time entry support for datetime fields Object Model: - Create DialogDateTimeConfig with TimeInterval, LocationTimezone, AllowManualTimeEntry - Add DateTimeConfig field to DialogElement - Keep legacy MinDate, MaxDate, TimeInterval for fallback Timezone Support (location_timezone): - Display datetime in specific IANA timezone (e.g., "Europe/London", "Asia/Tokyo") - Show timezone indicator: "🌍 Times in GMT" - Preserve timezone through all operations - Fix momentToString to clone before converting to UTC (prevents mutation) - Use moment.tz array syntax for timezone-safe moment creation - Generate time intervals starting at midnight in display timezone Manual Time Entry (allow_manual_time_entry): - Add parseTimeString() function supporting multiple formats: - 12-hour: 12a, 12:30p, 3:45pm - 24-hour: 14:30, 9:15 - Add TimeInputManual component with text input - Conditional rendering: manual input OR dropdown - No rounding for manual entry (exact minutes preserved) - No auto-advance (validation only, show error for invalid format) - Respects user's 12h/24h preference for placeholder Critical Bug Fixes: - Fix getTimeInIntervals to return Moment[] instead of Date[] (preserves timezone) - Fix momentToString mutation: use .clone() before .utc() - Use .clone() when calling .startOf('day') to preserve timezone - Use moment.tz([...], timezone) array syntax instead of .tz().hour() mutation - Display selected time using .format() instead of Timestamp component - Fix null handling: optional fields start empty, show '--:--' - Manual entry gets exact current time, dropdown gets rounded time Component Updates: - DateTimeInput: Add TimeInputManual component, parseTimeString, timezone handling - AppsFormDateTimeField: Extract config, timezone indicator, pass timezone to child - Modal components: Handle Moment | null signatures - CSS: Add manual entry input styles with error states Features: - Timezone-aware time generation (dropdown starts at midnight in display TZ) - Manual entry works with timezones (creates moments in correct TZ) - Optional fields start empty (null value, no display default) - Required datetime fields get rounded default from apps_form_component 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Fix momentToString mutation - clone before converting to UTC Prevents .utc() from mutating the original moment object. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Add E2E test for 12h/24h time preference support Test MM-T2530H verifies that datetime fields respect user's display preference: - Sets preference to 24-hour format - Verifies dropdown shows times as 14:00, 15:00, etc. - Verifies selected time displays in 24-hour format - Changes preference to 12-hour format - Verifies dropdown shows times as 2:00 PM, 3:00 PM, etc. Uses cy.apiSaveClockDisplayModeTo24HourPreference() to set user preference. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Auto-round time to interval boundaries in DateTimeInput Automatically rounds displayed time to timePickerInterval to ensure consistent behavior across all callers. Problem: - DND modal and Custom Status modal showed unrounded times (e.g., 13:47) - Should show rounded times (e.g., 14:00) to match dropdown intervals - Some callers pre-rounded, others didn't (inconsistent) Solution: - Add useEffect in DateTimeInput that auto-rounds on mount - Only calls handleChange if time needs rounding - Uses timePickerInterval prop or 30-minute default - Harmless for callers that already pre-round (no change triggered) Behavior: - DND modal: Now shows 14:00 instead of 13:47 - Custom Status: Still works (already pre-rounded, so no-op) - Post Reminder: Still works (already pre-rounded, so no-op) - Interactive Dialog: Still works (uses custom intervals) Added 3 unit tests for auto-rounding behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * lint fix * Add deferred login cleanup to post_test.go 'not logged in' test Ensures the test helper is logged back in after the logout test completes, preventing test state issues for subsequent tests. Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Add unit tests for parseTimeString and timezone handling parseTimeString tests (9 test cases): - 12-hour format with AM/PM (12a, 3:30pm, etc.) - 24-hour format (14:30, 23:59, etc.) - Time without minutes (defaults to :00) - Invalid hours, minutes, and formats - Edge cases (midnight 12:00am, noon 12:00pm) Timezone handling tests (3 test cases): - Preserve timezone in getTimeInIntervals - Generate intervals starting at midnight in timezone - Timezone conversion pattern verification Total: 12 new tests added (32 total in file) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Add E2E tests and webhook support for timezone/manual entry E2E Tests Added (MM-T2530O through MM-T2530S): - MM-T2530O: Manual time entry basic functionality - MM-T2530P: Manual time entry multiple formats (12a, 14:30, 9pm) - MM-T2530Q: Manual time entry invalid format handling - MM-T2530R: Timezone support dropdown (London GMT) - MM-T2530S: Timezone support manual entry (London GMT) Webhook Server Support: - Added getTimezoneManualDialog() to webhook_utils.js - Added 'timezone-manual' case to webhook_serve.js - Dialog with 3 fields: local manual, London dropdown, London manual Bug Fixes: - Skip auto-rounding for allowManualTimeEntry fields (preserve exact minutes) - Generate dropdown options even when displayTime is null (use currentTime fallback) - Scope Cypress selectors with .within() to avoid duplicate ID issues All tests passing (13 total datetime tests). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Fix ESLint no-multi-spaces in apps.ts Remove extra spacing before comments to comply with ESLint rules. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * Fix gofmt formatting in integration_action.go Align Options, MultiSelect, and Refresh field spacing to match Go formatting standards. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * more lint fixes * css lint fix * i18n-extract * lint fixes * update snapshot * Fix modal scroll containment for datetime fields The .modal-overflow class was applying overflow: visible to .modal-body, which broke scroll containment when datetime fields were present. This caused the entire form to scroll instead of scrolling within the modal-body viewport. Changes: - Remove .modal-body overflow override from .modal-overflow class to preserve scroll containment while still allowing date/time popups to display correctly via z-index - Remove italic styling from timezone indicator for cleaner appearance - Remove redundant "Time" label from manual time entry input (aria-label is sufficient for accessibility) - Add CSS rule to ensure "(optional)" label text is not bold Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> * fixes for cypress tests * fix for using timezone crossing dates * fix dateonly strings parse failures * regex fix * linter fix --------- Co-authored-by: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com> Co-authored-by: Mattermost Build <build@mattermost.com>
591 lines
23 KiB
JavaScript
591 lines
23 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
// Helper function to create dialog base structure
|
|
function createDialog(triggerId, webhookBaseUrl, dialogConfig) {
|
|
const baseDialog = {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/dialog_submit`,
|
|
dialog: {
|
|
callback_id: dialogConfig.callback_id,
|
|
title: dialogConfig.title,
|
|
submit_label: dialogConfig.submit_label || 'Submit',
|
|
notify_on_cancel: true,
|
|
...dialogConfig.dialog_props,
|
|
elements: dialogConfig.elements || [],
|
|
},
|
|
};
|
|
|
|
if (dialogConfig.icon_url) {
|
|
baseDialog.dialog.icon_url = dialogConfig.icon_url;
|
|
}
|
|
|
|
if (dialogConfig.introduction_text) {
|
|
baseDialog.dialog.introduction_text = dialogConfig.introduction_text;
|
|
}
|
|
|
|
if (dialogConfig.state) {
|
|
baseDialog.dialog.state = dialogConfig.state;
|
|
}
|
|
|
|
if (dialogConfig.source_url) {
|
|
baseDialog.dialog.source_url = dialogConfig.source_url;
|
|
}
|
|
|
|
return baseDialog;
|
|
}
|
|
|
|
// Helper function to create form response structure
|
|
function createFormResponse(formConfig) {
|
|
return {
|
|
callback_id: formConfig.callback_id,
|
|
title: formConfig.title,
|
|
submit_label: formConfig.submit_label || 'Submit',
|
|
notify_on_cancel: true,
|
|
elements: formConfig.elements || [],
|
|
...formConfig.form_props,
|
|
};
|
|
}
|
|
|
|
// Helper function to create common form elements
|
|
function createElement(type, config) {
|
|
const baseElement = {
|
|
display_name: config.display_name,
|
|
name: config.name,
|
|
type,
|
|
optional: config.optional || false,
|
|
};
|
|
|
|
if (config.placeholder) {
|
|
baseElement.placeholder = config.placeholder;
|
|
}
|
|
if (config.help_text) {
|
|
baseElement.help_text = config.help_text;
|
|
}
|
|
if (config.default) {
|
|
baseElement.default = config.default;
|
|
}
|
|
if (config.subtype) {
|
|
baseElement.subtype = config.subtype;
|
|
}
|
|
if (config.min_length) {
|
|
baseElement.min_length = config.min_length;
|
|
}
|
|
if (config.max_length) {
|
|
baseElement.max_length = config.max_length;
|
|
}
|
|
if (config.data_source) {
|
|
baseElement.data_source = config.data_source;
|
|
}
|
|
if (config.options) {
|
|
baseElement.options = config.options;
|
|
}
|
|
if (config.refresh) {
|
|
baseElement.refresh = config.refresh;
|
|
}
|
|
|
|
return baseElement;
|
|
}
|
|
|
|
// Standard icon URL
|
|
const STANDARD_ICON = 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png';
|
|
|
|
// Dialog configurations
|
|
const DIALOG_CONFIGS = {
|
|
full: {
|
|
callback_id: 'somecallbackid',
|
|
title: 'Title for Full Dialog Test',
|
|
icon_url: STANDARD_ICON,
|
|
elements: [
|
|
createElement('text', {display_name: 'Display Name', name: 'realname', default: 'default text', placeholder: 'placeholder', help_text: 'This a regular input in an interactive dialog triggered by a test integration.'}),
|
|
createElement('text', {display_name: 'Email', name: 'someemail', subtype: 'email', placeholder: 'placeholder@bladekick.com', help_text: 'This a regular email input in an interactive dialog triggered by a test integration.'}),
|
|
createElement('text', {display_name: 'Number', name: 'somenumber', subtype: 'number'}),
|
|
createElement('text', {display_name: 'Password', name: 'somepassword', subtype: 'password', default: 'p@ssW0rd', placeholder: 'placeholder', help_text: 'This a password input in an interactive dialog triggered by a test integration.', optional: true}),
|
|
createElement('textarea', {display_name: 'Display Name Long Text Area', name: 'realnametextarea', placeholder: 'placeholder', optional: true, min_length: 5, max_length: 100}),
|
|
createElement('select', {display_name: 'User Selector', name: 'someuserselector', placeholder: 'Select a user...', data_source: 'users'}),
|
|
createElement('select', {display_name: 'Channel Selector', name: 'somechannelselector', placeholder: 'Select a channel...', help_text: 'Choose a channel from the list.', data_source: 'channels', optional: true}),
|
|
createElement('select', {display_name: 'Option Selector', name: 'someoptionselector', placeholder: 'Select an option...', options: [{text: 'Option1', value: 'opt1'}, {text: 'Option2', value: 'opt2'}, {text: 'Option3', value: 'opt3'}]}),
|
|
createElement('radio', {display_name: 'Radio Option Selector', name: 'someradiooptions', help_text: '', options: [{text: 'Engineering', value: 'engineering'}, {text: 'Sales', value: 'sales'}]}),
|
|
createElement('bool', {display_name: 'Boolean Selector', name: 'boolean_input', placeholder: 'Was this modal helpful?', default: 'True', optional: true, help_text: 'This is the help text'}),
|
|
],
|
|
dialog_props: {state: 'somestate'},
|
|
},
|
|
|
|
simple: {
|
|
callback_id: 'somecallbackid',
|
|
title: 'Title for Dialog Test without elements',
|
|
icon_url: STANDARD_ICON,
|
|
submit_label: 'Submit Test',
|
|
dialog_props: {state: 'somestate'},
|
|
},
|
|
|
|
userAndChannel: {
|
|
callback_id: 'somecallbackid',
|
|
title: 'Title for Dialog Test with user and channel element',
|
|
icon_url: STANDARD_ICON,
|
|
submit_label: 'Submit Test',
|
|
elements: [
|
|
createElement('select', {display_name: 'User Selector', name: 'someuserselector', placeholder: 'Select a user...', data_source: 'users'}),
|
|
createElement('select', {display_name: 'Channel Selector', name: 'somechannelselector', placeholder: 'Select a channel...', help_text: 'Choose a channel from the list.', data_source: 'channels', optional: true}),
|
|
],
|
|
dialog_props: {state: 'somestate'},
|
|
},
|
|
|
|
boolean: {
|
|
callback_id: 'somecallbackid',
|
|
title: 'Title for Dialog Test with boolean element',
|
|
icon_url: STANDARD_ICON,
|
|
submit_label: 'Submit Test',
|
|
elements: [
|
|
createElement('bool', {display_name: 'Boolean Selector', name: 'boolean_input', placeholder: 'Was this modal helpful?', default: 'True', optional: true, help_text: 'This is the help text'}),
|
|
],
|
|
dialog_props: {state: 'somestate'},
|
|
},
|
|
|
|
fieldRefresh: {
|
|
callback_id: 'field_refresh_callback',
|
|
title: 'Field Refresh Demo',
|
|
introduction_text: 'Enter project name then select type to see different fields',
|
|
elements: [
|
|
createElement('text', {display_name: 'Project Name', name: 'project_name', placeholder: 'Enter project name'}),
|
|
createElement('select', {display_name: 'Project Type', name: 'project_type', refresh: true, placeholder: 'Select project type...', options: [{text: 'Web Application', value: 'web'}, {text: 'Mobile App', value: 'mobile'}, {text: 'API Service', value: 'api'}]}),
|
|
],
|
|
},
|
|
|
|
multistepStep1: {
|
|
callback_id: 'multistep_callback',
|
|
title: 'Step 1 - Personal Info',
|
|
introduction_text: 'Multi-step registration - Step 1 of 3',
|
|
submit_label: 'Next Step',
|
|
elements: [
|
|
createElement('text', {display_name: 'First Name', name: 'first_name', placeholder: 'Enter your first name'}),
|
|
createElement('text', {display_name: 'Email', name: 'email', subtype: 'email', placeholder: 'Enter your email address'}),
|
|
],
|
|
dialog_props: {state: 'step1'},
|
|
},
|
|
|
|
multistepStep2: {
|
|
callback_id: 'multistep_callback',
|
|
title: 'Step 2 - Work Info',
|
|
introduction_text: 'Multi-step registration - Step 2 of 3',
|
|
submit_label: 'Next Step',
|
|
elements: [
|
|
createElement('select', {display_name: 'Department', name: 'department', placeholder: 'Select department...', options: [{text: 'Engineering', value: 'engineering'}, {text: 'Marketing', value: 'marketing'}, {text: 'Sales', value: 'sales'}]}),
|
|
createElement('radio', {display_name: 'Experience Level', name: 'experience_level', options: [{text: 'Junior', value: 'junior'}, {text: 'Mid-level', value: 'mid'}, {text: 'Senior', value: 'senior'}]}),
|
|
],
|
|
form_props: {state: 'step2'},
|
|
},
|
|
|
|
multistepStep3: {
|
|
callback_id: 'multistep_callback',
|
|
title: 'Step 3 - Final Details',
|
|
introduction_text: 'Multi-step registration - Step 3 of 3',
|
|
submit_label: 'Complete Registration',
|
|
elements: [
|
|
createElement('textarea', {display_name: 'Comments', name: 'comments', placeholder: 'Any additional comments...', optional: true}),
|
|
createElement('bool', {display_name: 'Terms & Conditions', name: 'terms_accepted'}),
|
|
],
|
|
form_props: {state: 'step3'},
|
|
},
|
|
};
|
|
|
|
// Public API functions
|
|
function getFullDialog(triggerId, webhookBaseUrl) {
|
|
return createDialog(triggerId, webhookBaseUrl, DIALOG_CONFIGS.full);
|
|
}
|
|
|
|
function getSimpleDialog(triggerId, webhookBaseUrl) {
|
|
return createDialog(triggerId, webhookBaseUrl, DIALOG_CONFIGS.simple);
|
|
}
|
|
|
|
function getUserAndChannelDialog(triggerId, webhookBaseUrl) {
|
|
return createDialog(triggerId, webhookBaseUrl, DIALOG_CONFIGS.userAndChannel);
|
|
}
|
|
|
|
function getBooleanDialog(triggerId, webhookBaseUrl) {
|
|
return createDialog(triggerId, webhookBaseUrl, DIALOG_CONFIGS.boolean);
|
|
}
|
|
|
|
function getFieldRefreshDialog(triggerId, webhookBaseUrl) {
|
|
const config = {...DIALOG_CONFIGS.fieldRefresh};
|
|
config.source_url = `${webhookBaseUrl}/field_refresh_source`;
|
|
return createDialog(triggerId, webhookBaseUrl, config);
|
|
}
|
|
|
|
function getMultistepStep1Dialog(triggerId, webhookBaseUrl) {
|
|
return createDialog(triggerId, webhookBaseUrl, DIALOG_CONFIGS.multistepStep1);
|
|
}
|
|
|
|
function getMultistepStep2Dialog(triggerId, webhookBaseUrl) {
|
|
const config = {...DIALOG_CONFIGS.multistepStep2};
|
|
config.dialog_props = {url: `${webhookBaseUrl}/dialog_submit`, ...config.form_props};
|
|
return createFormResponse(config);
|
|
}
|
|
|
|
function getMultistepStep3Dialog(triggerId, webhookBaseUrl) {
|
|
const config = {...DIALOG_CONFIGS.multistepStep3};
|
|
config.dialog_props = {url: `${webhookBaseUrl}/dialog_submit`, ...config.form_props};
|
|
return createFormResponse(config);
|
|
}
|
|
|
|
function getMultiSelectDialog(triggerId, webhookBaseUrl, includeDefaults = false) {
|
|
return {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/dialog_submit`,
|
|
dialog: {
|
|
callback_id: 'somecallbackid',
|
|
title: 'Title for Dialog Test with multiselect elements',
|
|
icon_url:
|
|
'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
|
submit_label: 'Submit Multiselect Test',
|
|
notify_on_cancel: true,
|
|
state: 'somestate',
|
|
elements: [
|
|
{
|
|
display_name: 'Multi Option Selector',
|
|
name: 'multiselect_options',
|
|
type: 'select',
|
|
multiselect: true,
|
|
default: includeDefaults ? 'opt1,opt3' : '',
|
|
placeholder: 'Select multiple options...',
|
|
help_text: 'You can select multiple options from this list.',
|
|
optional: false,
|
|
min_length: 0,
|
|
max_length: 0,
|
|
data_source: '',
|
|
options: [
|
|
{
|
|
text: 'Engineering',
|
|
value: 'opt1',
|
|
},
|
|
{
|
|
text: 'Sales',
|
|
value: 'opt2',
|
|
},
|
|
{
|
|
text: 'Marketing',
|
|
value: 'opt3',
|
|
},
|
|
{
|
|
text: 'Support',
|
|
value: 'opt4',
|
|
},
|
|
{
|
|
text: 'Product',
|
|
value: 'opt5',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
display_name: 'Multi User Selector',
|
|
name: 'multiselect_users',
|
|
type: 'select',
|
|
multiselect: true,
|
|
default: '',
|
|
placeholder: 'Select multiple users...',
|
|
help_text: 'Choose multiple users from the team.',
|
|
optional: false,
|
|
min_length: 0,
|
|
max_length: 0,
|
|
data_source: 'users',
|
|
options: null,
|
|
},
|
|
{
|
|
display_name: 'Single Option Selector',
|
|
name: 'single_select_options',
|
|
type: 'select',
|
|
multiselect: false,
|
|
default: includeDefaults ? 'single2' : '',
|
|
placeholder: 'Select one option...',
|
|
help_text: 'This is a regular single-select for comparison.',
|
|
optional: false,
|
|
min_length: 0,
|
|
max_length: 0,
|
|
data_source: '',
|
|
options: [
|
|
{
|
|
text: 'Single Option 1',
|
|
value: 'single1',
|
|
},
|
|
{
|
|
text: 'Single Option 2',
|
|
value: 'single2',
|
|
},
|
|
{
|
|
text: 'Single Option 3',
|
|
value: 'single3',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
};
|
|
}
|
|
|
|
function getDynamicSelectDialog(triggerId, webhookBaseUrl) {
|
|
return {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/dialog_submit`,
|
|
dialog: {
|
|
callback_id: 'somecallbackid',
|
|
title: 'Title for Dialog Test with dynamic select element',
|
|
icon_url:
|
|
'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
|
submit_label: 'Submit Dynamic Select Test',
|
|
notify_on_cancel: true,
|
|
state: 'somestate',
|
|
elements: [
|
|
{
|
|
display_name: 'Dynamic Role Selector',
|
|
name: 'dynamic_role_selector',
|
|
type: 'select',
|
|
data_source: 'dynamic',
|
|
data_source_url: `${webhookBaseUrl}/dynamic_select_source`,
|
|
default: '',
|
|
placeholder: 'Search for a role...',
|
|
help_text: 'Start typing to search for available roles. Options are loaded dynamically.',
|
|
optional: false,
|
|
min_length: 0,
|
|
max_length: 0,
|
|
},
|
|
{
|
|
display_name: 'Optional Dynamic Selector',
|
|
name: 'optional_dynamic_selector',
|
|
type: 'select',
|
|
data_source: 'dynamic',
|
|
data_source_url: `${webhookBaseUrl}/dynamic_select_source`,
|
|
default: 'backend_eng',
|
|
placeholder: 'Search for another role...',
|
|
help_text: 'This field is optional and has a default value.',
|
|
optional: true,
|
|
min_length: 0,
|
|
max_length: 0,
|
|
},
|
|
],
|
|
},
|
|
};
|
|
}
|
|
|
|
// Basic date field test - MM-T2530A
|
|
function getBasicDateDialog(triggerId, webhookBaseUrl) {
|
|
return {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/datetime_dialog_submit`,
|
|
dialog: {
|
|
callback_id: 'basic_date_callback',
|
|
title: 'DateTime Fields Test',
|
|
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
|
elements: [
|
|
{
|
|
display_name: 'Event Date',
|
|
name: 'event_date',
|
|
type: 'date',
|
|
default: '',
|
|
placeholder: 'Select a date',
|
|
help_text: 'Select the date for your event',
|
|
optional: false,
|
|
},
|
|
],
|
|
submit_label: 'Submit',
|
|
notify_on_cancel: true,
|
|
state: 'datetime_state',
|
|
},
|
|
};
|
|
}
|
|
|
|
// Basic datetime field test - MM-T2530B
|
|
function getBasicDateTimeDialog(triggerId, webhookBaseUrl) {
|
|
return {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/datetime_dialog_submit`,
|
|
dialog: {
|
|
callback_id: 'basic_datetime_callback',
|
|
title: 'DateTime Fields Test',
|
|
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
|
elements: [
|
|
{
|
|
display_name: 'Event Date',
|
|
name: 'event_date',
|
|
type: 'date',
|
|
default: '',
|
|
placeholder: 'Select a date',
|
|
help_text: 'Select the date for your event',
|
|
optional: false,
|
|
},
|
|
{
|
|
display_name: 'Meeting Time',
|
|
name: 'meeting_time',
|
|
type: 'datetime',
|
|
default: '',
|
|
placeholder: 'Select date and time',
|
|
help_text: 'Select the date and time for your meeting',
|
|
optional: false,
|
|
time_interval: 60,
|
|
},
|
|
],
|
|
submit_label: 'Submit',
|
|
notify_on_cancel: true,
|
|
state: 'datetime_state',
|
|
},
|
|
};
|
|
}
|
|
|
|
// Date field with min_date constraint - MM-T2530C
|
|
function getMinDateConstraintDialog(triggerId, webhookBaseUrl) {
|
|
return {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/datetime_dialog_submit`,
|
|
dialog: {
|
|
callback_id: 'mindate_callback',
|
|
title: 'DateTime Fields Test',
|
|
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
|
elements: [
|
|
{
|
|
display_name: 'Future Date Only',
|
|
name: 'future_date',
|
|
type: 'date',
|
|
default: '',
|
|
placeholder: 'Select a future date',
|
|
help_text: 'Must be today or later',
|
|
optional: true,
|
|
min_date: 'today',
|
|
},
|
|
],
|
|
submit_label: 'Submit',
|
|
notify_on_cancel: true,
|
|
state: 'datetime_state',
|
|
},
|
|
};
|
|
}
|
|
|
|
// DateTime field with custom time interval - MM-T2530D
|
|
function getCustomIntervalDialog(triggerId, webhookBaseUrl) {
|
|
return {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/datetime_dialog_submit`,
|
|
dialog: {
|
|
callback_id: 'interval_callback',
|
|
title: 'DateTime Fields Test',
|
|
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
|
elements: [
|
|
{
|
|
display_name: 'Custom Interval Time',
|
|
name: 'interval_time',
|
|
type: 'datetime',
|
|
default: '',
|
|
placeholder: 'Select time (30min intervals)',
|
|
help_text: 'Time picker with 30-minute intervals',
|
|
optional: true,
|
|
time_interval: 30,
|
|
},
|
|
],
|
|
submit_label: 'Submit',
|
|
notify_on_cancel: true,
|
|
state: 'datetime_state',
|
|
},
|
|
};
|
|
}
|
|
|
|
// Relative date values test - MM-T2530F
|
|
function getRelativeDateDialog(triggerId, webhookBaseUrl) {
|
|
return {
|
|
trigger_id: triggerId,
|
|
url: `${webhookBaseUrl}/datetime_dialog_submit`,
|
|
dialog: {
|
|
callback_id: 'relative_callback',
|
|
title: 'DateTime Fields Test',
|
|
icon_url: 'https://mattermost.com/wp-content/uploads/2022/02/icon_WS.png',
|
|
elements: [
|
|
{
|
|
display_name: 'Relative Date Example',
|
|
name: 'relative_date',
|
|
type: 'date',
|
|
default: 'today',
|
|
placeholder: 'Today by default',
|
|
help_text: 'Defaults to today using relative date',
|
|
optional: true,
|
|
},
|
|
{
|
|
display_name: 'Relative DateTime Example',
|
|
name: 'relative_datetime',
|
|
type: 'datetime',
|
|
default: '+1d',
|
|
placeholder: 'Tomorrow by default',
|
|
help_text: 'Defaults to tomorrow using relative date',
|
|
optional: true,
|
|
},
|
|
],
|
|
submit_label: 'Submit',
|
|
notify_on_cancel: true,
|
|
state: 'datetime_state',
|
|
},
|
|
};
|
|
}
|
|
|
|
// Legacy function for backward compatibility - returns basic datetime dialog
|
|
function getDateTimeDialog(triggerId, webhookBaseUrl) {
|
|
return getBasicDateTimeDialog(triggerId, webhookBaseUrl);
|
|
}
|
|
|
|
function getTimezoneManualDialog(triggerId, webhookBaseUrl) {
|
|
return createDialog(triggerId, webhookBaseUrl, {
|
|
callback_id: 'timezone_manual',
|
|
title: 'Timezone & Manual Entry Demo',
|
|
introduction_text: '**Timezone & Manual Entry Demo**\n\n' +
|
|
'This dialog demonstrates timezone support and manual time entry features.',
|
|
elements: [
|
|
{
|
|
display_name: 'Your Local Time (Manual Entry)',
|
|
name: 'local_manual',
|
|
type: 'datetime',
|
|
help_text: 'Type any time: 9am, 14:30, 3:45pm - no rounding',
|
|
datetime_config: {
|
|
allow_manual_time_entry: true,
|
|
},
|
|
optional: true,
|
|
},
|
|
{
|
|
display_name: 'London Office Hours (Dropdown)',
|
|
name: 'london_dropdown',
|
|
type: 'datetime',
|
|
help_text: 'Times shown in GMT - select from 60 min intervals',
|
|
datetime_config: {
|
|
location_timezone: 'Europe/London',
|
|
time_interval: 60,
|
|
},
|
|
optional: true,
|
|
},
|
|
{
|
|
display_name: 'London Office Hours (Manual Entry)',
|
|
name: 'london_manual',
|
|
type: 'datetime',
|
|
help_text: 'Type time in GMT: 9am, 14:30, 3:45pm - no rounding',
|
|
datetime_config: {
|
|
location_timezone: 'Europe/London',
|
|
allow_manual_time_entry: true,
|
|
},
|
|
optional: true,
|
|
},
|
|
],
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
getFullDialog,
|
|
getSimpleDialog,
|
|
getUserAndChannelDialog,
|
|
getBooleanDialog,
|
|
getFieldRefreshDialog,
|
|
getMultistepStep1Dialog,
|
|
getMultistepStep2Dialog,
|
|
getMultistepStep3Dialog,
|
|
getMultiSelectDialog,
|
|
getDynamicSelectDialog,
|
|
getDateTimeDialog,
|
|
getBasicDateDialog,
|
|
getBasicDateTimeDialog,
|
|
getMinDateConstraintDialog,
|
|
getCustomIntervalDialog,
|
|
getRelativeDateDialog,
|
|
getTimezoneManualDialog,
|
|
};
|