-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:truenas/webui into NAS-134329
# Conflicts: # src/assets/i18n/it.json
- Loading branch information
Showing
115 changed files
with
6,498 additions
and
5,632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ules/ix-table/components/ix-table-body/cells/ix-cell-checkbox/ix-cell-checkbox.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ContentContainerComponentHarness } from '@angular/cdk/testing'; | ||
import { MatCheckboxHarness } from '@angular/material/checkbox/testing'; | ||
|
||
export class IxCellCheckboxHarness extends ContentContainerComponentHarness { | ||
static readonly hostSelector = 'ix-cell-checkbox'; | ||
|
||
async check(): Promise<void> { | ||
const checkbox = await this.getHarness(MatCheckboxHarness); | ||
await checkbox.check(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import { ContentContainerComponentHarness } from '@angular/cdk/testing'; | ||
import { | ||
IxCellCheckboxHarness, | ||
} from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-checkbox/ix-cell-checkbox.harness'; | ||
|
||
export class IxRowHarness extends ContentContainerComponentHarness { | ||
static readonly hostSelector = '.row'; | ||
|
||
async check(): Promise<void> { | ||
const checkbox = await this.getHarness(IxCellCheckboxHarness); | ||
await checkbox.check(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/app/modules/use-enterprise-marketing-link/use-enterprise-marketing-link.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<a | ||
ixTest="use-enterprise-marketing-link" | ||
target="_blank" | ||
[href]="currentMessageHref()" | ||
> | ||
<span class="text-above"> | ||
{{ currentMessage() }} | ||
</span> | ||
|
||
<span class="text-below"> | ||
{{ 'Explore TrueNAS Enterprise' | translate }} | ||
</span> | ||
</a> |
23 changes: 23 additions & 0 deletions
23
src/app/modules/use-enterprise-marketing-link/use-enterprise-marketing-link.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@import 'scss-imports/variables'; | ||
|
||
:host { | ||
margin: 0 auto 5px; | ||
} | ||
|
||
a { | ||
cursor: pointer; | ||
display: block; | ||
margin-bottom: 2px; | ||
text-align: center; | ||
text-decoration: none; | ||
|
||
span { | ||
color: var(--primary-txt); | ||
display: block; | ||
|
||
&.text-above { | ||
color: var(--primary); | ||
margin-bottom: 2px; | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...app/modules/use-enterprise-marketing-link/use-enterprise-marketing-link.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest'; | ||
import { UseEnterpriseMarketingLinkComponent } from './use-enterprise-marketing-link.component'; | ||
|
||
const lastShownDate = 'marketingMessageLastShownDate'; | ||
const lastMessageHash = 'marketingMessageLastHash'; | ||
|
||
describe('UseEnterpriseMarketingLinkComponent', () => { | ||
let spectator: Spectator<UseEnterpriseMarketingLinkComponent>; | ||
|
||
const createComponent = createComponentFactory({ | ||
component: UseEnterpriseMarketingLinkComponent, | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent(); | ||
jest.spyOn(global.Date.prototype, 'toDateString').mockReturnValue('2025-02-26'); | ||
localStorage.clear(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('should display the first message by default', () => { | ||
const message = spectator.component.currentMessage(); | ||
expect(message).toBe('Optimize Your Storage'); | ||
}); | ||
|
||
it('should rotate to the next message on a new day', () => { | ||
localStorage.setItem(lastShownDate, '2025-02-25'); | ||
localStorage.setItem(lastMessageHash, spectator.component.hashMessage('Optimize Your Storage')); | ||
|
||
const nextMessage = spectator.component.getTodaysMessage(); | ||
expect(nextMessage).toBe('More Performance, More Protection'); | ||
}); | ||
|
||
it('should loop to the first message after the last message', () => { | ||
localStorage.setItem(lastShownDate, '2025-02-25'); | ||
localStorage.setItem(lastMessageHash, spectator.component.hashMessage('5 Nines of Uptime with HA')); | ||
|
||
const nextMessage = spectator.component.getTodaysMessage(); | ||
expect(nextMessage).toBe('Optimize Your Storage'); | ||
}); | ||
|
||
it('should update localStorage with new date and hash', () => { | ||
spectator.component.getTodaysMessage(); | ||
|
||
expect(localStorage.getItem(lastShownDate)).toBe('2025-02-26'); | ||
expect(localStorage.getItem(lastMessageHash)).toBe(spectator.component.hashMessage('Optimize Your Storage')); | ||
}); | ||
|
||
it('should maintain consistent message even if array order changes', () => { | ||
const originalHash = spectator.component.hashMessage('Boost Performance & Support'); | ||
localStorage.setItem('marketingMessageLastShownDate', '2025-02-25'); | ||
localStorage.setItem('marketingMessageLastHash', originalHash); | ||
|
||
spectator.component.messages = [ | ||
'Boost Performance & Support', | ||
'Optimize Your Storage', | ||
'More Performance, More Protection', | ||
]; | ||
|
||
const nextMessage = spectator.component.getTodaysMessage(); | ||
expect(nextMessage).toBe('Optimize Your Storage'); | ||
}); | ||
|
||
it('should return the first message if hash is not found', () => { | ||
localStorage.setItem(lastShownDate, '2025-02-26'); | ||
localStorage.setItem(lastMessageHash, 'unknownHash'); | ||
|
||
const currentMessage = spectator.component.getTodaysMessage(); | ||
expect(currentMessage).toBe('Optimize Your Storage'); | ||
}); | ||
|
||
it('should not change message within the same day', () => { | ||
localStorage.setItem(lastShownDate, '2025-02-26'); | ||
localStorage.setItem(lastMessageHash, spectator.component.hashMessage('Optimize Your Storage')); | ||
|
||
const currentMessage = spectator.component.getTodaysMessage(); | ||
expect(currentMessage).toBe('Optimize Your Storage'); | ||
}); | ||
}); |
68 changes: 68 additions & 0 deletions
68
src/app/modules/use-enterprise-marketing-link/use-enterprise-marketing-link.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { | ||
Component, ChangeDetectionStrategy, computed, | ||
} from '@angular/core'; | ||
import { TranslateModule, TranslateService } from '@ngx-translate/core'; | ||
import { TestDirective } from 'app/modules/test-id/test.directive'; | ||
|
||
@Component({ | ||
selector: 'ix-use-enterprise-marketing-link', | ||
templateUrl: './use-enterprise-marketing-link.component.html', | ||
styleUrls: ['./use-enterprise-marketing-link.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [ | ||
TestDirective, | ||
TranslateModule, | ||
], | ||
}) | ||
export class UseEnterpriseMarketingLinkComponent { | ||
protected readonly targetUrl = 'https://truenas.com/explore-truenas-enterprise/'; | ||
|
||
messages = [ | ||
this.translate.instant('Optimize Your Storage'), | ||
this.translate.instant('More Performance, More Protection'), | ||
this.translate.instant('Boost Performance & Support'), | ||
this.translate.instant('Unlock High Performance Solutions'), | ||
this.translate.instant('Expert Support When You Need It'), | ||
this.translate.instant('5 Nines of Uptime with HA'), | ||
]; | ||
|
||
currentMessage = computed(() => this.getTodaysMessage()); | ||
currentMessageHref = computed(() => `${this.targetUrl}?m=${this.hashMessage(this.currentMessage())}`); | ||
|
||
constructor( | ||
private translate: TranslateService, | ||
) {} | ||
|
||
getTodaysMessage(): string { | ||
const today = new Date().toDateString(); | ||
const lastShownDate = localStorage.getItem('marketingMessageLastShownDate'); | ||
const lastMessageHash = localStorage.getItem('marketingMessageLastHash'); | ||
|
||
if (lastShownDate !== today) { | ||
const nextMessage = this.getNextMessage(lastMessageHash); | ||
|
||
localStorage.setItem('marketingMessageLastShownDate', today); | ||
localStorage.setItem('marketingMessageLastHash', this.hashMessage(nextMessage)); | ||
|
||
return nextMessage; | ||
} | ||
|
||
return this.getCurrentMessage(lastMessageHash); | ||
} | ||
|
||
getNextMessage(lastMessageHash: string | null): string { | ||
const lastIndex = this.messages.findIndex((message) => this.hashMessage(message) === lastMessageHash); | ||
const nextIndex = lastIndex >= 0 ? (lastIndex + 1) % this.messages.length : 0; | ||
return this.messages[nextIndex]; | ||
} | ||
|
||
getCurrentMessage(lastMessageHash: string | null): string { | ||
const currentIndex = this.messages.findIndex((message) => this.hashMessage(message) === lastMessageHash); | ||
return currentIndex >= 0 ? this.messages[currentIndex] : this.messages[0]; | ||
} | ||
|
||
hashMessage(message: string): string { | ||
return btoa(encodeURIComponent(message)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,7 @@ | |
} | ||
} | ||
} | ||
|
||
.use-enterprise { | ||
height: calc(var(--mdc-list-list-item-one-line-container-height, 48px) * 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.