Skip to content

Commit

Permalink
Add warning text for public access setting (#4350)
Browse files Browse the repository at this point in the history
  • Loading branch information
anbebe authored Nov 18, 2024
1 parent 1a84c60 commit 9b905d7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,14 @@
<div>
<mat-checkbox formControlName="value">{{ setting.label | translate }}</mat-checkbox>
@if (setting.helpText) {
<mat-hint class="hint-checkbox">{{ setting.helpText | translate }}</mat-hint>
<mat-hint class="hint-checkbox settings-form-group">
{{ setting.helpText | translate }}
</mat-hint>
}
@if (getWarning()) {
<mat-hint class="hint-checkbox red-warning-text">
{{ setting.warnText | translate }}
</mat-hint>
}
@if (error) {
<div class="error">{{ error }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ export class MeetingSettingsGroupDetailFieldComponent extends BaseComponent impl
this.cd.detach();
}

/**
* Checks if a warning should be given
*
*/
public getWarning(): boolean {
if (this.setting.warn) {
return this.setting.warn(this.orgaSettings);
} else {
return false;
}
}

public getRestrictedValue<T>(value: T): T {
if (this.setting.restrictionFn) {
return this.setting.restrictionFn(this.orgaSettings, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface SettingsInput<V = any> {
// alternative to `choices`; overwrites `choices` if both are given
choicesFunc?: ChoicesFunctionDefinition<V>;
helpText?: string; // default: ""
warnText?: string; // default: ""
indentation?: number; // default: 0. Indents the input field by the given amount to simulate nested settings
validators?: ValidatorFn[]; // default: []
automaticChangesSetting?: SettingsItemAutomaticChangeSetting<V>;
Expand Down Expand Up @@ -88,6 +89,13 @@ export interface SettingsInput<V = any> {
* @returns whether to disable the setting or not
*/
forbidden?: (meetingView: ViewMeeting) => boolean;
/**
* A function to conditionally give a warning depending on used organization's settings
*
* @param orgaSettings: The `OrganizationSettingsService` has to be passed, because it is not injected in the
* settings definitions
*/
warn?: (orgaSettings: OrganizationSettingsService) => boolean;

hide?: boolean; // Hide the setting in the settings view
}
Expand Down Expand Up @@ -207,7 +215,11 @@ export const meetingSettings: SettingsGroup[] = fillInSettingsDefaults([
type: `boolean`,
helpText: _(
`Enables public access to this meeting without login data. Permissions can be set after activation in the new group 'Public'.`
)
),
warnText: _(
`The public access setting is deactivated for the organization. Please contact your admins or hosting providers to activate the setting.`
),
warn: orgaSettings => !orgaSettings.instant(`enable_anonymous`)
}
]
},
Expand Down

0 comments on commit 9b905d7

Please sign in to comment.