Skip to content

Commit

Permalink
feat(admin): add target-profile board button link
Browse files Browse the repository at this point in the history
  • Loading branch information
Faraopix committed Feb 5, 2025
1 parent c30f3f3 commit 873f68d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 18 deletions.
45 changes: 28 additions & 17 deletions admin/app/components/target-profiles/target-profile.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { t } from 'ember-intl';
import { pageTitle } from 'ember-page-title';
import ENV from 'pix-admin/config/environment';

import formatDate from '../../helpers/format-date';
import ConfirmPopup from '../confirm-popup';
Expand Down Expand Up @@ -51,6 +52,11 @@ export default class TargetProfile extends Component {
return Boolean(this.args.model.hasLinkedAutonomousCourse);
}

get externalURL() {
const urlDashboardPrefix = ENV.APP.TARGETPROFILE_DASHBOARD_URL;
return urlDashboardPrefix && `${urlDashboardPrefix}?id=${this.args.model.id}`;
}

displayBooleanState = (bool) => {
const yes = this.intl.t('common.words.yes');
const no = this.intl.t('common.words.no');
Expand Down Expand Up @@ -235,21 +241,26 @@ export default class TargetProfile extends Component {
@route="authenticated.target-profiles.edit"
@model={{@model.id}}
@size="small"
@variant="secondary"
@variant="primary"
>
{{t "common.actions.edit"}}
</PixButtonLink>
<div class="target-profile__actions-separator"></div>

{{#unless @model.isSimplifiedAccess}}
<PixButton
@size="small"
@variant="secondary"
@triggerAction={{this.toggleDisplaySimplifiedAccessPopupConfirm}}
>
Marquer comme accès simplifié
</PixButton>
{{/unless}}
<PixButton @size="small" @variant="primary" @triggerAction={{this.openCopyModal}}>{{t
"pages.target-profiles.copy.button.label"
}}</PixButton>

<Copy @isOpen={{this.showCopyModal}} @onClose={{this.closeCopyModal}} @onSubmit={{this.copyTargetProfile}} />

<div class="target-profile__actions-separator"></div>
<PixButtonLink
@variant="secondary"
@href="{{this.externalURL}}"
@size="small"
target="_blank"
rel="noopener noreferrer"
>Tableau de bord
</PixButtonLink>

<PixButton @triggerAction={{this.downloadJSON}} @size="small" @variant="success">
Télécharger le profil cible (JSON)
Expand All @@ -259,14 +270,14 @@ export default class TargetProfile extends Component {
Télécharger le profil cible (PDF)
</PixButton>

<PixButton @size="small" @triggerAction={{this.openCopyModal}}>{{t
"pages.target-profiles.copy.button.label"
}}</PixButton>

<Copy @isOpen={{this.showCopyModal}} @onClose={{this.closeCopyModal}} @onSubmit={{this.copyTargetProfile}} />
<div class="target-profile__actions-separator"></div>
{{#unless @model.isSimplifiedAccess}}
<PixButton @size="small" @variant="error" @triggerAction={{this.toggleDisplaySimplifiedAccessPopupConfirm}}>
Marquer comme accès simplifié
</PixButton>
{{/unless}}

{{#unless @model.outdated}}
<div class="target-profile__actions-spacer"></div>
<PixButton @size="small" @variant="error" @triggerAction={{this.toggleDisplayConfirm}}>
Marquer comme obsolète
</PixButton>
Expand Down
5 changes: 4 additions & 1 deletion admin/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module.exports = function (environment) {
minValue: 1,
}),
ORGANIZATION_DASHBOARD_URL: process.env.ORGANIZATION_DASHBOARD_URL,
TARGETPROFILE_DASHBOARD_URL: process.env.TARGETPROFILE_DASHBOARD_URL,
CERTIFICATION_CENTER_DASHBOARD_URL: process.env.CERTIFICATION_CENTER_DASHBOARD_URL,
USER_DASHBOARD_URL: process.env.USER_DASHBOARD_URL,
MAX_LEVEL: 8,
Expand Down Expand Up @@ -124,6 +125,8 @@ module.exports = function (environment) {
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
ENV.APP.TARGETPROFILE_DASHBOARD_URL =
'https://metabase.pix.fr/dashboard/1456-recherche-infos-profil-cible-donnees-froides';
if (analyticsEnabled) {
ENV.matomo.url = process.env.WEB_ANALYTICS_URL;
ENV.matomo.debug = true;
Expand All @@ -133,12 +136,12 @@ module.exports = function (environment) {
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';

ENV.APP.API_HOST = 'http://localhost:3000';

// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.TARGETPROFILE_DASHBOARD_URL = 'https://metabase.pix.fr/dashboard';

ENV.APP.rootElement = '#ember-testing';
ENV.APP.autoboot = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render } from '@1024pix/ember-testing-library';
import { t } from 'ember-intl/test-support';
import TargetProfile from 'pix-admin/components/target-profiles/target-profile';
import ENV from 'pix-admin/config/environment';
import { module, test } from 'qunit';

import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering';
Expand Down Expand Up @@ -41,6 +42,18 @@ module('Integration | Component | TargetProfile', function (hooks) {
assert.ok(_findByListItemText(screen, `${t('pages.target-profiles.resettable-checkbox.label')} : Non`));
assert.ok(_findByListItemText(screen, `${t('pages.target-profiles.tubes-count')} : ${model.tubesCount}`));
});
test('it should display link to a metabase dashboard', async function (assert) {
//given
const model = { ...targetProfileSampleData };

// when
const screen = await render(<template><TargetProfile @model={{model}} /></template>);

//then
const buttonLink = screen.getByRole('link', { name: 'Tableau de bord' });
assert.ok(buttonLink);
assert.strictEqual(buttonLink.getAttribute('href'), `${ENV.APP.TARGETPROFILE_DASHBOARD_URL}?id=${model.id}`);
});
});

module('when no campaign is linked', function () {
Expand Down

0 comments on commit 873f68d

Please sign in to comment.