Skip to content

Commit

Permalink
feat: Display warning when widgets aren't visible in public site - ME…
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed Sep 10, 2024
1 parent 12629be commit 38b34cd
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,6 @@ gamification.topChallengers.settings.quarterPeriod=Current quarter
gamification.topChallengers.settings.allPeriod=All time
gamification.topChallengers.settings.displayCurrentPosition=Display Current User position
gamification.topChallengers.settings.editTooltip=Edit settings

gamification.publicWidgetHiddenTooltipPart1=Platform Access Restricted The gadget is hidden.
gamification.publicWidgetHiddenTooltipPart2=Adjust in admin settings.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<v-btn
v-show="hoverEdit"
:title="$t('gamification.programs.overviewSettings.editTooltip')"
:class="neverContributed && 'mt-n4 me-n2 z-index-one'"
:class="neverContributed && 'me-n2 z-index-one'"
small
icon
@click="$root.$emit('my-contributions-overview-settings')">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@
'r-0': !$vuetify.rtl,
}"
class="position-absolute absolute-vertical-center z-index-one">
<v-tooltip v-if="$root.displayNotPublicallyVisible && !hubAccessOpen" top>
<template #activator="{attrs, on}">
<v-icon
size="18"
color="warning"
class="me-2"
v-on="on"
v-bind="attrs">
fa-exclamation-triangle
</v-icon>
</template>
<span>
{{ $t('gamification.publicWidgetHiddenTooltipPart1') }}
<br>
{{ $t('gamification.publicWidgetHiddenTooltipPart2') }}
</span>
</v-tooltip>
<v-btn
v-show="programLink"
:icon="hoverEdit"
Expand All @@ -52,7 +69,7 @@
<v-btn
v-show="hoverEdit"
:title="$t('gamification.programs.overviewSettings.editTooltip')"
:class="!programsDisplayed && 'mt-n4 me-n2 z-index-one'"
:class="!programsDisplayed && 'me-n2 z-index-one'"
small
icon
@click="$root.$emit('programs-overview-settings')">
Expand Down Expand Up @@ -95,6 +112,7 @@ export default {
data: () => ({
programs: [],
administrators: null,
registrationSettings: null,
hover: false,
loading: true,
}),
Expand All @@ -120,6 +138,9 @@ export default {
sortBy() {
return this.$root.programsSortBy || 'modifiedDate';
},
hubAccessOpen() {
return !this.registrationSettings || this.registrationSettings?.type === 'OPEN';
},
},
watch: {
limit() {
Expand All @@ -135,6 +156,9 @@ export default {
},
created() {
this.retrievePrograms();
if (this.$root.displayNotPublicallyVisible) {
this.initRegistration();
}
},
methods: {
retrievePrograms() {
Expand All @@ -154,6 +178,22 @@ export default {
})
.finally(() => this.loading = false);
},
initRegistration() {
return this.getRegistrationSettings()
.then(data => this.registrationSettings = data);
},
getRegistrationSettings() {
return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/registration/settings`, {
method: 'GET',
credentials: 'include',
}).then((resp) => {
if (resp?.ok) {
return resp.json();
} else {
throw new Error('Error while getting Registration settings');
}
});
},
},
};
</script>
1 change: 1 addition & 0 deletions portlets/src/main/webapp/vue-app/programsOverview/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function init(portletStorageId, limit, programsSortBy, canEdit, pageRef)
programsSortBy,
canEdit: portletStorageId && canEdit || false,
pageRef,
displayNotPublicallyVisible: eXo.env.portal.portalName === 'public' && canEdit,
},
template: `<gamification-overview-programs id="${appId}" />`,
created() {
Expand Down
1 change: 1 addition & 0 deletions portlets/src/main/webapp/vue-app/rulesOverview/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function init(
rulesSortBy,
canEdit: portletStorageId && canEdit || false,
pageRef,
displayNotPublicallyVisible: eXo.env.portal.portalName === 'public' && canEdit,
},
template: `<gamification-rules-overview id="${appId}" />`,
created() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@
'r-0': !$vuetify.rtl,
}"
class="position-absolute absolute-vertical-center z-index-one">
<v-tooltip v-if="$root.displayNotPublicallyVisible && !hubAccessOpen" top>
<template #activator="{attrs, on}">
<v-icon
size="18"
color="warning"
class="me-2"
v-on="on"
v-bind="attrs">
fa-exclamation-triangle
</v-icon>
</template>
<span>
{{ $t('gamification.publicWidgetHiddenTooltipPart1') }}
<br>
{{ $t('gamification.publicWidgetHiddenTooltipPart2') }}
</span>
</v-tooltip>
<v-btn
v-if="!displayPlaceholder && !loading"
:icon="hoverEdit"
Expand All @@ -59,7 +76,7 @@
<v-btn
v-show="hoverEdit"
:title="$t('gamification.topChallengers.settings.editTooltip')"
:class="displayPlaceholder && 'mt-n4 me-n2 z-index-one'"
:class="displayPlaceholder && 'me-n2 z-index-one'"
small
icon
@click="$root.$emit('topChallengers-overview-settings')">
Expand All @@ -86,6 +103,7 @@
export default {
data: () => ({
hover: false,
registrationSettings: null,
rankDisplayed: false,
loading: true,
pageSize: Math.max(10, parseInt((window.innerHeight - 122) / 45)),
Expand All @@ -100,6 +118,9 @@ export default {
hoverEdit() {
return this.hover && this.$root.canEdit;
},
hubAccessOpen() {
return !this.registrationSettings || this.registrationSettings?.type === 'OPEN';
},
},
created() {
document.addEventListener('listOfRankedConnections', (event) => {
Expand All @@ -108,6 +129,27 @@ export default {
this.loading = false;
}
});
if (this.$root.displayNotPublicallyVisible) {
this.initRegistration();
}
},
methods: {
initRegistration() {
return this.getRegistrationSettings()
.then(data => this.registrationSettings = data);
},
getRegistrationSettings() {
return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/registration/settings`, {
method: 'GET',
credentials: 'include',
}).then((resp) => {
if (resp?.ok) {
return resp.json();
} else {
throw new Error('Error while getting Registration settings');
}
});
},
},
};
</script>
Expand Down
3 changes: 2 additions & 1 deletion portlets/src/main/webapp/vue-app/topChallengers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export function init(
topChallengersPeriod,
topChallengersCurrentPosition,
canEdit,
pageRef
pageRef,
displayNotPublicallyVisible: eXo.env.portal.portalName === 'public' && canEdit,
},
template: `<gamification-overview-top-challengers id="${appId}" />`,
i18n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@
'r-0': !$vuetify.rtl,
}"
class="position-absolute absolute-vertical-center z-index-one">
<v-tooltip v-if="$root.displayNotPublicallyVisible && !hubAccessOpen" top>
<template #activator="{attrs, on}">
<v-icon
class="me-2"
color="warning"
size="18"
v-on="on"
v-bind="attrs">
fa-exclamation-triangle
</v-icon>
</template>
<span>
{{ $t('gamification.publicWidgetHiddenTooltipPart1') }}
<br>
{{ $t('gamification.publicWidgetHiddenTooltipPart2') }}
</span>
</v-tooltip>
<v-btn
v-if="hasValidRules"
:icon="hoverEdit"
Expand Down Expand Up @@ -157,6 +174,7 @@ export default {
endingRulesList: [],
activeRulesSize: 0,
initialized: false,
registrationSettings: null,
}),
computed: {
title() {
Expand Down Expand Up @@ -288,6 +306,9 @@ export default {
limit() {
return this.$root.lockedRulesLimit + this.$root.endingRulesLimit + this.$root.availableRulesLimit + this.$root.upcomingRulesLimit;
},
hubAccessOpen() {
return !this.registrationSettings || this.registrationSettings?.type === 'OPEN';
},
},
watch: {
isHiddenWidget: {
Expand Down Expand Up @@ -324,6 +345,9 @@ export default {
this.$root.$on('rule-deleted', this.retrieveRules);
this.refreshLimit();
this.retrieveRules();
if (this.$root.displayNotPublicallyVisible) {
this.initRegistration();
}
},
beforeDestroy() {
this.$root.$off('announcement-added', this.retrieveRules);
Expand Down Expand Up @@ -481,6 +505,22 @@ export default {
|| prop === 'validDates'
|| rule.userInfo.context[prop]);
},
initRegistration() {
return this.getRegistrationSettings()
.then(data => this.registrationSettings = data);
},
getRegistrationSettings() {
return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/registration/settings`, {
method: 'GET',
credentials: 'include',
}).then((resp) => {
if (resp?.ok) {
return resp.json();
} else {
throw new Error('Error while getting Registration settings');
}
});
},
},
};
</script>

0 comments on commit 38b34cd

Please sign in to comment.