-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Prior to this change, all news extensions were loaded inside all-bottom-container including the non needed once in all pages. This PR add the use of load-group mechanism to enhance the resources load and load only what is needed in the current page.
- Loading branch information
Showing
27 changed files
with
485 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
webapp/src/main/webapp/news-extensions/activity-extensions/extensions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
Copyright (C) 2023 eXo Platform SAS. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
const newsActivityTypeExtensionOptions = { | ||
name: 'News', | ||
getExtendedComponent: (activity, isActivityDetail) => { | ||
if (activity && isActivityDetail) { | ||
return { | ||
component: Vue.options.components['exo-news-details-activity'], | ||
overrideHeader: true, | ||
overrideFooter: false, | ||
}; | ||
} | ||
}, | ||
extendSharedActivity: (activity, isActivityDetail) => isActivityDetail, | ||
showSharedInformationFooter: (activity, isActivityDetail) => isActivityDetail, | ||
init: (activity, isActivityDetail) => { | ||
let activityId = activity.id; | ||
if (activity.parentActivity) { | ||
activityId = activity.parentActivity.id; | ||
} | ||
if (!activity.news || isActivityDetail) { | ||
return Vue.prototype.$newsServices.getNewsByActivityId(activityId) | ||
.then(news => activity.news = news); | ||
} | ||
}, | ||
canEdit: () => false, | ||
canShare: () => true, | ||
hideOnDelete: true, | ||
supportsThumbnail: true, | ||
windowTitlePrefixKey: 'news.window.title', | ||
getThumbnail: (activity) => activity?.news?.illustrationURL && `${activity?.news?.illustrationURL}&size=305x285` || '/news/images/news.png', | ||
getThumbnailProperties: (activity) => !(activity?.news?.illustrationURL) && { | ||
height: '90px', | ||
width: '90px', | ||
noBorder: true, | ||
} || null, | ||
isUseSameViewForMobile: (activity) => !activity?.news?.illustrationURL, | ||
getTitle: (activity) => { | ||
const news = activity?.news; | ||
if (news?.title) { | ||
return news.title; | ||
} | ||
return ''; | ||
}, | ||
getSourceLink: (activity) => `${eXo.env.portal.context}/${eXo.env.portal.portalName}/activity?id=${!activity.parentActivity ? activity.id : activity.parentActivity.id}`, | ||
getSummary: (activity) => { | ||
const news = activity?.news; | ||
if (news?.summary) { | ||
return news.summary; | ||
} else if (news?.body) { | ||
return Vue.prototype.$utils.htmlToText(news.body); | ||
} | ||
return ''; | ||
}, | ||
getTooltip: (activity, isActivityDetail) => !isActivityDetail && activity && 'news.activity.clickToShowDetail', | ||
}; | ||
|
||
export function initExtensions() { | ||
extensionRegistry.registerExtension('activity', 'type', { | ||
type: 'news', | ||
options: newsActivityTypeExtensionOptions, | ||
}); | ||
} |
20 changes: 20 additions & 0 deletions
20
webapp/src/main/webapp/news-extensions/activity-extensions/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Copyright (C) 2023 eXo Platform SAS. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import {initExtensions} from './extensions.js'; | ||
|
||
export function init() { | ||
initExtensions(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
webapp/src/main/webapp/news-extensions/analytics-extensions/extensions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
Copyright (C) 2023 eXo Platform SAS. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
export function initExtensions() { | ||
extensionRegistry.registerExtension('AnalyticsTable', 'CellValue', { | ||
type: 'news', | ||
options: { | ||
// Rank of executing 'match' method | ||
rank: 60, | ||
// Used Vue component to display cell value | ||
vueComponent: Vue.options.components['analytics-table-cell-content-value'], | ||
// Method complete signature : match: (fieldName, aggregationType, fieldDataType, item) => { ... } | ||
match: (fieldName, aggregationType) => fieldName === 'contentId.keyword' && aggregationType === 'TERMS', | ||
}, | ||
}); | ||
|
||
extensionRegistry.registerExtension('AnalyticsSamples', 'SampleItem', { | ||
type: 'news', | ||
options: { | ||
// Rank of executing 'match' method | ||
rank: 30, | ||
// Used Vue component to display cell value | ||
vueComponent: Vue.options.components['analytics-sample-item-content'], | ||
match: fieldName => fieldName === 'contentId', | ||
}, | ||
}); | ||
} |
26 changes: 26 additions & 0 deletions
26
webapp/src/main/webapp/news-extensions/analytics-extensions/initComponents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Copyright (C) 2023 eXo Platform SAS. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import AnalyticsTableCellContentValue from './components/analytics/AnalyticsTableCellContentValue.vue'; | ||
import AnalyticsSampleItemContent from './components/analytics/AnalyticsSampleItemContent.vue'; | ||
|
||
const components = { | ||
'analytics-table-cell-content-value': AnalyticsTableCellContentValue, | ||
'analytics-sample-item-content': AnalyticsSampleItemContent, | ||
}; | ||
|
||
for (const key in components) { | ||
Vue.component(key, components[key]); | ||
} |
28 changes: 28 additions & 0 deletions
28
webapp/src/main/webapp/news-extensions/analytics-extensions/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright (C) 2023 eXo Platform SAS. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
import './initComponents.js'; | ||
import {initExtensions} from './extensions.js'; | ||
import * as newsServices from '../../services/newsServices'; | ||
|
||
if (!Vue.prototype.$newsServices) { | ||
window.Object.defineProperty(Vue.prototype, '$newsServices', { | ||
value: newsServices, | ||
}); | ||
} | ||
|
||
export function init() { | ||
initExtensions(); | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.