Skip to content

Commit 087f2d2

Browse files
authored
Move InstallButton into core (#930)
* Move InstallButton into core * remove unused types
1 parent 027fd13 commit 087f2d2

File tree

21 files changed

+121
-108
lines changed

21 files changed

+121
-108
lines changed

src/amo/components/AddonDetail.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { PropTypes } from 'react';
22

33
import AddonMeta from 'amo/components/AddonMeta';
4-
import InstallButton from 'disco/components/InstallButton';
4+
import InstallButton from 'core/components/InstallButton';
55
import LikeButton from 'amo/components/LikeButton';
66
import ScreenShots from 'amo/components/ScreenShots';
77
import SearchBox from 'amo/components/SearchBox';

src/disco/css/InstallButton.scss renamed to src/core/components/InstallButton/InstallButton.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ $installStripeColor2: #00c42e;
220220
&.enabled,
221221
&.installed {
222222
input + label::before {
223-
background: $switchBackgroundOn url('../img/tick.svg') no-repeat 35% 50%;
223+
background: $switchBackgroundOn url('./img/tick.svg') no-repeat 35% 50%;
224224

225225
[dir=rtl] & {
226226
background-position: 65% 50%;

src/disco/components/InstallButton.js renamed to src/core/components/InstallButton/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {
1414
UNKNOWN,
1515
validAddonTypes,
1616
validInstallStates as validStates,
17-
} from 'disco/constants';
17+
} from 'core/constants';
1818
import { getThemeData } from 'disco/themePreview';
1919

20-
import 'disco/css/InstallButton.scss';
20+
import './InstallButton.scss';
2121

2222
export class InstallButton extends React.Component {
2323
static propTypes = {

src/core/constants.js

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Addon States.
2+
export const DISABLED = 'DISABLED';
3+
export const DISABLING = 'DISABLING';
4+
export const DOWNLOADING = 'DOWNLOADING';
5+
export const ENABLED = 'ENABLED';
6+
export const ENABLING = 'ENABLING';
7+
export const ERROR = 'ERROR';
8+
export const INSTALLED = 'INSTALLED';
9+
export const INSTALLING = 'INSTALLING';
10+
export const UNINSTALLED = 'UNINSTALLED';
11+
export const UNINSTALLING = 'UNINSTALLING';
12+
export const UNKNOWN = 'UNKNOWN';
13+
export const validInstallStates = [
14+
DISABLED,
15+
DISABLING,
16+
ENABLED,
17+
ENABLING,
18+
DOWNLOADING,
19+
ENABLED,
20+
ERROR,
21+
INSTALLED,
22+
INSTALLING,
23+
UNINSTALLED,
24+
UNINSTALLING,
25+
UNKNOWN,
26+
];
27+
28+
// Add-on error states.
29+
export const DOWNLOAD_FAILED = 'DOWNLOAD_FAILED';
30+
export const INSTALL_FAILED = 'INSTALL_FAILED';
31+
32+
// Unrecoverable errors.
33+
export const FATAL_INSTALL_ERROR = 'FATAL_INSTALL_ERROR';
34+
export const FATAL_UNINSTALL_ERROR = 'FATAL_UNINSTALL_ERROR';
35+
export const FATAL_ERROR = 'FATAL_ERROR';
36+
37+
// Add-on types.
38+
export const API_THEME_TYPE = 'persona';
39+
export const EXTENSION_TYPE = 'extension';
40+
export const THEME_TYPE = 'theme';
41+
export const validAddonTypes = [
42+
EXTENSION_TYPE,
43+
THEME_TYPE,
44+
];
45+
46+
// Theme preview actions.
47+
export const THEME_INSTALL = 'InstallBrowserTheme';
48+
export const THEME_PREVIEW = 'PreviewBrowserTheme';
49+
export const THEME_RESET_PREVIEW = 'ResetBrowserThemePreview';
50+
export const validThemeActions = [
51+
THEME_INSTALL,
52+
THEME_PREVIEW,
53+
THEME_RESET_PREVIEW,
54+
];
55+
56+
export const installEventList = [
57+
'onDownloadStarted',
58+
'onDownloadProgress',
59+
'onDownloadEnded',
60+
'onDownloadCancelled',
61+
'onDownloadFailed',
62+
'onInstallStarted',
63+
'onInstallProgress',
64+
'onInstallEnded',
65+
'onInstallCancelled',
66+
'onInstallFailed',
67+
];
68+
69+
// Install Types
70+
export const INSTALL_STATE = 'INSTALL_STATE';
71+
export const START_DOWNLOAD = 'START_DOWNLOAD';
72+
export const DOWNLOAD_PROGRESS = 'DOWNLOAD_PROGRESS';
73+
export const INSTALL_COMPLETE = 'INSTALL_COMPLETE';
74+
export const UNINSTALL_COMPLETE = 'UNINSTALL_COMPLETE';
75+
export const INSTALL_ERROR = 'INSTALL_ERROR';
76+
77+
export const acceptedInstallTypes = [
78+
INSTALL_STATE,
79+
START_DOWNLOAD,
80+
DOWNLOAD_PROGRESS,
81+
INSTALL_COMPLETE,
82+
UNINSTALL_COMPLETE,
83+
INSTALL_ERROR,
84+
];

src/core/reducers/addons.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { API_THEME_TYPE, THEME_TYPE } from 'disco/constants';
1+
import { API_THEME_TYPE, THEME_TYPE } from 'core/constants';
22

33
const initialState = {};
44

src/disco/addonManager.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import log from 'core/logger';
33
import {
44
globalEvents,
55
globalEventStatusMap,
6-
installEventList,
76
SET_ENABLE_NOT_AVAILABLE,
87
} from 'disco/constants';
8+
import {
9+
installEventList,
10+
} from 'core/constants';
911

1012

1113
export function getAddon(guid, { _mozAddonManager = window.navigator.mozAddonManager } = {}) {

src/disco/components/Addon.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import tracking from 'core/tracking';
1212
import * as addonManager from 'disco/addonManager';
1313
import log from 'core/logger';
1414

15-
import InstallButton from 'disco/components/InstallButton';
15+
import InstallButton from 'core/components/InstallButton';
1616
import {
17-
CLOSE_INFO,
1817
DISABLED,
1918
DOWNLOAD_FAILED,
2019
DOWNLOAD_PROGRESS,
@@ -24,22 +23,25 @@ import {
2423
FATAL_ERROR,
2524
FATAL_INSTALL_ERROR,
2625
FATAL_UNINSTALL_ERROR,
27-
INSTALL_CATEGORY,
2826
INSTALL_ERROR,
2927
INSTALL_FAILED,
3028
INSTALL_STATE,
31-
SET_ENABLE_NOT_AVAILABLE,
32-
SHOW_INFO,
3329
START_DOWNLOAD,
3430
THEME_INSTALL,
3531
THEME_PREVIEW,
3632
THEME_RESET_PREVIEW,
3733
THEME_TYPE,
3834
UNINSTALLED,
3935
UNINSTALLING,
40-
UNINSTALL_CATEGORY,
4136
validAddonTypes,
4237
validInstallStates,
38+
} from 'core/constants';
39+
import {
40+
CLOSE_INFO,
41+
INSTALL_CATEGORY,
42+
SET_ENABLE_NOT_AVAILABLE,
43+
SHOW_INFO,
44+
UNINSTALL_CATEGORY,
4345
} from 'disco/constants';
4446

4547
import 'disco/css/Addon.scss';

src/disco/constants.js

+2-81
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,19 @@
1-
// Addon States.
2-
export const DISABLED = 'DISABLED';
3-
export const DISABLING = 'DISABLING';
4-
export const DOWNLOADING = 'DOWNLOADING';
5-
export const ENABLED = 'ENABLED';
6-
export const ENABLING = 'ENABLING';
7-
export const ERROR = 'ERROR';
8-
export const INSTALLED = 'INSTALLED';
9-
export const INSTALLING = 'INSTALLING';
10-
export const UNINSTALLED = 'UNINSTALLED';
11-
export const UNINSTALLING = 'UNINSTALLING';
12-
export const UNKNOWN = 'UNKNOWN';
13-
export const validInstallStates = [
1+
import {
142
DISABLED,
153
DISABLING,
164
ENABLED,
175
ENABLING,
18-
DOWNLOADING,
19-
ENABLED,
20-
ERROR,
216
INSTALLED,
227
INSTALLING,
238
UNINSTALLED,
249
UNINSTALLING,
25-
UNKNOWN,
26-
];
27-
28-
// Add-on error states.
29-
export const DOWNLOAD_FAILED = 'DOWNLOAD_FAILED';
30-
export const INSTALL_FAILED = 'INSTALL_FAILED';
31-
32-
// Unrecoverable errors.
33-
export const FATAL_INSTALL_ERROR = 'FATAL_INSTALL_ERROR';
34-
export const FATAL_UNINSTALL_ERROR = 'FATAL_UNINSTALL_ERROR';
35-
export const FATAL_ERROR = 'FATAL_ERROR';
36-
37-
// Add-on types.
38-
export const API_THEME_TYPE = 'persona';
39-
export const EXTENSION_TYPE = 'extension';
40-
export const THEME_TYPE = 'theme';
41-
// These types are not used.
42-
// export const DICT_TYPE = 'dictionary';
43-
// export const SEARCH_TYPE = 'search';
44-
// export const LPAPP_TYPE = 'language';
45-
// export const PERSONA_TYPE = 'persona';
46-
export const validAddonTypes = [
47-
EXTENSION_TYPE,
48-
THEME_TYPE,
49-
];
50-
51-
// Theme preview actions.
52-
export const THEME_INSTALL = 'InstallBrowserTheme';
53-
export const THEME_PREVIEW = 'PreviewBrowserTheme';
54-
export const THEME_RESET_PREVIEW = 'ResetBrowserThemePreview';
55-
export const validThemeActions = [
56-
THEME_INSTALL,
57-
THEME_PREVIEW,
58-
THEME_RESET_PREVIEW,
59-
];
60-
61-
export const installEventList = [
62-
'onDownloadStarted',
63-
'onDownloadProgress',
64-
'onDownloadEnded',
65-
'onDownloadCancelled',
66-
'onDownloadFailed',
67-
'onInstallStarted',
68-
'onInstallProgress',
69-
'onInstallEnded',
70-
'onInstallCancelled',
71-
'onInstallFailed',
72-
];
10+
} from 'core/constants';
7311

7412
export const INSTALL_CATEGORY = 'AMO Addon / Theme Installs';
7513
export const UNINSTALL_CATEGORY = 'AMO Addon / Theme Uninstalls';
7614
export const VIDEO_CATEGORY = 'Discovery Video';
7715
export const NAVIGATION_CATEGORY = 'Discovery Navigation';
7816

79-
// Install Types
80-
export const INSTALL_STATE = 'INSTALL_STATE';
81-
export const START_DOWNLOAD = 'START_DOWNLOAD';
82-
export const DOWNLOAD_PROGRESS = 'DOWNLOAD_PROGRESS';
83-
export const INSTALL_COMPLETE = 'INSTALL_COMPLETE';
84-
export const UNINSTALL_COMPLETE = 'UNINSTALL_COMPLETE';
85-
export const INSTALL_ERROR = 'INSTALL_ERROR';
86-
87-
export const acceptedInstallTypes = [
88-
INSTALL_STATE,
89-
START_DOWNLOAD,
90-
DOWNLOAD_PROGRESS,
91-
INSTALL_COMPLETE,
92-
UNINSTALL_COMPLETE,
93-
INSTALL_ERROR,
94-
];
95-
9617
export const globalEventStatusMap = {
9718
onDisabled: DISABLED,
9819
onEnabled: ENABLED,

src/disco/containers/DiscoPane.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { discoResults } from 'disco/actions';
1111
import { loadEntities } from 'core/actions';
1212
import { addChangeListeners } from 'disco/addonManager';
1313
import {
14-
INSTALL_STATE,
1514
NAVIGATION_CATEGORY,
1615
VIDEO_CATEGORY,
1716
} from 'disco/constants';
17+
import { INSTALL_STATE } from 'core/constants';
1818

1919
import Addon from 'disco/components/Addon';
2020
import InfoDialog from 'disco/components/InfoDialog';

src/disco/reducers/installations.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
UNINSTALLED,
1111
UNINSTALL_COMPLETE,
1212
acceptedInstallTypes,
13-
} from 'disco/constants';
13+
} from 'core/constants';
1414

1515

1616
export default function installations(state = {}, { type, payload }) {

src/disco/themePreview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { validThemeActions } from 'disco/constants';
1+
import { validThemeActions } from 'core/constants';
22

33
export default function themeAction(node, action, _doc = document) {
44
if (!validThemeActions.includes(action)) {

tests/client/amo/components/TestAddonDetail.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import AddonDetail, { allowedDescriptionTags }
99
from 'amo/components/AddonDetail';
1010
import I18nProvider from 'core/i18n/Provider';
11-
import InstallButton from 'disco/components/InstallButton';
11+
import InstallButton from 'core/components/InstallButton';
1212

1313
import { getFakeI18nInst } from 'tests/client/helpers';
1414

tests/client/disco/components/TestInstallButton.js renamed to tests/client/core/components/TestInstallButton.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { findDOMNode } from 'react-dom';
44

55
import {
66
InstallButton,
7-
} from 'disco/components/InstallButton';
7+
} from 'core/components/InstallButton';
88
import {
99
DISABLED,
1010
DISABLING,
@@ -17,7 +17,7 @@ import {
1717
UNINSTALLED,
1818
UNINSTALLING,
1919
UNKNOWN,
20-
} from 'disco/constants';
20+
} from 'core/constants';
2121
import { getFakeI18nInst } from 'tests/client/helpers';
2222

2323

tests/client/core/reducers/test_addons.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import addons from 'core/reducers/addons';
2-
import { API_THEME_TYPE, THEME_TYPE } from 'disco/constants';
2+
import { API_THEME_TYPE, THEME_TYPE } from 'core/constants';
33

44
describe('addon reducer', () => {
55
let originalState;

tests/client/disco/TestAddonManager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as addonManager from 'disco/addonManager';
22
import { unexpectedSuccess } from 'tests/client/helpers';
3+
import { installEventList } from 'core/constants';
34
import {
45
globalEventStatusMap,
5-
installEventList,
66
SET_ENABLE_NOT_AVAILABLE,
77
} from 'disco/constants';
88

tests/client/disco/TestThemePreview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import themeAction from 'disco/themePreview';
2-
import { THEME_PREVIEW } from 'disco/constants';
2+
import { THEME_PREVIEW } from 'core/constants';
33

44

55
describe('Theme Preview Lib', () => {

tests/client/disco/components/TestAddon.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
mapStateToProps,
1414
} from 'disco/components/Addon';
1515
import {
16-
CLOSE_INFO,
1716
DISABLED,
1817
DOWNLOAD_FAILED,
1918
DOWNLOAD_PROGRESS,
@@ -24,18 +23,21 @@ import {
2423
FATAL_INSTALL_ERROR,
2524
FATAL_UNINSTALL_ERROR,
2625
INSTALLED,
27-
INSTALL_CATEGORY,
2826
INSTALL_FAILED,
2927
INSTALL_STATE,
30-
SET_ENABLE_NOT_AVAILABLE,
31-
SHOW_INFO,
3228
START_DOWNLOAD,
3329
THEME_INSTALL,
3430
THEME_PREVIEW,
3531
THEME_RESET_PREVIEW,
3632
THEME_TYPE,
3733
UNINSTALLED,
3834
UNINSTALLING,
35+
} from 'core/constants';
36+
import {
37+
CLOSE_INFO,
38+
INSTALL_CATEGORY,
39+
SET_ENABLE_NOT_AVAILABLE,
40+
SHOW_INFO,
3941
UNINSTALL_CATEGORY,
4042
} from 'disco/constants';
4143
import { getFakeAddonManagerWrapper, getFakeI18nInst } from 'tests/client/helpers';

tests/client/disco/containers/TestDiscoPane.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import createStore from 'disco/store';
88
import {
99
EXTENSION_TYPE,
1010
INSTALL_STATE,
11+
} from 'core/constants';
12+
import {
1113
NAVIGATION_CATEGORY,
1214
VIDEO_CATEGORY,
1315
globalEvents,

0 commit comments

Comments
 (0)