mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 10:00:17 -04:00
* Prettier all the JS files * Add GitHub Action to autoformat code pushed to master * Fix eslint violation due to formatting. * Remove GitHub actions for styling * Add restyled.io config
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import { isObject, cloneDeep, each, extend } from "lodash";
|
|
|
|
export function routesToAngularRoutes(routes, template) {
|
|
const result = {};
|
|
template = extend({}, template); // convert to object
|
|
each(routes, ({ path, title, key, ...resolve }) => {
|
|
// Convert to functions
|
|
each(resolve, (value, prop) => {
|
|
resolve[prop] = () => value;
|
|
});
|
|
|
|
result[path] = {
|
|
...template,
|
|
title,
|
|
// keep `resolve` from `template` (if exists)
|
|
resolve: {
|
|
...template.resolve,
|
|
...resolve,
|
|
currentPage: () => key,
|
|
},
|
|
};
|
|
});
|
|
return result;
|
|
}
|
|
|
|
// ANGULAR_REMOVE_ME
|
|
export function cleanAngularProps(value) {
|
|
// remove all props that start with '$$' - that's what `angular.toJson` does
|
|
const omitAngularProps = obj => {
|
|
each(obj, (v, k) => {
|
|
if (("" + k).startsWith("$$")) {
|
|
delete obj[k];
|
|
} else {
|
|
obj[k] = isObject(v) ? omitAngularProps(v) : v;
|
|
}
|
|
});
|
|
return obj;
|
|
};
|
|
|
|
const result = cloneDeep(value);
|
|
return isObject(result) ? omitAngularProps(result) : result;
|
|
}
|