mattermost-community-enterp.../public/pluginapi/experimental/panel/settings/read_only_setting.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

70 lines
1.5 KiB
Go

package settings
import (
"errors"
"fmt"
"github.com/mattermost/mattermost/server/public/model"
)
type readOnlySetting struct {
baseSetting
store SettingStore
}
// NewReadOnlySetting creates a new panel value that only read from the setting
func NewReadOnlySetting(id, title, description, dependsOn string, store SettingStore) Setting {
return &readOnlySetting{
baseSetting: baseSetting{
title: title,
description: description,
id: id,
dependsOn: dependsOn,
},
store: store,
}
}
func (s *readOnlySetting) Get(userID string) (any, error) {
value, err := s.store.GetSetting(userID, s.id)
if err != nil {
return "", err
}
stringValue, ok := value.(string)
if !ok {
return "", errors.New("current value is not a string")
}
return stringValue, nil
}
func (s *readOnlySetting) Set(userID string, value any) error {
return nil
}
func (s *readOnlySetting) GetSlackAttachments(userID, settingHandler string, disabled bool) (*model.SlackAttachment, error) {
title := fmt.Sprintf("Setting: %s", s.title)
currentValueMessage := DisabledString
if !disabled {
currentValue, err := s.Get(userID)
if err != nil {
return nil, err
}
currentValueMessage = fmt.Sprintf("Current value: %s", currentValue)
}
text := fmt.Sprintf("%s\n%s", s.description, currentValueMessage)
sa := model.SlackAttachment{
Title: title,
Text: text,
Fallback: fmt.Sprintf("%s: %s", title, text),
}
return &sa, nil
}
func (s *readOnlySetting) IsDisabled(foreignValue any) bool {
return foreignValue == FalseString
}