Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-17494] Fix plugin translations #3536

Merged
merged 4 commits into from Aug 30, 2019
Merged

Conversation

iomodo
Copy link
Contributor

@iomodo iomodo commented Aug 27, 2019

Summary

This PR will fix plugin translations issues (translation files were not updating on the web-client when plugins were upgraded)

Ticket Link

MM-17494

@iomodo iomodo added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Aug 27, 2019
@iomodo iomodo added this to the v5.15.0 milestone Aug 27, 2019
@iomodo iomodo changed the title [MM-17518] Fix plugin translations [MM-17494] Fix plugin translations Aug 27, 2019
Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts, but nothing blocking. Nice investigation!

if (immutableTranslations) {
copyAndDispatchTranslations(dispatch, translations, sourceFunction(locale), locale);
}
};
}

export function unregisterPluginTranslationsSource(pluginId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to dispatch an event on unregistration too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. We unregister translations on plugin removal, that event is dispatched.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i think we should no? otherwise the plugin translation will remain in memory if i'm not mistaken.

@@ -30,6 +31,16 @@ const pluginTranslationSources = {};

export function registerPluginTranslationsSource(pluginId, sourceFunction) {
pluginTranslationSources[pluginId] = sourceFunction;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely out of scope for this PR, but I'm wondering if this mapping should just live in Redux directly, and copyAndDispatchTranslations gets moved into a reducer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

translations,
},
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing newline here, suggest configuring http://editorconfig.com/

@lieut-data lieut-data removed the 2: Dev Review Requires review by a core commiter label Aug 27, 2019
@lindalumitchell lindalumitchell removed the 3: QA Review Requires review by a QA tester label Aug 30, 2019
@iomodo iomodo merged commit 400fea6 into master Aug 30, 2019
@iomodo iomodo deleted the MM-17518-plugin-translations branch August 30, 2019 07:03
@mattermod
Copy link
Contributor

@iomodo
Error trying doing the automated Cherry picking. Please do this manually

+++ Updating remotes...
Fetching upstream
Fetching origin
+++ Updating remotes done...
+++ Creating local branch automated-cherry-pick-of-#3536-upstream-release-5.15-1567148633
Branch 'automated-cherry-pick-of-#3536-upstream-release-5.15-1567148633' set up to track remote branch 'release-5.15' from 'upstream'.
+++ Downloading patch to /tmp/3536.patch (in case you need to do this again)

+++ About to attempt cherry pick of PR. To reattempt:
  $ git am -3 /tmp/3536.patch

Applying: Fix plugin translations
Applying: "Unregister plugin translations when removed"
Using index info to reconstruct a base tree...
M	actions/global_actions.jsx
M	plugins/index.js
Falling back to patching base and 3-way merge...
Auto-merging plugins/index.js
CONFLICT (content): Merge conflict in plugins/index.js
Auto-merging actions/global_actions.jsx
Patch failed at 0002 "Unregister plugin translations when removed"
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

+++ Conflicts detected:

UU plugins/index.js

+++ Aborting in-progress git am.

+++ Returning you to the master branch and cleaning up.

@lindalumitchell
Copy link
Contributor

@iomodo @lieut-data @crspeller looks like this one needs some help with its cherry-picking?

lieut-data pushed a commit that referenced this pull request Aug 31, 2019
* Fix plugin translations

* "Unregister plugin translations when plugin is removed"

* Fix lint
@lieut-data lieut-data added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Aug 31, 2019
@lieut-data
Copy link
Member

I've manually cherry picked this to v5.15.

translations,
},
});
copyAndDispatchTranslations(dispatch, translations, en, locale);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely works, however it would've been nice if we had converted this into async/await and had just one dispatch in this function rather than dispatching twice as per two different code paths.

...
set variables for 'en'
or set variables when fetching through 'Client4'
...

copyAndDispatchTranslations(dispatch, translations, serverTranslations, locale);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ali-farooq0, is this something we might yet still be able to squeeze in v5.15? Or is it an internal detail that we can safely improve in v5.16?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lieut-data nah, just an internal detail that we can improve for 5.16. No need to rush it for 5.15.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels Sep 3, 2019
@prapti prapti added Setup Cloud Test Server Setup a test server using Mattermost Cloud and removed Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Sep 13, 2019
@mattermod
Copy link
Contributor

Test server destroyed

skheria pushed a commit to uber-archive/mattermost-webapp that referenced this pull request Oct 3, 2019
* Fix plugin translations

* "Unregister plugin translations when plugin is removed"

* Fix lint
skheria pushed a commit to uber-archive/mattermost-webapp that referenced this pull request Oct 3, 2019
* Fix plugin translations

* "Unregister plugin translations when plugin is removed"

* Fix lint
@hanzei hanzei added the 4: Reviews Complete All reviewers have approved the pull request label Jan 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone Docs/Not Needed Does not require documentation
Projects
None yet
9 participants