This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work toward new component bundle directories
- Moved ExperimentRowCard and UpdateList components into subdirectories - Extracted IncompatibleAddons as a component from ExperimentPage - Webpack config to extract static/app/app.js.css from component imports - Storybook config changes to use frontend/src/app/**/{ComponentName}/stories.jsx files - Mocha test command changes use frontend/src/app/**/{ComponentName}/tests.js - Hacks to frontend/tasks/pages.js to ignore scss imports - Hacks to test-setup.js to ignore scss imports See also: https://gist.github.com/chuckharmston/01e5b7a16ba9b771863cbb8b2de64138 Issue #2807
- Loading branch information
Showing
18 changed files
with
195 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const path = require('path'); | ||
|
||
// Export a function. Accept the base config as the only param. | ||
module.exports = (storybookBaseConfig, configType) => { | ||
// configType has a value of 'DEVELOPMENT' or 'PRODUCTION' | ||
// You can change the configuration based on that. | ||
// 'PRODUCTION' is used when building the static version of storybook. | ||
|
||
// Make whatever fine-grained changes you need | ||
storybookBaseConfig.module.rules.push({ | ||
test: /\.s?css$/, | ||
loaders: ["style-loader", "css-loader", "sass-loader"], | ||
include: path.resolve(__dirname, '../') | ||
}); | ||
|
||
storybookBaseConfig.module.rules.push({ | ||
test: /\.(png|jpg|gif|svg)$/, | ||
loaders: ['url-loader'] | ||
}); | ||
|
||
// Return the altered config | ||
return storybookBaseConfig; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// @flow | ||
|
||
import React from 'react'; | ||
import { Localized } from 'fluent-react/compat'; | ||
import LocalizedHtml from '../LocalizedHtml'; | ||
|
||
import './index.scss'; | ||
|
||
type IncompatibleAddonsProps = { | ||
experiment: Array, | ||
installedAddons: Array | ||
}; | ||
|
||
export default class IncompatibleAddons extends React.Component { | ||
props: IncompatibleAddonsProps | ||
|
||
render() { | ||
const { incompatible } = this.props.experiment; | ||
const installed = this.getIncompatibleInstalled(incompatible); | ||
if (installed.length === 0) return null; | ||
|
||
const helpUrl = 'https://support.mozilla.org/kb/disable-or-remove-add-ons'; | ||
|
||
return ( | ||
<section className="incompatible-addons"> | ||
<header> | ||
<Localized id="incompatibleHeader"> | ||
<h3> | ||
This experiment may not be compatible with add-ons you have installed. | ||
</h3> | ||
</Localized> | ||
<LocalizedHtml id="incompatibleSubheader"> | ||
<p> | ||
We recommend <a href={helpUrl}>disabling these add-ons</a> before activating this experiment: | ||
</p> | ||
</LocalizedHtml> | ||
</header> | ||
<main> | ||
<ul> | ||
{installed.map(guid => ( | ||
<li key={guid}>{incompatible[guid]}</li> | ||
))} | ||
</ul> | ||
</main> | ||
</section> | ||
); | ||
} | ||
|
||
getIncompatibleInstalled(incompatible) { | ||
if (!incompatible) { | ||
return []; | ||
} | ||
const installed = this.props.installedAddons || []; | ||
return Object.keys(incompatible).filter(guid => ( | ||
installed.indexOf(guid) !== -1 | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// TODO: migrate <IncompatibleAddons> styles from frontend/src/styles/components/_Warning.scss | ||
|
44 changes: 44 additions & 0 deletions
44
frontend/src/app/components/IncompatibleAddons/stories.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import IncompatibleAddons from './index'; | ||
import LayoutWrapper from '../LayoutWrapper'; | ||
|
||
const experiment = { | ||
title: 'Sample experiment', | ||
description: 'This is an example experiment', | ||
subtitle: '', | ||
slug: 'snooze-tabs', | ||
survey_url: 'https://example.com', | ||
created: '2010-06-21T12:12:12Z', | ||
modified: '2010-06-21T12:12:12Z', | ||
incompatible: { | ||
'[email protected]': 'Foo from BarCorp' | ||
} | ||
}; | ||
|
||
const installedAddons = [ | ||
'[email protected]' | ||
]; | ||
|
||
const baseProps = { | ||
experiment, | ||
installedAddons | ||
}; | ||
|
||
storiesOf('IncompatibleAddons', module) | ||
.addDecorator(story => | ||
<div className="blue" style={{ padding: 10 }} onClick={action('click')}> | ||
<div className="stars" /> | ||
<LayoutWrapper flexModifier="card-list"> | ||
{story()} | ||
</LayoutWrapper> | ||
</div> | ||
) | ||
.add('base state', () => | ||
<IncompatibleAddons {...{ experiment, installedAddons }} /> | ||
) | ||
.add('none installed', () => | ||
<IncompatibleAddons {...{ experiment, installedAddons: [] }} /> | ||
) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
|
||
import IncompatibleAddons from './index.js'; | ||
|
||
describe('app/components/IncompatibleAddons', () => { | ||
|
||
it('should exist', () => { | ||
expect(IncompatibleAddons).to.exist; | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.