feat: admin UI logout extensibility (#1274)

* added Logout documentation

* updated type and schema

* updated logout component, route and inactivityRoute references

* added custom Logout component into test admin instance

* fixed windows path management

* added dotenv usage

* added check on testSuiteDir and provided more meaningful error message

* fixed object destructure

* updated from logout.route to logoutRoute

* extracted getSanitizedLogoutRoutes method

* added unit tests

* updated references

* updated doc

* reviewed casing and added defaults

* updated usage

* restored workers previous value

* fixed config validation

* updated docs and schema

* updated reference to logoutRoute and inactivityRoute

* updated test ref

Co-authored-by: Alberto Maghini (MSC Technology Italia) <alberto.maghini@msc.com>
Co-authored-by: Alberto Maghini <alberto@newesis.com>
This commit is contained in:
Alberto Maghini
2022-11-14 20:55:31 +01:00
committed by GitHub
parent 4d8cc97475
commit a345ef0d31
18 changed files with 233 additions and 119 deletions

View File

@@ -0,0 +1,23 @@
import React from 'react';
import { useConfig } from '../../../../src/admin/components/utilities/Config';
import LogOut from '../../../../src/admin/components/icons/LogOut';
const Logout: React.FC = () => {
const config = useConfig();
const {
routes: {
admin,
},
admin: {
logoutRoute
},
} = config;
return (
<a href={`${admin}${logoutRoute}#custom`}>
<LogOut />
</a>
);
};
export default Logout;

View File

@@ -8,6 +8,7 @@ import CustomDefaultRoute from './components/views/CustomDefault';
import BeforeLogin from './components/BeforeLogin';
import AfterNavLinks from './components/AfterNavLinks';
import { slug, globalSlug } from './shared';
import Logout from './components/Logout';
export interface Post {
id: string;
@@ -38,6 +39,9 @@ export default buildConfig({
beforeLogin: [
BeforeLogin,
],
logout: {
Button: Logout,
},
afterNavLinks: [
AfterNavLinks,
],

View File

@@ -15,6 +15,11 @@ require('@babel/register')({
const [testSuiteDir] = process.argv.slice(2);
if (!testSuiteDir) {
console.error('ERROR: You must provide an argument for "testSuiteDir"');
process.exit(1);
}
const configPath = path.resolve(__dirname, testSuiteDir, 'config.ts');
if (!fs.existsSync(configPath)) {

View File

@@ -2,8 +2,8 @@ import express from 'express';
import { v4 as uuid } from 'uuid';
import payload from '../src';
require("dotenv").config();
const expressApp = express();
const init = async () => {
await payload.initAsync({
secret: uuid(),

View File

@@ -15,7 +15,7 @@ const suiteName = args[0];
// Run all
if (!suiteName || args[0].startsWith('-')) {
const bail = args.includes('--bail');
const files = glob.sync(`${path.resolve(__dirname)}/**/*e2e.spec.ts`);
const files = glob.sync(`${path.resolve(__dirname).replace(/\\/g, '/')}/**/*e2e.spec.ts`);
console.log(`\n\nExecuting all ${files.length} E2E tests...`);
files.forEach((file) => {
clearWebpackCache();