Skip to content

Commit

Permalink
Merge pull request #6 from AjayJagan/patternfly-kie-tools-version-upg…
Browse files Browse the repository at this point in the history
…rade

changes for tooling library update
  • Loading branch information
Sara4994 authored Jun 28, 2023
2 parents a5dec54 + 110d212 commit d0b3b8d
Show file tree
Hide file tree
Showing 35 changed files with 729 additions and 612 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*/

import React, { useCallback, useMemo } from 'react';
import React, { useCallback } from 'react';
import { EnvelopeServer } from '@kie-tools-core/envelope-bus/dist/channel';
import { EmbeddedEnvelopeFactory } from '@kie-tools-core/envelope/dist/embedded';
import {
EmbeddedEnvelopeProps,
RefForwardingEmbeddedEnvelope
} from '@kie-tools-core/envelope/dist/embedded';
import {
CloudEventFormApi,
CloudEventFormChannelApi,
Expand All @@ -37,63 +40,71 @@ export interface EmbeddedCloudEventFormProps {
};
}

export const EmbeddedCloudEventForm = React.forwardRef<
CloudEventFormApi,
EmbeddedCloudEventFormProps
>((props, forwardedRef) => {
const pollInit = useCallback(
(
envelopeServer: EnvelopeServer<
CloudEventFormChannelApi,
CloudEventFormEnvelopeApi
>,
container: () => HTMLDivElement
) => {
init({
config: {
containerType: ContainerType.DIV,
envelopeId: envelopeServer.id
},
container: container(),
bus: {
postMessage(message, targetOrigin, transfer) {
window.postMessage(message, targetOrigin, transfer);
export const EmbeddedCloudEventForm = React.forwardRef(
(
props: EmbeddedCloudEventFormProps,
forwardedRef: React.Ref<CloudEventFormApi>
) => {
const refDelegate = useCallback(
(
envelopeServer: EnvelopeServer<
CloudEventFormChannelApi,
CloudEventFormEnvelopeApi
>
): CloudEventFormApi => ({}),
[]
);
const pollInit = useCallback(
(
envelopeServer: EnvelopeServer<
CloudEventFormChannelApi,
CloudEventFormEnvelopeApi
>,
container: () => HTMLDivElement
) => {
init({
config: {
containerType: ContainerType.DIV,
envelopeId: envelopeServer.id
},
container: container(),
bus: {
postMessage(message, targetOrigin, transfer) {
window.postMessage(message, targetOrigin, transfer);
}
}
}
});
return envelopeServer.envelopeApi.requests.cloudEventForm__init(
{
origin: envelopeServer.origin,
envelopeServerId: envelopeServer.id
},
{
isNewInstanceEvent: props.isNewInstanceEvent ?? true,
defaultValues: props.defaultValues
}
);
},
[]
);

const refDelegate = useCallback(
(
envelopeServer: EnvelopeServer<
CloudEventFormChannelApi,
CloudEventFormEnvelopeApi
>
): CloudEventFormApi => ({}),
[]
);

const EmbeddedEnvelope = useMemo(() => {
return EmbeddedEnvelopeFactory({
api: new EmbeddedCloudEventFormChannelApiImpl(props.driver),
origin: props.targetOrigin,
refDelegate,
pollInit,
config: { containerType: ContainerType.DIV }
});
}, []);
});
return envelopeServer.envelopeApi.requests.cloudEventForm__init(
{
origin: envelopeServer.origin,
envelopeServerId: envelopeServer.id
},
{
isNewInstanceEvent: props.isNewInstanceEvent ?? true,
defaultValues: props.defaultValues
}
);
},
[]
);
return (
<EmbeddedCloudEventFormEnvelope
ref={forwardedRef}
apiImpl={new EmbeddedCloudEventFormChannelApiImpl(props.driver)}
origin={props.targetOrigin}
refDelegate={refDelegate}
pollInit={pollInit}
config={{ containerType: ContainerType.DIV }}
/>
);
}
);

return <EmbeddedEnvelope ref={forwardedRef} />;
});
const EmbeddedCloudEventFormEnvelope = React.forwardRef<
CloudEventFormApi,
EmbeddedEnvelopeProps<
CloudEventFormChannelApi,
CloudEventFormEnvelopeApi,
CloudEventFormApi
>
>(RefForwardingEmbeddedEnvelope);
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { CloudEventFormEnvelopeViewApi } from './CloudEventFormEnvelopeView';
export class CloudEventFormEnvelopeApiImpl
implements CloudEventFormEnvelopeApi
{
private view: () => CloudEventFormEnvelopeViewApi;
private capturedInitRequestYet = false;

constructor(
Expand All @@ -52,7 +53,7 @@ export class CloudEventFormEnvelopeApiImpl
association: Association,
args: CloudEventFormInitArgs
): Promise<void> => {
this.args.envelopeBusController.associate(
this.args.envelopeClient.associate(
association.origin,
association.envelopeServerId
);
Expand All @@ -61,6 +62,7 @@ export class CloudEventFormEnvelopeApiImpl
return;
}
this.ackCapturedInitRequest();
this.args.view().initialize(args);
this.view = await this.args.viewDelegate();
this.view().initialize(args);
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Red Hat, Inc. and/or its affiliates.
* Copyright 2023 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React, { useCallback, useMemo, Ref } from 'react';
import React, { useCallback } from 'react';
import { EnvelopeServer } from '@kie-tools-core/envelope-bus/dist/channel';
import { EmbeddedEnvelopeFactory } from '@kie-tools-core/envelope/dist/embedded';
import {
EmbeddedEnvelopeProps,
RefForwardingEmbeddedEnvelope
} from '@kie-tools-core/envelope/dist/embedded';
import {
CustomDashboardListApi,
CustomDashboardListChannelApi,
Expand All @@ -31,57 +34,63 @@ export interface Props {
driver: CustomDashboardListDriver;
}

export const EmbeddedCustomDashboardList = React.forwardRef<
CustomDashboardListApi,
Props
>((props, forwardedRef: Ref<CustomDashboardListApi>) => {
const pollInit = useCallback(
(
envelopeServer: EnvelopeServer<
CustomDashboardListChannelApi,
CustomDashboardListEnvelopeApi
>,
container: () => HTMLDivElement
) => {
init({
config: {
containerType: ContainerType.DIV,
envelopeId: envelopeServer.id
},
container: container(),
bus: {
postMessage(message, targetOrigin, transfer) {
window.postMessage(message, targetOrigin, transfer);
export const EmbeddedCustomDashboardList = React.forwardRef(
(props: Props, forwardedRef: React.Ref<CustomDashboardListApi>) => {
const refDelegate = useCallback(
(
envelopeServer: EnvelopeServer<
CustomDashboardListChannelApi,
CustomDashboardListEnvelopeApi
>
): CustomDashboardListApi => ({}),
[]
);
const pollInit = useCallback(
(
envelopeServer: EnvelopeServer<
CustomDashboardListChannelApi,
CustomDashboardListEnvelopeApi
>,
container: () => HTMLDivElement
) => {
init({
config: {
containerType: ContainerType.DIV,
envelopeId: envelopeServer.id
},
container: container(),
bus: {
postMessage(message, targetOrigin, transfer) {
window.postMessage(message, targetOrigin, transfer);
}
}
}
});
return envelopeServer.envelopeApi.requests.customDashboardList__init({
origin: envelopeServer.origin,
envelopeServerId: envelopeServer.id
});
},
[]
);
});
return envelopeServer.envelopeApi.requests.customDashboardList__init({
origin: envelopeServer.origin,
envelopeServerId: envelopeServer.id
});
},
[]
);

const refDelegate = useCallback(
(
envelopeServer: EnvelopeServer<
CustomDashboardListChannelApi,
CustomDashboardListEnvelopeApi
>
): CustomDashboardListApi => ({}),
[]
);
return (
<EmbeddedCustomDashboardListEnvelope
ref={forwardedRef}
apiImpl={new CustomDashboardListChannelApiImpl(props.driver)}
origin={props.targetOrigin}
refDelegate={refDelegate}
pollInit={pollInit}
config={{ containerType: ContainerType.DIV }}
/>
);
}
);

const EmbeddedEnvelope = useMemo(() => {
return EmbeddedEnvelopeFactory({
api: new CustomDashboardListChannelApiImpl(props.driver),
origin: props.targetOrigin,
refDelegate,
pollInit,
config: { containerType: ContainerType.DIV }
});
}, []);

return <EmbeddedEnvelope ref={forwardedRef} />;
});
const EmbeddedCustomDashboardListEnvelope = React.forwardRef<
CustomDashboardListApi,
EmbeddedEnvelopeProps<
CustomDashboardListChannelApi,
CustomDashboardListEnvelopeApi,
CustomDashboardListApi
>
>(RefForwardingEmbeddedEnvelope);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Red Hat, Inc. and/or its affiliates.
* Copyright 2023 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@ import { CustomDashboardListEnvelopeContext } from './CustomDashboardListEnvelop
export class CustomDashboardListEnvelopeApiImpl
implements CustomDashboardListEnvelopeApi
{
private view: () => CustomDashboardListEnvelopeViewApi;
private capturedInitRequestYet = false;
constructor(
private readonly args: EnvelopeApiFactoryArgs<
Expand All @@ -50,7 +51,7 @@ export class CustomDashboardListEnvelopeApiImpl
customDashboardList__init = async (
association: Association
): Promise<void> => {
this.args.envelopeBusController.associate(
this.args.envelopeClient.associate(
association.origin,
association.envelopeServerId
);
Expand All @@ -60,6 +61,7 @@ export class CustomDashboardListEnvelopeApiImpl
}

this.ackCapturedInitRequest();
this.args.view().initialize();
this.view = await this.args.viewDelegate();
this.view().initialize();
};
}
Loading

0 comments on commit d0b3b8d

Please sign in to comment.