mirror of
https://github.com/datahub-project/datahub.git
synced 2025-08-11 10:46:52 +00:00

* Releases updated version of datahub-web client UI code * Fix typo in yarn lock * Change yarn lock to match yarn registry directories * Previous commit missed some paths * Even more changes to yarnlock missing in previous commit * Include codegen file for typings * Add files to get parity for datahub-web and current OS datahub-midtier * Add in typo fix from previous commit - change to proper license * Implement proper OS fix for person entity picture url * Workarounds for open source DH issues * Fixes institutional memory api and removes unopensourced tabs for datasets * Fixes search dataset deprecation and user search issue as a result of changes * Remove internal only options in the avatar menu
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import Controller from '@ember/controller';
|
|
import { IProtocolDefinition } from '@datahub/utils/types/controllers';
|
|
|
|
/**
|
|
* Default Protocol controller which other protocols must extend
|
|
*/
|
|
export class ProtocolController extends Controller {
|
|
/**
|
|
* This method will be called to clear attributes when exiting the route on which
|
|
* the controller is used.
|
|
*
|
|
* Make sure you call super.resetProtocol when overriding to avoid breaking the chain.
|
|
*/
|
|
resetProtocol(): void {
|
|
//noop
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Mixin kind of way to share common logic accross Controllers (by @sadebajo)
|
|
* Usage:
|
|
*
|
|
* const myProtocol1 = {
|
|
* protocol: class extends ProtocolController {
|
|
* ...add your logic here
|
|
* },
|
|
* queryParams: ['your_query_params']
|
|
* }
|
|
*
|
|
*
|
|
* class MyController extends WithControllerProtocol(myProtocol1, myProtocol2, ...) {
|
|
*
|
|
*
|
|
* }
|
|
*
|
|
* @param protocols Array of protocol that current controller will extend
|
|
*/
|
|
export const WithControllerProtocol = (...protocols: Array<IProtocolDefinition>): typeof ProtocolController =>
|
|
protocols.reduce(
|
|
(controller, { protocol, queryParams }): typeof ProtocolController =>
|
|
class extends protocol(controller) {
|
|
constructor() {
|
|
// eslint-disable-next-line prefer-rest-params
|
|
super(...arguments);
|
|
const resolvedQueryParams = [].concat.apply(queryParams);
|
|
this.queryParams = [...this.queryParams, ...resolvedQueryParams];
|
|
}
|
|
},
|
|
ProtocolController
|
|
);
|