chore: enable vaults if dev mode or if user has role (#2483)
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
import { action, makeObservable, observable, runInAction, when } from 'mobx'
|
||||
import { AbstractViewController } from './Abstract/AbstractViewController'
|
||||
import { CrossControllerEvent } from './CrossControllerEvent'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
|
||||
export class FeaturesController extends AbstractViewController implements InternalEventHandlerInterface {
|
||||
hasFolders: boolean
|
||||
@@ -128,4 +129,13 @@ export class FeaturesController extends AbstractViewController implements Intern
|
||||
|
||||
return status === FeatureStatus.Entitled
|
||||
}
|
||||
|
||||
isEntitledToVaults(): boolean {
|
||||
const status = this.features.getFeatureStatus(
|
||||
NativeFeatureIdentifier.create(NativeFeatureIdentifier.TYPES.SharedVaults).getValue(),
|
||||
)
|
||||
const isEntitledToFeature = status === FeatureStatus.Entitled
|
||||
|
||||
return featureTrunkVaultsEnabled() || isEntitledToFeature
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import { LinkingController } from './LinkingController'
|
||||
import { NavigationController } from './Navigation/NavigationController'
|
||||
import { SubscriptionController } from './Subscription/SubscriptionController'
|
||||
import { getLinkingSearchResults } from '@/Utils/Items/Search/getSearchResults'
|
||||
import { FeaturesController } from './FeaturesController'
|
||||
|
||||
const createNote = (name: string, options?: Partial<SNNote>) => {
|
||||
return {
|
||||
@@ -63,11 +64,13 @@ describe('LinkingController', () => {
|
||||
itemListController: {} as jest.Mocked<ItemListController>,
|
||||
filesController: {} as jest.Mocked<FilesController>,
|
||||
subscriptionController: {} as jest.Mocked<SubscriptionController>,
|
||||
featuresController: {} as jest.Mocked<FeaturesController>,
|
||||
} as unknown as jest.Mocked<WebApplication>
|
||||
|
||||
application.getPreference = jest.fn()
|
||||
application.addSingleEventObserver = jest.fn()
|
||||
application.sync.sync = jest.fn()
|
||||
application.featuresController.isEntitledToVaults = jest.fn().mockReturnValue(true)
|
||||
|
||||
Object.defineProperty(application, 'items', { value: {} as jest.Mocked<ItemManagerInterface> })
|
||||
|
||||
@@ -81,6 +84,7 @@ describe('LinkingController', () => {
|
||||
application.filesController,
|
||||
application.subscriptionController,
|
||||
application.navigationController,
|
||||
application.featuresController,
|
||||
application.itemControllerGroup,
|
||||
application.vaultDisplayService,
|
||||
application.preferences,
|
||||
|
||||
@@ -32,9 +32,9 @@ import { FilesController } from './FilesController'
|
||||
import { ItemListController } from './ItemList/ItemListController'
|
||||
import { NavigationController } from './Navigation/NavigationController'
|
||||
import { SubscriptionController } from './Subscription/SubscriptionController'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import { ItemGroupController } from '@/Components/NoteView/Controller/ItemGroupController'
|
||||
import { VaultDisplayServiceInterface } from '@standardnotes/ui-services'
|
||||
import { FeaturesController } from './FeaturesController'
|
||||
|
||||
export class LinkingController extends AbstractViewController implements InternalEventHandlerInterface {
|
||||
shouldLinkToParentFolders: boolean
|
||||
@@ -45,6 +45,7 @@ export class LinkingController extends AbstractViewController implements Interna
|
||||
private filesController: FilesController,
|
||||
private subscriptionController: SubscriptionController,
|
||||
private navigationController: NavigationController,
|
||||
private featuresController: FeaturesController,
|
||||
private itemControllerGroup: ItemGroupController,
|
||||
private vaultDisplayService: VaultDisplayServiceInterface,
|
||||
private preferences: PreferenceServiceInterface,
|
||||
@@ -207,7 +208,7 @@ export class LinkingController extends AbstractViewController implements Interna
|
||||
const linkNoteAndFile = async (note: SNNote, file: FileItem) => {
|
||||
const updatedFile = await this.mutator.associateFileWithNote(file, note)
|
||||
|
||||
if (featureTrunkVaultsEnabled()) {
|
||||
if (this.featuresController.isEntitledToVaults()) {
|
||||
if (updatedFile) {
|
||||
const noteVault = this.vaults.getItemVault(note)
|
||||
const fileVault = this.vaults.getItemVault(updatedFile)
|
||||
|
||||
Reference in New Issue
Block a user