mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 02:00:10 +02:00
Only check a user's features for importing from reference provider (#3797)
GitOrigin-RevId: cc5a36be20c673f8941a2694eaeba80eebb4db6a
This commit is contained in:
@@ -19,7 +19,7 @@ aside.editor-sidebar.full-size(
|
||||
on-select="onSelect"
|
||||
on-init="onInit"
|
||||
is-connected="isConnected"
|
||||
has-feature="hasFeature"
|
||||
user-has-feature="hasFeature"
|
||||
ref-providers="refProviders"
|
||||
reindex-references="reindexReferences"
|
||||
set-ref-provider-enabled="setRefProviderEnabled"
|
||||
|
||||
@@ -17,7 +17,7 @@ function FileTreeContext({
|
||||
rootFolder,
|
||||
hasWritePermissions,
|
||||
rootDocId,
|
||||
hasFeature,
|
||||
userHasFeature,
|
||||
refProviders,
|
||||
reindexReferences,
|
||||
setRefProviderEnabled,
|
||||
@@ -29,7 +29,7 @@ function FileTreeContext({
|
||||
<FileTreeMainProvider
|
||||
projectId={projectId}
|
||||
hasWritePermissions={hasWritePermissions}
|
||||
hasFeature={hasFeature}
|
||||
userHasFeature={userHasFeature}
|
||||
refProviders={refProviders}
|
||||
setRefProviderEnabled={setRefProviderEnabled}
|
||||
setStartedFreeTrial={setStartedFreeTrial}
|
||||
@@ -54,7 +54,7 @@ FileTreeContext.propTypes = {
|
||||
projectId: PropTypes.string.isRequired,
|
||||
rootFolder: PropTypes.array.isRequired,
|
||||
hasWritePermissions: PropTypes.bool.isRequired,
|
||||
hasFeature: PropTypes.func.isRequired,
|
||||
userHasFeature: PropTypes.func.isRequired,
|
||||
reindexReferences: PropTypes.func.isRequired,
|
||||
refProviders: PropTypes.object.isRequired,
|
||||
setRefProviderEnabled: PropTypes.func.isRequired,
|
||||
|
||||
@@ -24,7 +24,7 @@ function FileTreeRoot({
|
||||
rootFolder,
|
||||
rootDocId,
|
||||
hasWritePermissions,
|
||||
hasFeature,
|
||||
userHasFeature,
|
||||
refProviders,
|
||||
reindexReferences,
|
||||
setRefProviderEnabled,
|
||||
@@ -44,7 +44,7 @@ function FileTreeRoot({
|
||||
<FileTreeContext
|
||||
projectId={projectId}
|
||||
hasWritePermissions={hasWritePermissions}
|
||||
hasFeature={hasFeature}
|
||||
userHasFeature={userHasFeature}
|
||||
refProviders={refProviders}
|
||||
setRefProviderEnabled={setRefProviderEnabled}
|
||||
setStartedFreeTrial={setStartedFreeTrial}
|
||||
@@ -100,7 +100,7 @@ FileTreeRoot.propTypes = {
|
||||
onInit: PropTypes.func.isRequired,
|
||||
isConnected: PropTypes.bool.isRequired,
|
||||
setRefProviderEnabled: PropTypes.func.isRequired,
|
||||
hasFeature: PropTypes.func.isRequired,
|
||||
userHasFeature: PropTypes.func.isRequired,
|
||||
setStartedFreeTrial: PropTypes.func.isRequired,
|
||||
reindexReferences: PropTypes.func.isRequired,
|
||||
refProviders: PropTypes.object.isRequired
|
||||
|
||||
@@ -18,7 +18,7 @@ export function useFileTreeMainContext() {
|
||||
export const FileTreeMainProvider = function({
|
||||
projectId,
|
||||
hasWritePermissions,
|
||||
hasFeature,
|
||||
userHasFeature,
|
||||
refProviders,
|
||||
reindexReferences,
|
||||
setRefProviderEnabled,
|
||||
@@ -32,7 +32,7 @@ export const FileTreeMainProvider = function({
|
||||
value={{
|
||||
projectId,
|
||||
hasWritePermissions,
|
||||
hasFeature,
|
||||
userHasFeature,
|
||||
refProviders,
|
||||
reindexReferences,
|
||||
setRefProviderEnabled,
|
||||
@@ -49,7 +49,7 @@ export const FileTreeMainProvider = function({
|
||||
FileTreeMainProvider.propTypes = {
|
||||
projectId: PropTypes.string.isRequired,
|
||||
hasWritePermissions: PropTypes.bool.isRequired,
|
||||
hasFeature: PropTypes.func.isRequired,
|
||||
userHasFeature: PropTypes.func.isRequired,
|
||||
reindexReferences: PropTypes.func.isRequired,
|
||||
refProviders: PropTypes.object.isRequired,
|
||||
setRefProviderEnabled: PropTypes.func.isRequired,
|
||||
|
||||
@@ -82,8 +82,7 @@ App.controller('ReactFileTreeController', function(
|
||||
}
|
||||
}
|
||||
|
||||
$scope.hasFeature = feature =>
|
||||
ide.$scope.project.features[feature] || ide.$scope.user.features[feature]
|
||||
$scope.userHasFeature = feature => ide.$scope.user.features[feature]
|
||||
|
||||
$scope.$watch('permissions.write', hasWritePermissions => {
|
||||
$scope.hasWritePermissions = hasWritePermissions
|
||||
|
||||
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types'
|
||||
const defaultContextProps = {
|
||||
projectId: 'project-1',
|
||||
hasWritePermissions: true,
|
||||
hasFeature: () => true,
|
||||
userHasFeature: () => true,
|
||||
refProviders: {},
|
||||
reindexReferences: () => {
|
||||
console.log('reindex references')
|
||||
|
||||
@@ -5,7 +5,7 @@ import FileTreeModalCreateFile from '../../../js/features/file-tree/components/m
|
||||
export const MinimalFeatures = args => <FileTreeModalCreateFile {...args} />
|
||||
MinimalFeatures.decorators = [
|
||||
createFileModalDecorator({
|
||||
hasFeature: () => false
|
||||
userHasFeature: () => false
|
||||
})
|
||||
]
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import sinon from 'sinon'
|
||||
export const contextProps = {
|
||||
projectId: 'test-project',
|
||||
hasWritePermissions: true,
|
||||
hasFeature: () => true,
|
||||
userHasFeature: () => true,
|
||||
refProviders: {},
|
||||
reindexReferences: () => {
|
||||
console.log('reindex references')
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions={false}
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -72,7 +72,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -113,7 +113,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
onSelect={onSelect}
|
||||
onInit={onInit}
|
||||
isConnected={false}
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -142,7 +142,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
projectId="123abc"
|
||||
rootDocId="456def"
|
||||
hasWritePermissions={false}
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -195,7 +195,7 @@ describe('<FileTreeRoot/>', function() {
|
||||
projectId="123abc"
|
||||
rootDocId="456def"
|
||||
hasWritePermissions={false}
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('FileTree Context Menu Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -57,7 +57,7 @@ describe('FileTree Context Menu Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions={false}
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -100,7 +100,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -170,7 +170,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -229,7 +229,7 @@ describe('FileTree Create Folder Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -153,7 +153,7 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
@@ -207,7 +207,7 @@ describe('FileTree Delete Entity Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('FileTree Rename Entity Flow', function() {
|
||||
rootFolder={rootFolder}
|
||||
projectId="123abc"
|
||||
hasWritePermissions
|
||||
hasFeature={() => true}
|
||||
userHasFeature={() => true}
|
||||
refProviders={{}}
|
||||
reindexReferences={() => null}
|
||||
setRefProviderEnabled={() => null}
|
||||
|
||||
@@ -14,7 +14,7 @@ export default (children, options = {}) => {
|
||||
}
|
||||
],
|
||||
hasWritePermissions: true,
|
||||
hasFeature: () => true,
|
||||
userHasFeature: () => true,
|
||||
refProviders: {},
|
||||
reindexReferences: () => {
|
||||
console.log('reindex references')
|
||||
|
||||
Reference in New Issue
Block a user