Skip to content

Commit

Permalink
removed red warning box from completed experiment page
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycoates committed Oct 19, 2016
1 parent 2423d11 commit eda70df
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 48 deletions.
1 change: 0 additions & 1 deletion content-src/experiments/universal-search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,4 @@ contributors:
installation_count: 39943
created: '2016-04-28T03:57:32.270681Z'
modified: '2016-07-20T15:42:28.873321Z'
completed: '2016-10-01T15:42:28.873321Z'
order: 7
6 changes: 3 additions & 3 deletions frontend/src/app/components/ExperimentRowCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const MAX_JUST_UPDATED_PERIOD = 2 * ONE_WEEK;
export default class ExperimentRowCard extends React.Component {

render() {
const { hasAddon, experiment, enabled, isExperimentCompleted } = this.props;
const { hasAddon, experiment, enabled, isAfterCompletedDate } = this.props;

const { description, thumbnail } = experiment;
const installation_count = (experiment.installation_count) ? experiment.installation_count : 0;
const title = experiment.short_title || experiment.title;
const isCompleted = isExperimentCompleted(experiment);
const isCompleted = isAfterCompletedDate(experiment);

// TODO: #1138 Replace this highly hackly hook so that the subtitle comes from the model
const subtitle = (experiment.title === 'No More 404s') ?
Expand Down Expand Up @@ -161,5 +161,5 @@ ExperimentRowCard.propTypes = {
getExperimentLastSeen: React.PropTypes.func.isRequired,
sendToGA: React.PropTypes.func.isRequired,
navigateTo: React.PropTypes.func.isRequired,
isExperimentCompleted: React.PropTypes.func
isAfterCompletedDate: React.PropTypes.func
};
4 changes: 2 additions & 2 deletions frontend/src/app/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { push as routerPush } from 'react-router-redux';
import cookies from 'js-cookie';
import Clipboard from 'clipboard';

import { getInstalled, isExperimentEnabled, isExperimentCompleted, isInstalledLoaded } from '../reducers/addon';
import { getInstalled, isExperimentEnabled, isAfterCompletedDate, isInstalledLoaded } from '../reducers/addon';
import { getExperimentBySlug, isExperimentsLoaded } from '../reducers/experiments';
import experimentSelector from '../selectors/experiment';
import { uninstallAddon, installAddon, enableExperiment, disableExperiment, pollAddon } from '../lib/addon';
Expand Down Expand Up @@ -132,7 +132,7 @@ export default connect(
isDev: state.browser.isDev,
isExperimentEnabled: experiment =>
isExperimentEnabled(state.addon, experiment),
isExperimentCompleted,
isAfterCompletedDate,
isFirefox: state.browser.isFirefox,
isMinFirefox: state.browser.isMinFirefox,
routing: state.routing
Expand Down
30 changes: 9 additions & 21 deletions frontend/src/app/containers/ExperimentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ export class ExperimentDetail extends React.Component {
// TODO: figure out a non-hack way to toggle user counts when we have
// telemetry data coming in from prod
renderInstallationCount() {
const { experiment } = this.props;
const { experiment, isAfterCompletedDate } = this.props;
const { completed, title, installation_count } = experiment;
const eol = completed && (new Date(completed)).getTime() < Date.now();
if (eol) {

if (isAfterCompletedDate(experiment)) {
const completedDate = formatDate(completed);
return (
<span data-l10n-id="completedDateLabel" data-l10n-args={JSON.stringify({ completedDate })}>Experiment End Date: {completedDate}</span>
Expand Down Expand Up @@ -474,16 +474,15 @@ export class ExperimentDetail extends React.Component {

renderExperimentControls() {
const { enabled, isEnabling, isDisabling, progressButtonWidth } = this.state;
const { experiment, installed, hasAddon } = this.props;
const { completed, title, min_release, survey_url } = experiment;
const { experiment, installed, isAfterCompletedDate, hasAddon } = this.props;
const { title, min_release, survey_url } = experiment;
const validVersion = this.isValidVersion(min_release);
const surveyURL = buildSurveyURL('givefeedback', title, installed, survey_url);
const eol = completed && (new Date(completed)).getTime() < Date.now();

if (!hasAddon || !validVersion) {
return null;
}
if (eol) {
if (isAfterCompletedDate(experiment)) {
if (enabled) {
return (
<div className="experiment-controls">
Expand All @@ -510,23 +509,11 @@ export class ExperimentDetail extends React.Component {
}

renderEolBlock() {
const { experiment } = this.props;
if (!experiment.completed) { return null; }
const { experiment, isAfterCompletedDate } = this.props;
if (!experiment.completed || isAfterCompletedDate(experiment)) { return null; }

const title = experiment.title;
const completedDate = formatDate(experiment.completed);
const eol = (new Date(experiment.completed)).getTime() < Date.now();

if (eol) {
return (
<div>
<section className="completed-block">
<h3 data-l10n-id="completedHeading">This experiment has been retired and is no longer supported.</h3>
{this.state.enabled && <p data-l10n-id="completedMessage" data-l10n-args={JSON.stringify({ title })}>You are still able to use {title} but we will no longer be providing updates or support.</p>}
</section>
</div>
);
}

return (
<div className="eol-block">
Expand Down Expand Up @@ -667,6 +654,7 @@ ExperimentDetail.propTypes = {
installed: React.PropTypes.object,
installedAddons: React.PropTypes.array,
navigateTo: React.PropTypes.func,
isAfterCompletedDate: React.PropTypes.func,
isExperimentEnabled: React.PropTypes.func,
requireRestart: React.PropTypes.func,
sendToGA: React.PropTypes.func,
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/app/containers/HomePageNoAddon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import View from '../components/View';
export default class HomePageNoAddon extends React.Component {

render() {
const { experiments, isExperimentCompleted } = this.props;
const { experiments, isAfterCompletedDate } = this.props;

if (experiments.length === 0) { return <LoadingPage />; }

const currentExperiments = experiments.filter(x => !isExperimentCompleted(x));
const currentExperiments = experiments.filter(x => !isAfterCompletedDate(x));

return (
<section data-hook="landing-page">
Expand Down Expand Up @@ -78,5 +78,5 @@ HomePageNoAddon.propTypes = {
hasAddon: React.PropTypes.bool,
isFirefox: React.PropTypes.bool,
experiments: React.PropTypes.array,
isExperimentCompleted: React.PropTypes.func
isAfterCompletedDate: React.PropTypes.func
};
8 changes: 4 additions & 4 deletions frontend/src/app/containers/HomePageWithAddon.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class HomePageWithAddon extends React.Component {
}

render() {
const { experiments, getCookie, removeCookie, getWindowLocation, isExperimentCompleted } = this.props;
const { experiments, getCookie, removeCookie, getWindowLocation, isAfterCompletedDate } = this.props;

if (experiments.length === 0) { return <LoadingPage />; }

Expand All @@ -30,8 +30,8 @@ export default class HomePageWithAddon extends React.Component {
showEmailDialog = true;
}
const { showPastExperiments } = this.state;
const currentExperiments = experiments.filter(x => !isExperimentCompleted(x));
const pastExperiments = experiments.filter(isExperimentCompleted);
const currentExperiments = experiments.filter(x => !isAfterCompletedDate(x));
const pastExperiments = experiments.filter(isAfterCompletedDate);

return (
<View {...this.props}>
Expand Down Expand Up @@ -79,5 +79,5 @@ HomePageWithAddon.propTypes = {
uninstallAddon: React.PropTypes.func,
sendToGA: React.PropTypes.func,
openWindow: React.PropTypes.func,
isExperimentCompleted: React.PropTypes.func
isAfterCompletedDate: React.PropTypes.func
};
2 changes: 1 addition & 1 deletion frontend/src/app/reducers/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const getInstalled = (state) => state.installed;
export const isExperimentEnabled = (state, experiment) =>
!!(experiment && experiment.addon_id in state.installed);

export const isExperimentCompleted = (experiment) =>
export const isAfterCompletedDate = (experiment) =>
((new Date(experiment.completed)).getTime() < Date.now());

export const isInstalledLoaded = (state) => state.installedLoaded;
Expand Down
4 changes: 2 additions & 2 deletions frontend/test/app/components/ExperimentRowCard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('app/components/ExperimentRowCard', () => {
navigateTo: sinon.spy(),
sendToGA: sinon.spy(),
getExperimentLastSeen: sinon.spy(),
isExperimentCompleted: sinon.spy()
isAfterCompletedDate: sinon.spy()
};
subject = shallow(<ExperimentRowCard {...props} />);
});
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('app/components/ExperimentRowCard', () => {
experiment: { ...mockExperiment,
completed: moment().subtract(1, 'days').utc()
},
isExperimentCompleted: () => true
isAfterCompletedDate: () => true
});
expect(findByL10nID('experimentCardLearnMore')).to.have.property('length', 1);
expect(findByL10nID('participantCount')).to.have.property('length', 0);
Expand Down
12 changes: 5 additions & 7 deletions frontend/test/app/containers/ExperimentPage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('app/components/ExperimentPage:ExperimentDetail', () => {
params: {},
uninstallAddon: sinon.spy(),
navigateTo: sinon.spy(),
isAfterCompletedDate: sinon.stub().returns(false),
isExperimentEnabled: sinon.spy(),
requireRestart: sinon.spy(),
sendToGA: sinon.spy(),
Expand Down Expand Up @@ -447,19 +448,16 @@ describe('app/components/ExperimentPage:ExperimentDetail', () => {

describe('with a completed experiment', () => {
beforeEach(() => {
subject.setProps({ experiment: Object.assign({}, mockExperiment, { completed: '2016-10-01' }) });
subject.setProps({
experiment: Object.assign({}, mockExperiment, { completed: '2016-10-01' }),
isAfterCompletedDate: sinon.stub().returns(true)
});
});

it('does not render controls', () => {
expect(subject.find('.experiment-controls').length).to.equal(0);
});

it('displays a retired message box', () => {
expect(subject.find('.completed-block').length).to.equal(1);
expect(findByL10nID('completedHeading').length).to.equal(1);
expect(findByL10nID('eolMessage').length).to.equal(0);
});

it('displays the end date instead of install count', () => {
expect(findByL10nID('completedDateLabel').length).to.equal(1);
expect(findByL10nID('userCountContainer').length).to.equal(0);
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/app/containers/HomePageNoAddon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('app/containers/HomePageNoAddon', () => {
isFirefox: false,
uninstallAddon: sinon.spy(),
sendToGA: sinon.spy(),
isExperimentCompleted: sinon.spy(x => !!x.completed)
isAfterCompletedDate: sinon.spy(x => !!x.completed)
};
subject = shallow(<HomePageNoAddon {...props} />);
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/app/containers/HomePageWithAddon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('app/containers/HomePageWithAddon', () => {
subscribeToBasket: sinon.spy(),
sendToGA: sinon.spy(),
openWindow: sinon.spy(),
isExperimentCompleted: sinon.spy(x => !!x.completed)
isAfterCompletedDate: sinon.spy(x => !!x.completed)
};
subject = shallow(<HomePageWithAddon {...props} />);
});
Expand Down
2 changes: 0 additions & 2 deletions locales/en-US/app.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ shareCopy = Copy
eolMessage = <strong>This experiment is ending on {$completedDate}</strong>.<br/><br/>After then you will still be able to use {$title} but we will no longer be providing updates or support.
eolDisableMessage = The {$title} experiment has ended. Once you uninstall it you won't be able to re-install it through Test Pilot again.
completedHeading = This experiment has been retired and is no longer supported.
completedMessage = You are still able to use {$title} but we will no longer be providing updates or support.
completedDateLabel = Experiment End Date: {$completedDate}
restartRequiredSubHeader = Almost done . . .
Expand Down

0 comments on commit eda70df

Please sign in to comment.