diff --git a/components/centraldashboard/app/api.ts b/components/centraldashboard/app/api.ts index 129083146aa..cdc0f69ef3a 100644 --- a/components/centraldashboard/app/api.ts +++ b/components/centraldashboard/app/api.ts @@ -72,17 +72,11 @@ export class Api { .get( '/dashboard-links', async (req: Request, res: Response) => { - const acceptlanguage = req.header('accept-language'); const cm = await this.k8sService.getConfigMap(); let langLinks = {}; try { const links = JSON.parse(cm.data["links"]); - const lang = this.resolveLanguage ( - this.getBrowserLanguages(acceptlanguage), - Object.getOwnPropertyNames(links), - cm.data["defaultLanguage"] - ); - langLinks = links[lang]; + langLinks = links[req.query.lang]; }catch(e){ return apiError({ res, code: 500, diff --git a/components/centraldashboard/cypress/e2e/main-page.cy.ts b/components/centraldashboard/cypress/e2e/main-page.cy.ts index 1b0bf15a0b1..50e2d494988 100644 --- a/components/centraldashboard/cypress/e2e/main-page.cy.ts +++ b/components/centraldashboard/cypress/e2e/main-page.cy.ts @@ -74,11 +74,11 @@ describe('Main Page', () => { cy.get('main-page').shadow().find('a[href="https://grafana.aaw-dev.cloud.statcan.ca/d/ZLp774O4z/namespace-metrics?orgId=1&var-namespace=test-namespace&kiosk=tv"]').should('exist'); cy.get('main-page').shadow().find('a[href="https://grafana.aaw-dev.cloud.statcan.ca/d/ZLp774O4z/namespace-metrics?orgId=1&var-namespace=test-namespace&kiosk=tv"]').find('paper-item').should('have.text', 'Metrics'); - cy.get('main-page').shadow().find('a[href="https://github.com/kubeflow/kubeflow"]').should('exist'); - cy.get('main-page').shadow().find('a[href="https://github.com/kubeflow/kubeflow"]').find('paper-item').should('have.text', 'GitHub'); + cy.get('main-page').shadow().find('a[href="https://github.com/StatCan/kubeflow"]').should('exist'); + cy.get('main-page').shadow().find('a[href="https://github.com/StatCan/kubeflow"]').find('paper-item').should('have.text', 'GitHub'); - cy.get('main-page').shadow().find('a[href="https://www.kubeflow.org/docs/about/kubeflow/"]').should('exist'); - cy.get('main-page').shadow().find('a[href="https://www.kubeflow.org/docs/about/kubeflow/"]').find('paper-item').should('have.text', 'Documentation'); + cy.get('main-page').shadow().find('a[href="https://statcan.github.io/aaw/"]').should('exist'); + cy.get('main-page').shadow().find('a[href="https://statcan.github.io/aaw/"]').find('paper-item').should('have.text', 'Documentation'); //mock env info to hide manage contributors link cy.intercept('GET', `/api/workgroup/env-info`, { @@ -174,10 +174,10 @@ describe('Main Page', () => { cy.get('main-page').shadow().find('a[href="https://grafana.aaw-dev.cloud.statcan.ca/d/ZLp774O4z/namespace-metrics?orgId=1&var-namespace=test-namespace-2&kiosk=tv"]').should('exist'); cy.get('main-page').shadow().find('a[href="https://grafana.aaw-dev.cloud.statcan.ca/d/ZLp774O4z/namespace-metrics?orgId=1&var-namespace=test-namespace-2&kiosk=tv"]').find('paper-item').should('have.text', 'Metrics'); - cy.get('main-page').shadow().find('a[href="https://github.com/kubeflow/kubeflow"]').should('exist'); - cy.get('main-page').shadow().find('a[href="https://github.com/kubeflow/kubeflow"]').find('paper-item').should('have.text', 'GitHub'); + cy.get('main-page').shadow().find('a[href="https://github.com/StatCan/kubeflow"]').should('exist'); + cy.get('main-page').shadow().find('a[href="https://github.com/StatCan/kubeflow"]').find('paper-item').should('have.text', 'GitHub'); - cy.get('main-page').shadow().find('a[href="https://www.kubeflow.org/docs/about/kubeflow/"]').should('exist'); - cy.get('main-page').shadow().find('a[href="https://www.kubeflow.org/docs/about/kubeflow/"]').find('paper-item').should('have.text', 'Documentation'); + cy.get('main-page').shadow().find('a[href="https://statcan.github.io/aaw/"]').should('exist'); + cy.get('main-page').shadow().find('a[href="https://statcan.github.io/aaw/"]').find('paper-item').should('have.text', 'Documentation'); }); }) \ No newline at end of file diff --git a/components/centraldashboard/cypress/support/commands.ts b/components/centraldashboard/cypress/support/commands.ts index 8161aec4b8a..85b54c8e519 100644 --- a/components/centraldashboard/cypress/support/commands.ts +++ b/components/centraldashboard/cypress/support/commands.ts @@ -43,7 +43,7 @@ Cypress.Commands.add('mockWorkgroupRequest', () => { }); Cypress.Commands.add('mockDashboardLinksRequest', () => { - cy.intercept('GET', `/api/dashboard-links`, { + cy.intercept('GET', `/api/dashboard-links?lang=*`, { fixture: 'dashboard-links', }).as('mockDashboardLinksRequest'); }); diff --git a/components/centraldashboard/public/assets/i18n/languages.json b/components/centraldashboard/public/assets/i18n/languages.json index 3517f727ba5..e3389832b4e 100644 --- a/components/centraldashboard/public/assets/i18n/languages.json +++ b/components/centraldashboard/public/assets/i18n/languages.json @@ -47,6 +47,7 @@ "mainPage.tabActivity": "Activity", "mainPage.footerBuildVersion": "Build: {buildVersion} | Dashboard: v {dashVersion} | Isolation-Mode: {isolationMode}", "mainPage.errGeneric": "An error occured.", + "mainPage.languageButton": "Français", "notFound.invalidPagePart1": "Sorry, ", "notFound.invalidPagePart2": " is not a valid page", "pipelinesCard.txtCreated": "Created ", @@ -152,6 +153,7 @@ "mainPage.tabActivity": "Activité", "mainPage.footerBuildVersion": "Version: {buildVersion} | Dashboard: v {dashVersion} | Mode d'isolation: {isolationMode}", "mainPage.errGeneric": "Une erreur est survenue.", + "mainPage.languageButton": "English", "notFound.invalidPagePart1": "Désolé, ", "notFound.invalidPagePart2": " n'est pas une page valide", "pipelinesCard.txtCreated": "Créé", diff --git a/components/centraldashboard/public/components/activity-view.js b/components/centraldashboard/public/components/activity-view.js index 614142cb279..472462b118f 100644 --- a/components/centraldashboard/public/components/activity-view.js +++ b/components/centraldashboard/public/components/activity-view.js @@ -3,12 +3,14 @@ import '@polymer/iron-ajax/iron-ajax.js'; import '@polymer/iron-icon/iron-icon.js'; import '@polymer/iron-icons/iron-icons.js'; import '@polymer/paper-progress/paper-progress.js'; -import localizationMixin from './localization-mixin.js'; +// eslint-disable-next-line max-len +import {AppLocalizeBehavior} from '@polymer/app-localize-behavior/app-localize-behavior.js'; +import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js'; import {html, PolymerElement} from '@polymer/polymer'; import './activities-list.js'; // eslint-disable-next-line max-len -export class ActivityView extends localizationMixin(PolymerElement) { +export class ActivityView extends mixinBehaviors([AppLocalizeBehavior], PolymerElement) { static get template() { return html` diff --git a/components/centraldashboard/public/components/manage-users-view-contributor_test.js b/components/centraldashboard/public/components/manage-users-view-contributor_test.js index b8a97060083..0a95adfbd79 100644 --- a/components/centraldashboard/public/components/manage-users-view-contributor_test.js +++ b/components/centraldashboard/public/components/manage-users-view-contributor_test.js @@ -5,6 +5,7 @@ import {mockIronAjax, yieldForRequests} from '../ajax_test_helper'; import {flush} from '@polymer/polymer/lib/utils/flush.js'; import './dashboard-view'; +import {languages} from '../assets/i18n/languages.json'; const FIXTURE_ID = 'manage-users-view-contributor-fixture'; const MU_VIEW_SELECTOR_ID = 'test-manage-users-contributor-view'; @@ -32,6 +33,8 @@ describe('Manage Users View Contributor', () => { beforeEach(() => { document.getElementById(FIXTURE_ID).create(); manageUsersView = document.getElementById(MU_VIEW_SELECTOR_ID); + manageUsersView.language = 'en'; + manageUsersView.resources = languages; }); afterEach(() => { diff --git a/components/centraldashboard/public/components/manage-users-view.js b/components/centraldashboard/public/components/manage-users-view.js index d88649c74ed..03d77ea2106 100644 --- a/components/centraldashboard/public/components/manage-users-view.js +++ b/components/centraldashboard/public/components/manage-users-view.js @@ -9,17 +9,18 @@ import '@polymer/paper-icon-button/paper-icon-button.js'; import '@vaadin/vaadin-grid/vaadin-grid.js'; import '@vaadin/vaadin-grid/vaadin-grid-selection-column.js'; import '@vaadin/vaadin-grid/vaadin-grid-sort-column.js'; - +// eslint-disable-next-line max-len +import {AppLocalizeBehavior} from '@polymer/app-localize-behavior/app-localize-behavior.js'; +import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js'; import {html, PolymerElement} from '@polymer/polymer'; import './manage-users-view-contributor.js'; import css from './manage-users-view.css'; import template from './manage-users-view.pug'; import utilitiesMixin from './utilities-mixin.js'; -import localizationMixin from './localization-mixin.js'; // eslint-disable-next-line max-len -export class ManageUsersView extends utilitiesMixin(localizationMixin(PolymerElement)) { +export class ManageUsersView extends mixinBehaviors([AppLocalizeBehavior], utilitiesMixin(PolymerElement)) { static get template() { return html([` @@ -47,9 +48,10 @@ export class ManageUsersView extends utilitiesMixin(localizationMixin(PolymerEle /** * Returns namespaces and roles * @param {[object]} ns Namespaces array. + * @param {[object]} lang Language string. * @return {[string, [string]]} rows for namespace table. */ - nsBreakdown(ns) { + nsBreakdown(ns, lang) { const {namespaces} = this; if (!namespaces) return; const roleStrings = { diff --git a/components/centraldashboard/public/components/manage-users-view.pug b/components/centraldashboard/public/components/manage-users-view.pug index 554b2697e21..3e0743bf07d 100644 --- a/components/centraldashboard/public/components/manage-users-view.pug +++ b/components/centraldashboard/public/components/manage-users-view.pug @@ -15,12 +15,12 @@ section#Main-Content iron-icon.icon(icon='kubeflow:namespace') span.text {{localize('manageUsersView.lblNamespaceMemberships')}} .content.small - vaadin-grid(items='[[nsBreakdown(namespaces)]]', theme="no-border", height-by-rows, multi-sort) + vaadin-grid(items='[[nsBreakdown(namespaces, language)]]', theme="no-border", height-by-rows, multi-sort) vaadin-grid-column(width='15em', path='0', flex-grow='2', header="{{localize('manageUsersView.headerNamespaces')}}") vaadin-grid-column(width='9em', path='1', header="{{localize('manageUsersView.headerYouRole')}}") article.Contributors(hidden$='[[empty(multiOwnedNamespaces)]]') template(is='dom-repeat', items='[[multiOwnedNamespaces]]' as='multiOwnedNamespace') - manage-users-view-contributor(owned-namespace='[[multiOwnedNamespace]]') + manage-users-view-contributor(owned-namespace='[[multiOwnedNamespace]]', language='[[language]]', resources='[[resources]]') article.Cluster-Namespaces(hidden$='[[empty(isClusterAdmin)]]') h2 iron-icon.icon(icon='kubeflow:namespace') diff --git a/components/centraldashboard/public/components/manage-users-view_test.js b/components/centraldashboard/public/components/manage-users-view_test.js index 60ce5587c5b..4c06cd89731 100644 --- a/components/centraldashboard/public/components/manage-users-view_test.js +++ b/components/centraldashboard/public/components/manage-users-view_test.js @@ -5,6 +5,7 @@ import {mockIronAjax, yieldForRequests} from '../ajax_test_helper'; import {flush} from '@polymer/polymer/lib/utils/flush.js'; import './dashboard-view'; +import {languages} from '../assets/i18n/languages.json'; const FIXTURE_ID = 'manage-users-view-fixture'; const MU_VIEW_SELECTOR_ID = 'test-manage-users-view'; @@ -33,6 +34,8 @@ describe('Manage Users View', () => { beforeEach(() => { document.getElementById(FIXTURE_ID).create(); manageUsersView = document.getElementById(MU_VIEW_SELECTOR_ID); + manageUsersView.language = 'en'; + manageUsersView.resources = languages; }); afterEach(() => { diff --git a/components/centraldashboard/public/components/namespace-needed-view.js b/components/centraldashboard/public/components/namespace-needed-view.js index 17ef54e3b01..6f62f494d28 100644 --- a/components/centraldashboard/public/components/namespace-needed-view.js +++ b/components/centraldashboard/public/components/namespace-needed-view.js @@ -1,7 +1,10 @@ import {html, PolymerElement} from '@polymer/polymer'; -import localizationMixin from './localization-mixin.js'; +// eslint-disable-next-line max-len +import {AppLocalizeBehavior} from '@polymer/app-localize-behavior/app-localize-behavior.js'; +import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js'; -export class NamespaceNeededView extends localizationMixin(PolymerElement) { +// eslint-disable-next-line max-len +export class NamespaceNeededView extends mixinBehaviors([AppLocalizeBehavior], PolymerElement) { static get template() { return html`

{{localize('namespaceNeeded.text1')}} - {{localize('namespaceNeeded.text2')}} - {{localize('namespaceNeeded.text3')}}

+ {{localize('namespaceNeeded.text2')}} + {{localize('namespaceNeeded.text3')}} +

`; } } diff --git a/components/centraldashboard/public/components/namespace-selector.js b/components/centraldashboard/public/components/namespace-selector.js index 46e2aec6b7b..a8be59fba53 100644 --- a/components/centraldashboard/public/components/namespace-selector.js +++ b/components/centraldashboard/public/components/namespace-selector.js @@ -4,7 +4,9 @@ import '@polymer/paper-button/paper-button.js'; import '@polymer/paper-menu-button/paper-menu-button.js'; import '@polymer/paper-listbox/paper-listbox.js'; import '@polymer/paper-item/paper-item.js'; -import localizationMixin from './localization-mixin.js'; +// eslint-disable-next-line max-len +import {AppLocalizeBehavior} from '@polymer/app-localize-behavior/app-localize-behavior.js'; +import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class.js'; import {html, PolymerElement} from '@polymer/polymer/polymer-element.js'; @@ -12,7 +14,8 @@ import {html, PolymerElement} from '@polymer/polymer/polymer-element.js'; * Component to retrieve and allow namespace selection. Bubbles the selected * items up to the query string in the 'ns' parameter. */ -export class NamespaceSelector extends localizationMixin(PolymerElement) { +// eslint-disable-next-line max-len +export class NamespaceSelector extends mixinBehaviors([AppLocalizeBehavior], PolymerElement) { static get template() { return html`

- {{localize('s3Proxy.defaultMessage')}} + {{localize('s3Proxy.defaultMessage')}}

`; } diff --git a/components/centraldashboard/public/components/security-messages-card.js b/components/centraldashboard/public/components/security-messages-card.js index e4f7e9e768b..1c4031b916f 100644 --- a/components/centraldashboard/public/components/security-messages-card.js +++ b/components/centraldashboard/public/components/security-messages-card.js @@ -7,7 +7,6 @@ import '@polymer/paper-ripple/paper-ripple.js'; import '@polymer/paper-icon-button/paper-icon-button.js'; import '@polymer/paper-progress/paper-progress.js'; import './iframe-link.js'; -import localizationMixin from './localization-mixin.js'; import {html, PolymerElement} from '@polymer/polymer'; @@ -17,8 +16,7 @@ import '@polymer/paper-styles/element-styles/paper-material-styles.js'; /** * Component to retrieve and display recently modified Jupyter Notebooks. */ -// eslint-disable-next-line max-len -export class SecurityMessagesCard extends localizationMixin(PolymerElement) { +export class SecurityMessagesCard extends PolymerElement { static get template() { return html`