nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

View File

@@ -8,26 +8,37 @@ const path = require("path");
const ContextElementDependency = require("./dependencies/ContextElementDependency");
class ContextReplacementPlugin {
constructor(resourceRegExp, newContentResource, newContentRecursive, newContentRegExp) {
constructor(
resourceRegExp,
newContentResource,
newContentRecursive,
newContentRegExp
) {
this.resourceRegExp = resourceRegExp;
if(typeof newContentResource === "function") {
if (typeof newContentResource === "function") {
this.newContentCallback = newContentResource;
} else if(typeof newContentResource === "string" && typeof newContentRecursive === "object") {
} else if (
typeof newContentResource === "string" &&
typeof newContentRecursive === "object"
) {
this.newContentResource = newContentResource;
this.newContentCreateContextMap = (fs, callback) => {
callback(null, newContentRecursive);
};
} else if(typeof newContentResource === "string" && typeof newContentRecursive === "function") {
} else if (
typeof newContentResource === "string" &&
typeof newContentRecursive === "function"
) {
this.newContentResource = newContentResource;
this.newContentCreateContextMap = newContentRecursive;
} else {
if(typeof newContentResource !== "string") {
if (typeof newContentResource !== "string") {
newContentRegExp = newContentRecursive;
newContentRecursive = newContentResource;
newContentResource = undefined;
}
if(typeof newContentRecursive !== "boolean") {
if (typeof newContentRecursive !== "boolean") {
newContentRegExp = newContentRecursive;
newContentRecursive = undefined;
}
@@ -45,67 +56,78 @@ class ContextReplacementPlugin {
const newContentRegExp = this.newContentRegExp;
const newContentCreateContextMap = this.newContentCreateContextMap;
compiler.plugin("context-module-factory", (cmf) => {
cmf.plugin("before-resolve", (result, callback) => {
if(!result) return callback();
if(resourceRegExp.test(result.request)) {
if(typeof newContentResource !== "undefined")
compiler.hooks.contextModuleFactory.tap("ContextReplacementPlugin", cmf => {
cmf.hooks.beforeResolve.tap("ContextReplacementPlugin", result => {
if (!result) return;
if (resourceRegExp.test(result.request)) {
if (newContentResource !== undefined) {
result.request = newContentResource;
if(typeof newContentRecursive !== "undefined")
}
if (newContentRecursive !== undefined) {
result.recursive = newContentRecursive;
if(typeof newContentRegExp !== "undefined")
}
if (newContentRegExp !== undefined) {
result.regExp = newContentRegExp;
if(typeof newContentCallback === "function") {
}
if (typeof newContentCallback === "function") {
newContentCallback(result);
} else {
result.dependencies.forEach((d) => {
if(d.critical)
d.critical = false;
});
for (const d of result.dependencies) {
if (d.critical) d.critical = false;
}
}
}
return callback(null, result);
return result;
});
cmf.plugin("after-resolve", (result, callback) => {
if(!result) return callback();
if(resourceRegExp.test(result.resource)) {
if(typeof newContentResource !== "undefined")
cmf.hooks.afterResolve.tap("ContextReplacementPlugin", result => {
if (!result) return;
if (resourceRegExp.test(result.resource)) {
if (newContentResource !== undefined) {
result.resource = path.resolve(result.resource, newContentResource);
if(typeof newContentRecursive !== "undefined")
}
if (newContentRecursive !== undefined) {
result.recursive = newContentRecursive;
if(typeof newContentRegExp !== "undefined")
}
if (newContentRegExp !== undefined) {
result.regExp = newContentRegExp;
if(typeof newContentCreateContextMap === "function")
result.resolveDependencies = createResolveDependenciesFromContextMap(newContentCreateContextMap);
if(typeof newContentCallback === "function") {
}
if (typeof newContentCreateContextMap === "function") {
result.resolveDependencies = createResolveDependenciesFromContextMap(
newContentCreateContextMap
);
}
if (typeof newContentCallback === "function") {
const origResource = result.resource;
newContentCallback(result);
if(result.resource !== origResource) {
if (result.resource !== origResource) {
result.resource = path.resolve(origResource, result.resource);
}
} else {
result.dependencies.forEach((d) => {
if(d.critical)
d.critical = false;
});
for (const d of result.dependencies) {
if (d.critical) d.critical = false;
}
}
}
return callback(null, result);
return result;
});
});
}
}
const createResolveDependenciesFromContextMap = (createContextMap) => {
return function resolveDependenciesFromContextMap(fs, resource, recursive, regExp, callback) {
const createResolveDependenciesFromContextMap = createContextMap => {
const resolveDependenciesFromContextMap = (fs, options, callback) => {
createContextMap(fs, (err, map) => {
if(err) return callback(err);
const dependencies = Object.keys(map).map((key) => {
return new ContextElementDependency(map[key], key);
if (err) return callback(err);
const dependencies = Object.keys(map).map(key => {
return new ContextElementDependency(
map[key] + options.resourceQuery,
key
);
});
callback(null, dependencies);
});
};
return resolveDependenciesFromContextMap;
};
module.exports = ContextReplacementPlugin;