Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-133459 / 25.04 / Allow From Name and Email to be used with oAuth email config #11320

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h3>{{ 'Email' | translate }}</h3>
</mat-list-item>

<ng-container *ixWithLoadingState="emailConfig$ as emailConfig">
@if (!emailConfig?.oauth?.client_id) {
@if (emailConfig?.fromemail || emailConfig?.fromname) {
<mat-list-item>
<span class="label">{{ 'From' | translate }}:</span>
<span *ixWithLoadingState="emailConfig$ as emailConfig" class="value">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ describe('EmailCardComponent with Gmail OAuth', () => {

expect(itemTexts).toEqual([
'Send Mail Method: GMail OAuth',
'From: Test [email protected] via google.com',
]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
[options]="sendMethodOptions$"
></ix-radio-group>

@if (isSmtp) {
<ix-input
formControlName="fromemail"
[label]="'From Email' | translate"
[required]="true"
[tooltip]="helptext.fromemail.tooltip | translate"
></ix-input>
<ix-input
formControlName="fromemail"
[label]="'From Email' | translate"
[required]="isSmtp"
[tooltip]="helptext.fromemail.tooltip | translate"
></ix-input>

<ix-input
formControlName="fromname"
[label]="'From Name' | translate"
[tooltip]="helptext.fromname.tooltip | translate"
></ix-input>
<ix-input
formControlName="fromname"
[label]="'From Name' | translate"
[tooltip]="helptext.fromname.tooltip | translate"
></ix-input>

@if (isSmtp) {
<ix-input
formControlName="outgoingserver"
[label]="'Outgoing Mail Server' | translate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ describe('EmailFormComponent', () => {

it('saves Gmail Oauth config when user authorizes via Gmail and saves the form', async () => {
await form.fillForm({
'From Email': '[email protected]',
'From Name': 'Johnny',
'Send Mail Method': 'GMail OAuth',
});

Expand All @@ -169,8 +171,8 @@ describe('EmailFormComponent', () => {
await saveButton.click();

expect(api.call).toHaveBeenCalledWith('mail.update', [{
fromemail: '',
fromname: '',
fromemail: '[email protected]',
fromname: 'Johnny',
oauth: {
client_id: 'new_client_id',
client_secret: 'new_secret',
Expand Down Expand Up @@ -202,8 +204,8 @@ describe('EmailFormComponent', () => {
text: 'This is a test message from TrueNAS SCALE.',
},
{
fromemail: '',
fromname: '',
fromemail: '[email protected]',
fromname: 'John Smith',
oauth: {
client_id: 'new_client_id',
client_secret: 'new_secret',
Expand Down Expand Up @@ -253,6 +255,8 @@ describe('EmailFormComponent', () => {

it('saves Outlook Oauth config when user authorizes via Outlook and saves the form', async () => {
await form.fillForm({
'From Email': '[email protected]',
'From Name': 'Johnny',
'Send Mail Method': 'Outlook OAuth',
});

Expand All @@ -263,8 +267,8 @@ describe('EmailFormComponent', () => {
await saveButton.click();

expect(api.call).toHaveBeenCalledWith('mail.update', [{
fromemail: '',
fromname: '',
fromemail: '[email protected]',
fromname: 'Johnny',
outgoingserver: 'smtp-mail.outlook.com',
port: 587,
security: 'TLS',
Expand Down Expand Up @@ -299,8 +303,8 @@ describe('EmailFormComponent', () => {
text: 'This is a test message from TrueNAS SCALE.',
},
{
fromemail: '',
fromname: '',
fromemail: '[email protected]',
fromname: 'John Smith',
outgoingserver: 'smtp-mail.outlook.com',
port: 587,
security: 'TLS',
Expand Down Expand Up @@ -426,6 +430,8 @@ describe('EmailFormComponent', () => {
const values = await form.getValues();

expect(values).toEqual({
'From Email': '[email protected]',
'From Name': 'John Smith',
'Send Mail Method': 'GMail OAuth',
});
expect(spectator.query('.oauth-message')).toHaveText('Gmail credentials have been applied.');
Expand Down Expand Up @@ -458,6 +464,8 @@ describe('EmailFormComponent', () => {
const values = await form.getValues();

expect(values).toEqual({
'From Email': '[email protected]',
'From Name': 'John Smith',
'Send Mail Method': 'Outlook OAuth',
});
expect(spectator.query('.oauth-message')).toHaveText('Outlook credentials have been applied.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class EmailFormComponent implements OnInit {
sendMethodControl = new FormControl(MailSendMethod.Smtp, { nonNullable: true });

form = this.formBuilder.group({
fromemail: ['', [Validators.required, emailValidator()]],
fromemail: ['', [emailValidator()]],
fromname: [''],
outgoingserver: [''],
port: [null as number | null, [
Expand Down Expand Up @@ -271,8 +271,8 @@ export class EmailFormComponent implements OnInit {
}
} else {
update = {
fromemail: '',
fromname: '',
fromemail: this.form.value.fromemail,
fromname: this.form.value.fromname,
oauth: {
...this.oauthCredentials as MailOauthConfig,
provider: this.sendMethodControl.value,
Expand Down
8 changes: 4 additions & 4 deletions src/assets/i18n/ko.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"": "",
"Enable General Purpose OS STIG compatibility mode": "범용 운영체제 STIG 호환 모드 활성화",
"Enable this mode to enhance system security to meet US federal government security requirements. Note that enabling STIG mode will restrict some functionality.": "이 모드를 활성화하여 미국 연방 정부 보안 요구 사항을 충족하도록 시스템 보안을 강화합니다. STIG 모드를 활성화하면 일부 기능이 제한됩니다.",
"Restart is required after changing these settings.": "이 설정들을 바꾼 후에는 재시작이 필요합니다.",
"\n It looks like your session has been inactive for more than {lifetime} seconds.<br>\n For security reasons we will log you out at {time}.\n ": "세션의 비활성화 시간이 {lifetime}초를 넘었습니다.<br />보안을 위해 {time}에 로그아웃 되었습니다.",
" Est. Usable Raw Capacity": " 사용 가능한 원시 용량 추정",
" When the <b>UPS Mode</b> is set to <i>slave</i>. Enter the open network port number of the UPS <i>Master</i> system. The default port is <i>3493</i>.": " <b>UPS 모드</b>가 <i>슬레이브</i>일 때, <i>마스터</i> UPS 시스템의 네트워크 포트 번호를 입력합니다. 기본 포트는 <i>3493</i>입니다.",
Expand Down Expand Up @@ -1594,6 +1591,7 @@
"Enable FSRVP": "FSRVP 활성화",
"Enable FXP": "FXP 활성화",
"Enable GMail OAuth authentication.": "GMail OAuth 인증을 활성화합니다.",
"Enable General Purpose OS STIG compatibility mode": "범용 운영체제 STIG 호환 모드 활성화",
"Enable HTTPS Redirect": "HTTPS 재연결 활성화",
"Enable Hyper-V Enlightenments": "Hyper-V Enlightenments 활성화",
"Enable Kernel Debug": "커널 디버그 활성화",
Expand Down Expand Up @@ -1628,6 +1626,7 @@
"Enable this SMB share. Unset to disable this SMB share without deleting it.": "이 SMB 공유를 활성화합니다. 설정하지 않으면 이 SMB 공유를 삭제하지 않고 비활성화합니다.",
"Enable this TrueCloud Backup Task. Unset to disable this TrueCloud Backup Task without deleting it.": "이 TrueCloud 백업 작업을 활성화합니다. 설정하지 않으면 이 TrueCloud 백업 작업을 삭제하지 않고 비활성화합니다.",
"Enable this cron job. When unset, disable the cron job without deleting it.": "이 Cron 작업을 활성화합니다. 설정하지 않으면 이 Cron 작업을 삭제하지 않고 비활성화합니다.",
"Enable this mode to enhance system security to meet US federal government security requirements. Note that enabling STIG mode will restrict some functionality.": "이 모드를 활성화하여 미국 연방 정부 보안 요구 사항을 충족하도록 시스템 보안을 강화합니다. STIG 모드를 활성화하면 일부 기능이 제한됩니다.",
"Enable this rsync task. Unset to disable this rsync task without deleting it.": "이 Rsync 작업을 활성화합니다. 설정하지 않으면 이 Rsync 작업을 삭제하지 않고 비활성화합니다",
"Enable this service to start automatically.": "이 서비스를 자동으로 시작합니다.",
"Enable this task. Unset to disable the task without deleting it.": "이 작업을 활성화합니다. 설정하지 않으면 이 작업을 삭제하지 않고 비활성화합니다.",
Expand Down Expand Up @@ -3555,6 +3554,7 @@
"Restart Standby": "재시작 대기",
"Restart Web Service": "웹 서비스 재시작",
"Restart is recommended for new FIPS setting to take effect. Would you like to restart now?": "새로운 FIPS 설정이 작용하기 위해 재시작을 권장합니다. 지금 재시작하시겠습니까?",
"Restart is required after changing these settings.": "이 설정들을 바꾼 후에는 재시작이 필요합니다.",
"Restart of a remote system is required for new FIPS setting to take effect. Would you like to restart standby now?": "새로운 FIPS 설정을 적용하기 위해 원격 시스템을 재시작해야 합니다. 지금 재시작하시겠습니까?",
"Restart standby TrueNAS controller": "대기중인 TrueNAS 컨트롤러 재시작",
"Restart to improve system performance speed.": "재시작하여 시스템 성능 속도를 개선합니다.",
Expand Down Expand Up @@ -5321,4 +5321,4 @@
"{used} of {total} ({used_pct})": "{total} 중 {used} ({used_pct})",
"{version} is available!": "{version}이 준비되었습니다!",
"{view} on {enclosure}": "{enclousure}의 {view}"
}
}
Loading