Skip to content

Commit

Permalink
revert basePath defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi committed Jun 30, 2024
1 parent 5d60c6c commit 69bae99
Show file tree
Hide file tree
Showing 19 changed files with 8 additions and 112 deletions.
1 change: 0 additions & 1 deletion examples/auth/keystone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default withAuth<TypeInfo<Session>>(
},
lists,
ui: {
basePath: '/',
// only admins can view the AdminUI
isAccessAllowed: (context) => {
return context.session?.data?.isAdmin ?? false
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/pages/SigninPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TextInput } from '@keystone-ui/fields'
import { Notice } from '@keystone-ui/notice'

import { useMutation, gql } from '@keystone-6/core/admin-ui/apollo'
import { useKeystone, useRawKeystone, useReinitContext } from '@keystone-6/core/admin-ui/context'
import { useRawKeystone, useReinitContext } from '@keystone-6/core/admin-ui/context'
import { useRouter } from '@keystone-6/core/admin-ui/router'
import { SigninContainer } from '../components/SigninContainer'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export function HomePage () {
const {
adminMeta: { lists },
visibleLists,
adminPath,
} = useKeystone()
const query = useMemo(
() => gql`
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/admin-ui/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const writeAdminFiles = (
graphQLSchema,
{ configFileExists },
config.graphql?.path || '/api/graphql',
config.ui?.basePath?.replace(/\/$/, '') || ''
config.ui?.basePath || ''
),
overwrite: true,
outputPath: `.admin/index.${ext}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/createAdminUIMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export function createAdminUIMiddlewareWithNextApp (
isAccessAllowed,
pageMiddleware,
publicPages,
basePath,
},
} = config

const basePath = config.ui?.basePath?.replace(/\/$/, '') || ''
if (basePath.endsWith('/')) throw new TypeError('basePath must not end with a trailing slash')

return async (req: express.Request, res: express.Response) => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/lib/createSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function getSystemPaths (cwd: string, config: KeystoneConfig | __Resolved

const srcPath = path.join(cwd, 'src')
const hasSrc = fs.existsSync(srcPath)
// remove leading `/` if present
const basePath = config.ui?.basePath?.replace(/^\//, '') ?? ''
const adminPath = path.join(cwd, hasSrc ? 'src' : '', `app/${basePath || '(admin)'}`)

Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/lib/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export function resolveDefaults <TypeInfo extends BaseKeystoneTypeInfo> (config:
if (config?.server && 'options' in config.server && config.server.options) {
Object.assign(httpOptions, config.server.options)
}

return {
types: {
...config.types,
Expand Down Expand Up @@ -140,7 +141,7 @@ export function resolveDefaults <TypeInfo extends BaseKeystoneTypeInfo> (config:
telemetry: config.telemetry ?? true,
ui: {
...config.ui,
basePath: config.ui?.basePath?.replace(/\/$/, '') ?? '/admin',
basePath: config.ui?.basePath ?? '',
isAccessAllowed: config.ui?.isAccessAllowed ?? defaultIsAccessAllowed,
isDisabled: config.ui?.isDisabled ?? false,
getAdditionalFiles: config.ui?.getAdditionalFiles ?? [],
Expand Down
4 changes: 2 additions & 2 deletions tests/api-tests/fields/types/relationship.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getSchema (field: {
},
}),
},
})
}) as any
).graphQLSchema
}

Expand Down Expand Up @@ -140,7 +140,7 @@ describe('Reference errors', () => {
config({
db: { url: 'file:./thing.db', provider: 'sqlite' },
lists,
})
}) as any
).graphQLSchema
}

Expand Down
17 changes: 0 additions & 17 deletions tests/test-projects/basic/app/admin/.admin/index.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions tests/test-projects/basic/app/admin/[listKey]/[id]/page.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions tests/test-projects/basic/app/admin/[listKey]/create/page.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions tests/test-projects/basic/app/admin/[listKey]/page.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions tests/test-projects/basic/app/admin/layout.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions tests/test-projects/basic/app/admin/no-access/page.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions tests/test-projects/basic/app/admin/page.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions tests/test-projects/basic/app/layout.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions tests/test-projects/basic/keystone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,5 @@ export default config({
// WARNING: this is only needed for examples, dont do this
...fixPrismaPath,
},
ui: {
basePath: '/admin',
tsx: true,
},
lists,
})
5 changes: 0 additions & 5 deletions tests/test-projects/basic/next-env.d.ts

This file was deleted.

34 changes: 0 additions & 34 deletions tests/test-projects/basic/tsconfig.json

This file was deleted.

0 comments on commit 69bae99

Please sign in to comment.