Skip to content

Commit

Permalink
[FIX JENKINS-41642] Handle when favouriting a pipeline fails (#876)
Browse files Browse the repository at this point in the history
* @jenkins-cd/design-language@0.0.122-tf-JENKINS-41642-2 on core-js

* core-js 0.0.85-tf-JENKINS-41642-1

* @jenkins-cd/design-language@0.0.122-tf-JENKINS-41642-3 on core-js

* @jenkins-cd/design-language@0.0.122-tf-JENKINS-41642-3 and @jenkins-cd/blueocean-core-js@0.0.85-tf-JENKINS-41642-1 on dependants

* A toast for favoriting errors

* @jenkins-cd/design-language@0.0.122 on core-js

* @jenkins-cd/blueocean-core-js@0.0.85 @jenkins-cd/design-language@0.0.122 on dependants

* Allow raw string i18n keys

so as to eliminate the need to provide the defaultValue

* core-js 0.0.86-tf-41642-1

* core-js 0.0.86-tf-41642-1 on dependants

* localization of Favoriting text

* core-js 0.0.86

* core-js 0.0.86 on dependants
  • Loading branch information
tfennelly authored Mar 3, 2017
1 parent d6dad05 commit ab869c0
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 43 deletions.
16 changes: 8 additions & 8 deletions blueocean-core-js/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions blueocean-core-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jenkins-cd/blueocean-core-js",
"version": "0.0.84",
"version": "0.0.86",
"description": "Shared JavaScript libraries for use with Jenkins Blue Ocean",
"main": "dist/js/index.js",
"scripts": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"url": "https://github.com/jenkinsci/blueocean-plugin.git"
},
"dependencies": {
"@jenkins-cd/design-language": "0.0.121",
"@jenkins-cd/design-language": "0.0.122",
"@jenkins-cd/js-extensions": "0.0.33",
"@jenkins-cd/js-modules": "0.0.8",
"@jenkins-cd/logging": "0.0.6",
Expand Down
18 changes: 17 additions & 1 deletion blueocean-core-js/src/js/i18n/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,23 @@ export default function i18nTranslator(pluginName, namespace, onLoad) {
logger.log('Translator instance created for "%s". Language detected as "%s".', translatorCacheKey, detectedLang);
}

translator = I18n.getFixedT(detectedLang, namespace);
const fixedT = I18n.getFixedT(detectedLang, namespace);
translator = function (i18nKey, i18nParams) {
const normalizedKey = i18nKey.replace(/[\W]/g, '.');
let passedParams = i18nParams;
if (normalizedKey !== i18nKey) {
if (!passedParams) {
passedParams = {};
}
if (!passedParams.defaultValue) {
passedParams.defaultValue = i18nKey;
}
if (logger.isDebugEnabled()) {
logger.debug(`Normalized i18n key "${i18nKey}" to "${normalizedKey}".`);
}
}
return fixedT(normalizedKey, passedParams);
};
translatorCache[translatorCacheKey] = translator;
}

Expand Down
26 changes: 13 additions & 13 deletions blueocean-dashboard/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions blueocean-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"skin-deep": "0.16.0"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.84",
"@jenkins-cd/design-language": "0.0.121",
"@jenkins-cd/blueocean-core-js": "0.0.86",
"@jenkins-cd/design-language": "0.0.122",
"@jenkins-cd/js-extensions": "0.0.33",
"@jenkins-cd/js-modules": "0.0.8",
"@jenkins-cd/react-material-icons": "1.0.0",
Expand Down
12 changes: 6 additions & 6 deletions blueocean-personalization/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions blueocean-personalization/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"react-addons-test-utils": "15.3.2"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.84",
"@jenkins-cd/design-language": "0.0.121",
"@jenkins-cd/blueocean-core-js": "0.0.86",
"@jenkins-cd/design-language": "0.0.122",
"@jenkins-cd/js-extensions": "0.0.33",
"@jenkins-cd/js-modules": "0.0.8",
"immutable": "3.8.1",
Expand Down
12 changes: 11 additions & 1 deletion blueocean-personalization/src/main/js/redux/FavoritesActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
* Created by cmeyers on 7/6/16.
*/
import { UrlConfig, Fetch } from '@jenkins-cd/blueocean-core-js';
import { capabilityAugmenter as augmenter } from '@jenkins-cd/blueocean-core-js';
import { capabilityAugmenter as augmenter, ToastService, i18nTranslator } from '@jenkins-cd/blueocean-core-js';

import { ACTION_TYPES } from './FavoritesStore';
import { cleanSlashes } from '../util/UrlUtils';

const translator = i18nTranslator('blueocean-personalization');
const fetchFlags = {
[ACTION_TYPES.SET_FAVORITES]: false,
};
Expand Down Expand Up @@ -86,6 +87,15 @@ export const actions = {
});
})
.catch((error) => {
const responseBody = error.responseBody;
if (responseBody && responseBody.code && responseBody.message) {
ToastService.newToast({
style: 'error',
caption: translator('Favoriting Error'),
text: translator(responseBody.message),
});
}

fetchFlags[actionType] = false;
console.error(error); // eslint-disable-line no-console
// call again with no payload so actions handle missing data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
dashboardCard.input.required=Input Required
dashboardCard.input.favorite=Favorites

Favoriting.Error=Favoriting Error
no.default.branch.to.favorite=No default branch (e.g. "master") to favorite
12 changes: 6 additions & 6 deletions blueocean-web/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions blueocean-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"zombie": "4.2.1"
},
"dependencies": {
"@jenkins-cd/blueocean-core-js": "0.0.84",
"@jenkins-cd/design-language": "0.0.121",
"@jenkins-cd/blueocean-core-js": "0.0.86",
"@jenkins-cd/design-language": "0.0.122",
"@jenkins-cd/js-extensions": "0.0.33",
"@jenkins-cd/js-modules": "0.0.8",
"history": "2.0.2",
Expand Down

0 comments on commit ab869c0

Please sign in to comment.