Skip to content

Commit

Permalink
legacy extension compatibility layer
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Oct 18, 2023
1 parent 344732b commit f7b256c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {httpRequestJsonLocal} from 'core/helpers/network';
import {store} from 'core/data';
import {registerGlobalKeybindings} from 'core/keyboard/keyboard';
import {maybeDisplayInvalidInstanceConfigurationMessage} from 'validate-instance-configuration';
import {registerLegacyExtensionCompatibilityLayer} from 'register-legacy-extension-compatibility-layer';

let body = angular.element('body');

Expand Down Expand Up @@ -152,6 +153,8 @@ export function startApp(
registerAuthoringReactWidgets();
registerAuthoringReactFields();
}

registerLegacyExtensionCompatibilityLayer();
});
});
},
Expand Down
33 changes: 33 additions & 0 deletions scripts/register-legacy-extension-compatibility-layer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import {IExtensionActivationResult} from 'superdesk-api';
import {registerInternalExtension} from 'core/helpers/register-internal-extension';
import ng from 'core/services/ng';

interface ILegacyExtensionPoint {
type: string;
componentClass: React.ComponentType<any>;
data: unknown;
onInit: unknown;
props: {[key: string]: unknown};
}

export function registerLegacyExtensionCompatibilityLayer() {
const extensionActivationResult: IExtensionActivationResult = {
contributions: {
publishingSections: (ng.get('extensionPoints').get('authoring:publish') as Array<ILegacyExtensionPoint>)
.map((api) => {
const Component = api.componentClass;

return {
component: function LegacyExtensionCompatibilityLayerComponentWrapper(props) {
return (
<Component {...api.props} item={props.item} />
);
},
};
}),
},
};

registerInternalExtension('extensionCompatibilityLayer', extensionActivationResult);
}

0 comments on commit f7b256c

Please sign in to comment.