Skip to content

Commit

Permalink
Merge pull request #157 from rajnishdargan/release-1.1.0
Browse files Browse the repository at this point in the history
Issue #PS-2876 feat: Set channel and framework value from metadata for existing content while launching editor
  • Loading branch information
itsvick authored Dec 24, 2024
2 parents e6e4d11 + e965393 commit 23106fb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/GenericEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const GenericEditor: React.FC = () => {
}

try {
const response = await fetch(`/action/content/v3/read/${contentId}?fields=createdBy,status,mimeType,contentType,resourceType,collaborators,contentDisposition,primaryCategory,framework,targetFWIds&mode=edit`);
const response = await fetch(`/action/content/v3/read/${contentId}?fields=createdBy,status,mimeType,contentType,resourceType,collaborators,contentDisposition,primaryCategory,framework,channel,targetFWIds&mode=edit`);

if (!response.ok) {
throw new Error('Failed to fetch content');
Expand Down Expand Up @@ -119,6 +119,8 @@ const GenericEditor: React.FC = () => {

// Set window context for the iframe
const setWindowContext = (data: any) => {
const contentChannel = data?.channel || CHANNEL_ID;
const contentFramework = data?.framework || CONTENT_FRAMEWORK_ID;
if (typeof window !== 'undefined') {
window['context'] = _.cloneDeep(editorConfig.GENERIC_EDITOR.WINDOW_CONTEXT);
if (identifier) {
Expand All @@ -127,16 +129,16 @@ const GenericEditor: React.FC = () => {
window['context'].user = {
id: getLocalStoredUserId() || TENANT_ID,
name: getLocalStoredUserName() || "Anonymous User",
orgIds: [CHANNEL_ID],
orgIds: [contentChannel],
organisations: {
[CHANNEL_ID]: CHANNEL_ID + " Channel"
[contentChannel]: contentChannel
}
}
window['context'].uid = getLocalStoredUserId() || TENANT_ID;
window['context'].contextRollUp.l1 = CHANNEL_ID;
window['context'].tags = [CHANNEL_ID];
window['context'].channel = CHANNEL_ID;
window['context'].framework = CONTENT_FRAMEWORK_ID;
window['context'].contextRollUp.l1 = contentChannel;
window['context'].tags = [contentChannel];
window['context'].channel = contentChannel;
window['context'].framework = contentFramework;
if (isLargeFileUpload || (_.get(data, 'contentDisposition') === 'online-only')) {
window.context['uploadInfo'] = {
isLargeFileUpload: true
Expand Down

0 comments on commit 23106fb

Please sign in to comment.