chore: enable vaults if dev mode or if user has role (#2483)
This commit is contained in:
@@ -262,6 +262,7 @@ export class WebDependencies extends DependencyContainer {
|
||||
this.get<FilesController>(Web_TYPES.FilesController),
|
||||
this.get<SubscriptionController>(Web_TYPES.SubscriptionController),
|
||||
this.get<NavigationController>(Web_TYPES.NavigationController),
|
||||
this.get<FeaturesController>(Web_TYPES.FeaturesController),
|
||||
this.get<ItemGroupController>(Web_TYPES.ItemGroupController),
|
||||
this.get<VaultDisplayService>(Web_TYPES.VaultDisplayService),
|
||||
application.preferences,
|
||||
|
||||
@@ -3,7 +3,6 @@ import { useApplication } from '../ApplicationProvider'
|
||||
import Icon from '../Icon/Icon'
|
||||
import { DecryptedItemInterface, classNames } from '@standardnotes/snjs'
|
||||
import VaultNameBadge from '../Vaults/VaultNameBadge'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
|
||||
type Props = {
|
||||
item: DecryptedItemInterface
|
||||
@@ -13,7 +12,7 @@ type Props = {
|
||||
const ListItemVaultInfo: FunctionComponent<Props> = ({ item, className }) => {
|
||||
const application = useApplication()
|
||||
|
||||
if (!featureTrunkVaultsEnabled()) {
|
||||
if (!application.featuresController.isEntitledToVaults()) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import AddTagOption from '../NotesOptions/AddTagOption'
|
||||
import { MenuItemIconSize } from '@/Constants/TailwindClassNames'
|
||||
import AddToVaultMenuOption from '../Vaults/AddToVaultMenuOption'
|
||||
import { iconClass } from '../NotesOptions/ClassNames'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import { useApplication } from '../ApplicationProvider'
|
||||
|
||||
type Props = {
|
||||
@@ -87,7 +86,9 @@ const FileMenuOptions: FunctionComponent<Props> = ({
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
{featureTrunkVaultsEnabled() && <AddToVaultMenuOption iconClassName={iconClass} items={selectedFiles} />}
|
||||
{application.featuresController.isEntitledToVaults() && (
|
||||
<AddToVaultMenuOption iconClassName={iconClass} items={selectedFiles} />
|
||||
)}
|
||||
<AddTagOption
|
||||
navigationController={application.navigationController}
|
||||
linkingController={application.linkingController}
|
||||
|
||||
@@ -5,7 +5,6 @@ import Popover from '../Popover/Popover'
|
||||
import StyledTooltip from '../StyledTooltip/StyledTooltip'
|
||||
import VaultSelectionMenu from '../VaultSelectionMenu/VaultSelectionMenu'
|
||||
import { useApplication } from '../ApplicationProvider'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import RoundIconButton from '../Button/RoundIconButton'
|
||||
|
||||
const VaultSelectionButton = ({ isMobileNavigation = false }: { isMobileNavigation?: boolean }) => {
|
||||
@@ -16,7 +15,7 @@ const VaultSelectionButton = ({ isMobileNavigation = false }: { isMobileNavigati
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
const toggleMenu = () => setIsOpen(!isOpen)
|
||||
|
||||
if (!featureTrunkVaultsEnabled()) {
|
||||
if (!application.featuresController.isEntitledToVaults()) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import { FunctionComponent } from 'react'
|
||||
import Icon from '../Icon/Icon'
|
||||
import { useApplication } from '../ApplicationProvider'
|
||||
import { DecryptedItemInterface } from '@standardnotes/snjs'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import VaultNameBadge from '../Vaults/VaultNameBadge'
|
||||
|
||||
type Props = {
|
||||
@@ -12,7 +11,7 @@ type Props = {
|
||||
const CollaborationInfoHUD: FunctionComponent<Props> = ({ item }) => {
|
||||
const application = useApplication()
|
||||
|
||||
if (!featureTrunkVaultsEnabled()) {
|
||||
if (!application.featuresController.isEntitledToVaults()) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -32,7 +31,7 @@ const CollaborationInfoHUD: FunctionComponent<Props> = ({ item }) => {
|
||||
<VaultNameBadge vault={vault} />
|
||||
|
||||
{lastEditedBy && (
|
||||
<div title="Last edited by" className="flex rounded bg-info px-1.5 py-1 text-info-contrast select-none">
|
||||
<div title="Last edited by" className="flex select-none rounded bg-info px-1.5 py-1 text-info-contrast">
|
||||
<Icon ariaLabel="Shared by" type="pencil" className="mr-1 text-info-contrast" size="medium" />
|
||||
<span className="mr-auto overflow-hidden text-ellipsis text-xs">{lastEditedBy?.name}</span>
|
||||
</div>
|
||||
|
||||
@@ -41,7 +41,6 @@ import SuperExportModal from './SuperExportModal'
|
||||
import { useApplication } from '../ApplicationProvider'
|
||||
import { MutuallyExclusiveMediaQueryBreakpoints } from '@/Hooks/useMediaQuery'
|
||||
import AddToVaultMenuOption from '../Vaults/AddToVaultMenuOption'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import Menu from '../Menu/Menu'
|
||||
import Popover from '../Popover/Popover'
|
||||
|
||||
@@ -267,7 +266,9 @@ const NotesOptions = ({ notes, closeMenu }: NotesOptionsProps) => {
|
||||
)}
|
||||
<HorizontalSeparator classes="my-2" />
|
||||
|
||||
{featureTrunkVaultsEnabled() && <AddToVaultMenuOption iconClassName={iconClass} items={notes} />}
|
||||
{application.featuresController.isEntitledToVaults() && (
|
||||
<AddToVaultMenuOption iconClassName={iconClass} items={notes} />
|
||||
)}
|
||||
|
||||
{application.navigationController.tagsCount > 0 && (
|
||||
<AddTagOption
|
||||
|
||||
@@ -6,7 +6,6 @@ import Spinner from '../Spinner/Spinner'
|
||||
import { PasswordStep } from './PasswordStep'
|
||||
import { FinishStep } from './FinishStep'
|
||||
import { PreprocessingStep } from './PreprocessingStep'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
|
||||
interface Props {
|
||||
application: WebApplication
|
||||
@@ -50,7 +49,7 @@ class PasswordWizard extends AbstractComponent<Props, State> {
|
||||
continueTitle: DEFAULT_CONTINUE_TITLE,
|
||||
}
|
||||
|
||||
if (featureTrunkVaultsEnabled()) {
|
||||
if (props.application.featuresController.isEntitledToVaults()) {
|
||||
this.state = {
|
||||
...baseState,
|
||||
lockContinue: true,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PackageProvider } from '../Panes/General/Advanced/Packages/Provider/Pac
|
||||
import { securityPrefsHasBubble } from '../Panes/Security/securityPrefsHasBubble'
|
||||
import { PreferencePaneId, StatusServiceEvent } from '@standardnotes/services'
|
||||
import { isDesktopApplication } from '@/Utils'
|
||||
import { featureTrunkHomeServerEnabled, featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import { featureTrunkHomeServerEnabled } from '@/FeatureTrunk'
|
||||
import { PreferencesMenuItem } from './PreferencesMenuItem'
|
||||
import { SelectableMenuItem } from './SelectableMenuItem'
|
||||
import { PREFERENCES_MENU_ITEMS, READY_PREFERENCES_MENU_ITEMS } from './MenuItems'
|
||||
@@ -26,7 +26,7 @@ export class PreferencesSessionController {
|
||||
? PREFERENCES_MENU_ITEMS.slice()
|
||||
: READY_PREFERENCES_MENU_ITEMS.slice()
|
||||
|
||||
if (featureTrunkVaultsEnabled()) {
|
||||
if (application.featuresController.isEntitledToVaults()) {
|
||||
menuItems.push({ id: 'vaults', label: 'Vaults', icon: 'safe-square', order: 5 })
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import { PaneLayout } from '@/Controllers/PaneController/PaneLayout'
|
||||
import { usePaneSwipeGesture } from '../Panes/usePaneGesture'
|
||||
import { mergeRefs } from '@/Hooks/mergeRefs'
|
||||
import { useAvailableSafeAreaPadding } from '@/Hooks/useSafeAreaPadding'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import QuickSettingsButton from '../Footer/QuickSettingsButton'
|
||||
import VaultSelectionButton from '../Footer/VaultSelectionButton'
|
||||
|
||||
@@ -131,7 +130,7 @@ const Navigation = forwardRef<HTMLDivElement, Props>(({ application, className,
|
||||
icon="tune"
|
||||
/>
|
||||
<QuickSettingsButton application={application} isMobileNavigation />
|
||||
{featureTrunkVaultsEnabled() && <VaultSelectionButton isMobileNavigation />}
|
||||
{application.featuresController.isEntitledToVaults() && <VaultSelectionButton isMobileNavigation />}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,6 @@ import { PremiumFeatureIconClass, PremiumFeatureIconName } from '../Icon/Premium
|
||||
import Popover from '../Popover/Popover'
|
||||
import IconPicker from '../Icon/IconPicker'
|
||||
import AddToVaultMenuOption from '../Vaults/AddToVaultMenuOption'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
import { useApplication } from '../ApplicationProvider'
|
||||
|
||||
type ContextMenuProps = {
|
||||
@@ -82,7 +81,7 @@ const TagContextMenu = ({ navigationController, isEntitledToFolders, selectedTag
|
||||
iconGridClassName="max-h-30"
|
||||
/>
|
||||
<HorizontalSeparator classes="my-2" />
|
||||
{featureTrunkVaultsEnabled() && (
|
||||
{application.featuresController.isEntitledToVaults() && (
|
||||
<AddToVaultMenuOption iconClassName="mr-2 text-neutral" items={[selectedTag]} />
|
||||
)}
|
||||
<MenuItem className={'justify-between py-1.5'} onClick={onClickStar}>
|
||||
|
||||
@@ -7,7 +7,6 @@ import { classNames, DecryptedItemInterface, VaultListingInterface } from '@stan
|
||||
import { useApplication } from '../ApplicationProvider'
|
||||
import MenuItem from '../Menu/MenuItem'
|
||||
import Menu from '../Menu/Menu'
|
||||
import { featureTrunkVaultsEnabled } from '@/FeatureTrunk'
|
||||
|
||||
const VaultMenu = observer(({ items }: { items: DecryptedItemInterface[] }) => {
|
||||
const application = useApplication()
|
||||
@@ -107,6 +106,7 @@ const VaultMenu = observer(({ items }: { items: DecryptedItemInterface[] }) => {
|
||||
})
|
||||
|
||||
const AddToVaultMenuOption = ({ iconClassName, items }: { iconClassName: string; items: DecryptedItemInterface[] }) => {
|
||||
const application = useApplication()
|
||||
const buttonRef = useRef<HTMLButtonElement>(null)
|
||||
|
||||
const [isSubMenuOpen, setIsSubMenuOpen] = useState(false)
|
||||
@@ -115,7 +115,7 @@ const AddToVaultMenuOption = ({ iconClassName, items }: { iconClassName: string;
|
||||
setIsSubMenuOpen((isOpen) => !isOpen)
|
||||
}, [])
|
||||
|
||||
if (!featureTrunkVaultsEnabled()) {
|
||||
if (!application.featuresController.isEntitledToVaults()) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -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