Skip to content

Commit

Permalink
fix: Use I18N of Vue PArent Node rather than destroyed child - MEED-7861
Browse files Browse the repository at this point in the history
 - Meeds-io/meeds#2627

Prior to this change, the I18N message was computed once a Space Administration action is triggered in a synchronous way in order to ensure having access to I18N translation object. Even this computing was making an error due to an intensive and instantly destroy of Button once it's not displayed anymore (Menu Closed). Thus, with this change, the access of I18N is made using the `this..` rather than using `this.` to ensure that the access to I18N messages is always available even when the child Vue component is destroyed.
  • Loading branch information
boubaker committed Dec 8, 2024
1 parent f829b80 commit 3f3458c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@
</template>
<script>
export default {
data: () => ({
successMessage: null,
}),
methods: {
applyTemplate(params) {
// Workaround for context change, compute success message on processing start
this.successMessage = this.$t('social.spaces.administration.manageSpaces.spaceTemplateAppliedOnSpaces');
this.$root.applyOperationInBulk(
(space, options) => this.$spaceAdministrationService.applySpaceTemplate(space.id, options),
params,
() => {
this.$root.$emit('alert-message', this.successMessage, 'success');
this.$root.$emit('alert-message', this.$root.$t('social.spaces.administration.manageSpaces.spaceTemplateAppliedOnSpaces'), 'success');
this.$root.$emit('spaces-administration-list-refresh', this.$root.isFilteredByTemplate);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
</template>
<script>
export default {
data: () => ({
successMessage: null,
}),
computed: {
spacesCount() {
return this.$root.allSpacesSelected ? this.$root.spacesSize : this.$root.selectedSpaces.length;
Expand All @@ -54,15 +51,13 @@ export default {
window.setTimeout(() => this.$refs.dialog.open(), 200);
},
deleteSpaces() {
// Workaround for context change, compute success message on processing start
this.successMessage = this.$t('social.spaces.administration.manageSpaces.spacesDeletedSuccessfully', {
0: this.spacesCount
});
this.$root.applyOperationInBulk(
space => this.$spaceService.removeSpace(space.id),
null,
() => {
this.$root.$emit('alert-message', this.successMessage, 'success');
this.$root.$emit('alert-message', this.$root.$t('social.spaces.administration.manageSpaces.spacesDeletedSuccessfully', {
0: this.spacesCount
}), 'success');
this.$root.$emit('spaces-administration-list-refresh');
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@
</template>
<script>
export default {
data: () => ({
successMessage: null,
}),
methods: {
updatePermissions(params) {
// Workaround for context change, compute success message on processing start
this.successMessage = this.$t('social.spaces.administration.manageSpaces.spacesPermissionsUpdatedSuccessfully');
this.$root.applyOperationInBulk(
async space => {
const permissions = {};
Expand All @@ -49,7 +45,7 @@ export default {
},
null,
() => {
this.$root.$emit('alert-message', this.successMessage, 'success');
this.$root.$emit('alert-message', this.$root.$t('social.spaces.administration.manageSpaces.spacesPermissionsUpdatedSuccessfully'), 'success');
this.$root.$emit('spaces-administration-list-refresh');
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@
</template>
<script>
export default {
data: () => ({
successMessage: null,
}),
methods: {
syncMembers(groups) {
// Workaround for context change, compute success message on processing start
this.successMessage = this.$t('social.spaces.administration.manageSpaces.groupsBoundOnSpaces');
this.$root.applyOperationInBulk(
async space => {
let spaceBoundGroups = await this.$spaceBindingService.getGroupSpaceBindings(space.id);
Expand All @@ -51,7 +46,7 @@ export default {
},
null,
() => {
this.$root.$emit('alert-message', this.successMessage, 'success');
this.$root.$emit('alert-message', this.$root.$t('social.spaces.administration.manageSpaces.groupsBoundOnSpaces'), 'success');
this.$root.$emit('spaces-administration-list-refresh');
});
},
Expand Down

0 comments on commit 3f3458c

Please sign in to comment.