Skip to content
Open
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
@@ -1,4 +1,3 @@
export enum InternalFeature {
Vaults = 'vaults',
Localization = 'localization',
}
1 change: 0 additions & 1 deletion packages/web/src/javascripts/Application/DevMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { WebApplicationInterface } from '@standardnotes/ui-services'
export class DevMode {
constructor(private application: WebApplicationInterface) {
InternalFeatureService.get().enableFeature(InternalFeature.Vaults)
InternalFeatureService.get().enableFeature(InternalFeature.Localization)
}

/** Valid only when running a mock event publisher on port 3124 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const General: FunctionComponent = () => {
<NewNoteDefaults />
<Tools application={application} />
<SmartViews application={application} featuresController={application.featuresController} />
{application.featuresController.isLocalizationFeatureAvailable() && <Language application={application} />}
<Language application={application} />
<Moments application={application} />
<LabsPane application={application} />
<OfflineActivation />
Expand Down
13 changes: 1 addition & 12 deletions packages/web/src/javascripts/Controllers/FeaturesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { action, makeObservable, observable, runInAction, when } from 'mobx'
import { AbstractViewController } from './Abstract/AbstractViewController'
import { CrossControllerEvent } from './CrossControllerEvent'
import { featureTrunkLocalizationEnabled, featureTrunkVaultsEnabled } from '@/FeatureTrunk'
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'

export class FeaturesController extends AbstractViewController implements InternalEventHandlerInterface {
hasFolders: boolean
Expand Down Expand Up @@ -148,22 +148,11 @@ export class FeaturesController extends AbstractViewController implements Intern
)
}

isLocalizationFeatureAvailable(): boolean {
return (
featureTrunkLocalizationEnabled() ||
this.features.hasRole(RoleName.create(RoleName.NAMES.InternalTeamUser).getValue())
)
}

toggleLocalization(): void {
this.features.toggleExperimentalFeature(NativeFeatureIdentifier.TYPES.Localization)
}

isLocalizationEnabled(): boolean {
if (!this.isLocalizationFeatureAvailable()) {
return false
}

return this.features.isExperimentalFeatureEnabled(NativeFeatureIdentifier.TYPES.Localization)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ describe('LocalizationController', () => {
const originalLocation = window.location
let reload: jest.Mock
let localizationEnabled: boolean
let localizationAvailable: boolean

const featuresController = {
isLocalizationEnabled: () => localizationEnabled,
isLocalizationFeatureAvailable: () => localizationAvailable,
toggleLocalization: () => {
localizationEnabled = !localizationEnabled
},
Expand Down Expand Up @@ -76,7 +74,6 @@ describe('LocalizationController', () => {
})

localizationEnabled = true
localizationAvailable = true
setBrowserLanguages(['en-US'])
localStorage.setItem('sn-has-seen-localization-spotlight', 'true')
mockCurrentLocale = 'en_US'
Expand Down Expand Up @@ -160,21 +157,6 @@ describe('LocalizationController', () => {
expect(localizationStore.availableLocales).toEqual(catalog)
})

it('loads the language list once the feature becomes available', async () => {
localizationEnabled = false
localizationAvailable = false
mockLocaleService.getAvailableLocales.mockClear()

const controller = await bootWithLocale('en_US')
expect(mockLocaleService.getAvailableLocales).not.toHaveBeenCalled()

localizationAvailable = true
await sendEvent(controller, ApplicationEvent.FeaturesAvailabilityChanged)
await flushPromises()

expect(localizationStore.availableLocales).toEqual(catalog)
})

it('keeps the saved language and reports an error when the catalog fails to load', async () => {
persistLocale(workspaceIdentifier, 'fr_FR')
mockLocaleService.getAvailableLocales.mockRejectedValue(new Error('offline'))
Expand Down Expand Up @@ -256,17 +238,6 @@ describe('LocalizationController', () => {
expect(controller.labsSpotlightOpen).toBe(true)
})

it('opens once the feature becomes available, e.g. after signing in', async () => {
localizationAvailable = false
const controller = await bootWithLocale('en_US')
expect(controller.labsSpotlightOpen).toBe(false)

localizationAvailable = true
await sendEvent(controller, ApplicationEvent.FeaturesAvailabilityChanged)

expect(controller.labsSpotlightOpen).toBe(true)
})

it('stays dismissed when the feature availability is checked again', async () => {
const controller = await bootWithLocale('en_US')
controller.dismissLabsSpotlight()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export class LocalizationController extends AbstractViewController implements In
const routeType = this.routeService.getRoute().type

return (
this.featuresController.isLocalizationFeatureAvailable() &&
!this.featuresController.isLocalizationEnabled() &&
!hasSeenLabsSpotlight() &&
routeType !== RouteType.Purchase &&
Expand Down Expand Up @@ -199,7 +198,7 @@ export class LocalizationController extends AbstractViewController implements In

/** Loaded while localization is still off so the language dropdown can show as soon as it's turned on. */
private async preloadAvailableLocales(): Promise<void> {
if (this.availableLocalesRequested || !this.featuresController.isLocalizationFeatureAvailable()) {
if (this.availableLocalesRequested) {
return
}
this.availableLocalesRequested = true
Expand Down
4 changes: 0 additions & 4 deletions packages/web/src/javascripts/FeatureTrunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ export function featureTrunkEnabled(trunk: FeatureTrunkName): boolean {
export function featureTrunkVaultsEnabled(): boolean {
return InternalFeatureService.get().isFeatureEnabled(InternalFeature.Vaults)
}

export function featureTrunkLocalizationEnabled(): boolean {
return InternalFeatureService.get().isFeatureEnabled(InternalFeature.Localization)
}
Loading