Skip to content

Commit

Permalink
NAS-133694: Update usage of system.product_type (#11367)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKarpov98 authored Jan 22, 2025
1 parent 0827c36 commit 4c1930f
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 92 deletions.
8 changes: 4 additions & 4 deletions src/app/enums/product-type.enum.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export enum ProductType {
Scale = 'SCALE',
ScaleEnterprise = 'SCALE_ENTERPRISE',
CommunityEdition = 'COMMUNITY_EDITION',
Enterprise = 'ENTERPRISE',
}

export const productTypeLabels = new Map<ProductType, string>([
[ProductType.Scale, ''],
[ProductType.ScaleEnterprise, 'ENTERPRISE'],
[ProductType.CommunityEdition, ''],
[ProductType.Enterprise, 'ENTERPRISE'],
]);
10 changes: 5 additions & 5 deletions src/app/modules/feedback/services/feedback.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('FeedbackService', () => {
selectors: [
{
selector: selectProductType,
value: ProductType.ScaleEnterprise,
value: ProductType.Enterprise,
},
{
selector: selectSystemInfoState,
Expand All @@ -75,7 +75,7 @@ describe('FeedbackService', () => {
}),
mockProvider(MatSnackBar),
mockProvider(SystemGeneralService, {
getProductType: jest.fn(() => ProductType.ScaleEnterprise),
getProductType: jest.fn(() => ProductType.Enterprise),
}),
mockWindow({
location: {
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('FeedbackService', () => {
message: 'Git gud',
page: '/storage',
product_model: 'M40',
product_type: ProductType.ScaleEnterprise,
product_type: ProductType.Enterprise,
rating: 1,
release: 'SCALE-24.04',
user_agent: 'Safari',
Expand All @@ -314,7 +314,7 @@ describe('FeedbackService', () => {
message: 'Git gud',
page: '/storage',
product_model: 'M40',
product_type: ProductType.ScaleEnterprise,
product_type: ProductType.Enterprise,
rating: 1,
release: 'SCALE-24.04',
user_agent: 'Safari',
Expand Down Expand Up @@ -348,7 +348,7 @@ describe('FeedbackService', () => {
message: 'Git gud',
page: '/storage',
product_model: 'M40',
product_type: ProductType.ScaleEnterprise,
product_type: ProductType.Enterprise,
rating: 5,
release: 'SCALE-24.04',
user_agent: 'Safari',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('WidgetSysInfoActiveComponent', () => {
selectors: [
{
selector: selectProductType,
value: ProductType.ScaleEnterprise,
value: ProductType.Enterprise,
},
{
selector: selectIsEnterprise,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('WidgetSysInfoPassiveComponent', () => {
selectors: [
{
selector: selectProductType,
value: ProductType.ScaleEnterprise,
value: ProductType.Enterprise,
},
{
selector: selectIsEnterprise,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('OtherOptionsSectionComponent', () => {
mockCall('pool.dataset.recommended_zvol_blocksize', '256K' as DatasetRecordSize),
]),
mockProvider(SystemGeneralService, {
getProductType: jest.fn(() => ProductType.Scale),
getProductType: jest.fn(() => ProductType.CommunityEdition),
}),
mockProvider(DialogService, {
confirm: jest.fn(() => of(true)),
Expand Down Expand Up @@ -409,7 +409,7 @@ describe('OtherOptionsSectionComponent', () => {

it('does not show deduplication field on Enterprise systems that do not have a dedup license', async () => {
const systemGeneralService = spectator.inject(SystemGeneralService);
jest.spyOn(systemGeneralService, 'getProductType').mockReturnValue(ProductType.ScaleEnterprise);
jest.spyOn(systemGeneralService, 'getProductType').mockReturnValue(ProductType.Enterprise);
const store$ = spectator.inject(MockStore);
store$.overrideSelector(selectSystemInfo, {
license: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class OtherOptionsSectionComponent implements OnInit, OnChanges {
this.hasDeduplication = false;
this.cdr.markForCheck();

if (this.systemGeneralService.getProductType() !== ProductType.ScaleEnterprise) {
if (this.systemGeneralService.getProductType() !== ProductType.Enterprise) {
this.hasDeduplication = true;
this.cdr.markForCheck();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class NetworkConfigurationComponent implements OnInit {
},
);

if (this.systemGeneralService.getProductType() === ProductType.ScaleEnterprise) {
if (this.systemGeneralService.getProductType() === ProductType.Enterprise) {
this.store$.select(selectIsHaLicensed).pipe(untilDestroyed(this)).subscribe((isHaLicensed) => {
this.hostnameB.hidden = !isHaLicensed;
this.hostnameVirtual.hidden = !isHaLicensed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('InterfaceFormComponent', () => {
components$: of([]),
}),
mockProvider(SystemGeneralService, {
getProductType: () => ProductType.ScaleEnterprise,
getProductType: () => ProductType.Enterprise,
}),
mockProvider(SlideInRef, slideInRef),
mockAuth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export class InterfaceFormComponent implements OnInit {
}

private loadFailoverStatus(): void {
if (this.systemGeneralService.getProductType() !== ProductType.ScaleEnterprise) {
if (this.systemGeneralService.getProductType() !== ProductType.Enterprise) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ describe('IpmiFormComponent', () => {

describe('product type is SCALE_ENTERPRISE', () => {
beforeEach(async () => {
await setupTest(ProductType.ScaleEnterprise);
await setupTest(ProductType.Enterprise);
});

it('loads data with controller radio buttons in the form for ScaleEnterprise', async () => {
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('IpmiFormComponent', () => {

describe('product type is SCALE', () => {
beforeEach(async () => {
await setupTest(ProductType.Scale);
await setupTest(ProductType.CommunityEdition);
});

it('loads data in the form if the product type is SCALE', async () => {
Expand All @@ -238,7 +238,7 @@ describe('IpmiFormComponent', () => {

describe('IPMI lights', () => {
beforeEach(async () => {
await setupTest(ProductType.ScaleEnterprise);
await setupTest(ProductType.Enterprise);
});

it('flashes IPMI light when Flash Identify Light is pressed', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export class IpmiFormComponent implements OnInit {
}

private loadFailoverData(): Observable<unknown> {
if (this.systemGeneralService.getProductType() !== ProductType.ScaleEnterprise) {
if (this.systemGeneralService.getProductType() !== ProductType.Enterprise) {
return of(null);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/network/network.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class NetworkComponent implements OnInit {
this.cdr.markForCheck();
});

if (this.systemGeneralService.getProductType() === ProductType.ScaleEnterprise) {
if (this.systemGeneralService.getProductType() === ProductType.Enterprise) {
this.listenForHaStatus();
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/network/tests/checkin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('NetworkComponent', () => {
confirm: jest.fn(() => of(true)),
}),
mockProvider(SystemGeneralService, {
getProductType$: of(ProductType.Scale),
getProductType$: of(ProductType.CommunityEdition),
}),
mockProvider(SlideInRef, slideInRef),
mockProvider(SlideIn, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('AdvancedSettingsComponent', () => {
provideMockStore({
selectors: [{
selector: selectProductType,
value: ProductType.Scale,
value: ProductType.CommunityEdition,
}],
}),
],
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('AdvancedSettingsComponent', () => {

it('enterprise: shows cards with advanced settings', () => {
const store$ = spectator.inject(MockStore);
store$.overrideSelector(selectProductType, ProductType.ScaleEnterprise);
store$.overrideSelector(selectProductType, ProductType.Enterprise);
store$.refreshState();

spectator.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('SystemSecurityFormComponent', () => {
}),
mockProvider(SnackbarService),
mockProvider(SystemGeneralService, {
getProductType: () => ProductType.Scale,
getProductType: () => ProductType.CommunityEdition,
}),
mockProvider(SlideInRef, {
close: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('EmailFormComponent', () => {
}),
mockProvider(SnackbarService),
mockProvider(SystemGeneralService, {
getProductType: () => ProductType.Scale,
getProductType: () => ProductType.CommunityEdition,
}),
mockWindow({
open: jest.fn(),
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('EmailFormComponent', () => {
[
{
subject: 'Test Message',
text: 'This is a test message from TrueNAS SCALE.',
text: 'This is a test message from TrueNAS COMMUNITY EDITION.',
},
{
fromemail: 'from@ixsystems.com',
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('EmailFormComponent', () => {
[
{
subject: 'Test Message',
text: 'This is a test message from TrueNAS SCALE.',
text: 'This is a test message from TrueNAS COMMUNITY EDITION.',
},
{
fromemail: 'from@ixsystems.com',
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('EmailFormComponent', () => {
[
{
subject: 'Test Message',
text: 'This is a test message from TrueNAS SCALE.',
text: 'This is a test message from TrueNAS COMMUNITY EDITION.',
},
{
fromemail: 'from@ixsystems.com',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class EmailFormComponent implements OnInit {
const productType = this.systemGeneralService.getProductType();
const email = {
subject: 'Test Message',
text: `This is a test message from TrueNAS ${productType}.`,
text: `This is a test message from TrueNAS ${productType.replace('_', ' ')}.`,
};
const config = this.prepareConfigUpdate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('SupportCardComponent', () => {
mockApi([
mockCall('truenas.is_production', true),
mockJob('truenas.set_production', fakeSuccessfulJob()),
mockCall('system.product_type', ProductType.Scale),
mockCall('system.product_type', ProductType.CommunityEdition),
]),
provideMockStore({
selectors: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('ManualUpdateFormComponent', () => {
}),
mockWindow({
localStorage: {
getItem: () => ProductType.ScaleEnterprise,
getItem: () => ProductType.Enterprise,
},
}),
provideMockStore({
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/navigation/navigation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class NavigationService {
{
name: 'KMIP',
state: 'kmip',
isVisible$: of(this.systemGeneralService.getProductType() === ProductType.ScaleEnterprise),
isVisible$: of(this.systemGeneralService.getProductType() === ProductType.Enterprise),
},
],
},
Expand Down Expand Up @@ -149,7 +149,7 @@ export class NavigationService {
}

private checkForEnterpriseLicenses(): void {
if (this.systemGeneralService.getProductType() !== ProductType.ScaleEnterprise) {
if (this.systemGeneralService.getProductType() !== ProductType.Enterprise) {
this.hasVms$.next(true);
this.hasApps$.next(true);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/system-general.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class SystemGeneralService {
* Use selectIsEnterprise selector instead
*/
get isEnterprise(): boolean {
return this.getProductType() === ProductType.ScaleEnterprise;
return this.getProductType() === ProductType.Enterprise;
}

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ export class SystemGeneralService {
* Use selectIsEnterprise selector instead
*/
readonly isEnterprise$ = this.getProductType$.pipe(
map((productType) => productType === ProductType.ScaleEnterprise),
map((productType) => productType === ProductType.Enterprise),
shareReplay({ refCount: true, bufferSize: 1 }),
);

Expand Down
2 changes: 1 addition & 1 deletion src/app/store/eula/eula.effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('EulaEffects', () => {
provideMockStore({
selectors: [{
selector: selectProductType,
value: ProductType.ScaleEnterprise,
value: ProductType.Enterprise,
}],
}),
mockAuth(),
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/system-info/system-info.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SystemInfoEffects {
map((productType) => productTypeLoaded({ productType })),
catchError((error: unknown) => {
console.error(error);
return of(productTypeLoaded({ productType: ProductType.Scale }));
return of(productTypeLoaded({ productType: ProductType.CommunityEdition }));
}),
);
}),
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/system-info/system-info.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface SystemInfoState {

const initialState: SystemInfoState = {
systemInfo: null,
productType: ProductType.Scale,
productType: ProductType.CommunityEdition,
isIxHardware: false,
buildYear: environment.buildYear,
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/system-info/system-info.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const selectProductType = createSelector(

export const selectIsEnterprise = createSelector(
selectProductType,
(productType) => productType === ProductType.ScaleEnterprise,
(productType) => productType === ProductType.Enterprise,
);

export const selectBuildYear = createSelector(
Expand Down
Loading

0 comments on commit 4c1930f

Please sign in to comment.