Skip to content

Commit

Permalink
Move InstallButton into core (#930)
Browse files Browse the repository at this point in the history
* Move InstallButton into core

* remove unused types
  • Loading branch information
kumar303 committed Aug 18, 2016
1 parent 027fd13 commit 087f2d2
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/amo/components/AddonDetail.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PropTypes } from 'react';

import AddonMeta from 'amo/components/AddonMeta';
import InstallButton from 'disco/components/InstallButton';
import InstallButton from 'core/components/InstallButton';
import LikeButton from 'amo/components/LikeButton';
import ScreenShots from 'amo/components/ScreenShots';
import SearchBox from 'amo/components/SearchBox';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ $installStripeColor2: #00c42e;
&.enabled,
&.installed {
input + label::before {
background: $switchBackgroundOn url('../img/tick.svg') no-repeat 35% 50%;
background: $switchBackgroundOn url('./img/tick.svg') no-repeat 35% 50%;

[dir=rtl] & {
background-position: 65% 50%;
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
UNKNOWN,
validAddonTypes,
validInstallStates as validStates,
} from 'disco/constants';
} from 'core/constants';
import { getThemeData } from 'disco/themePreview';

import 'disco/css/InstallButton.scss';
import './InstallButton.scss';

export class InstallButton extends React.Component {
static propTypes = {
Expand Down
84 changes: 84 additions & 0 deletions src/core/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Addon States.
export const DISABLED = 'DISABLED';
export const DISABLING = 'DISABLING';
export const DOWNLOADING = 'DOWNLOADING';
export const ENABLED = 'ENABLED';
export const ENABLING = 'ENABLING';
export const ERROR = 'ERROR';
export const INSTALLED = 'INSTALLED';
export const INSTALLING = 'INSTALLING';
export const UNINSTALLED = 'UNINSTALLED';
export const UNINSTALLING = 'UNINSTALLING';
export const UNKNOWN = 'UNKNOWN';
export const validInstallStates = [
DISABLED,
DISABLING,
ENABLED,
ENABLING,
DOWNLOADING,
ENABLED,
ERROR,
INSTALLED,
INSTALLING,
UNINSTALLED,
UNINSTALLING,
UNKNOWN,
];

// Add-on error states.
export const DOWNLOAD_FAILED = 'DOWNLOAD_FAILED';
export const INSTALL_FAILED = 'INSTALL_FAILED';

// Unrecoverable errors.
export const FATAL_INSTALL_ERROR = 'FATAL_INSTALL_ERROR';
export const FATAL_UNINSTALL_ERROR = 'FATAL_UNINSTALL_ERROR';
export const FATAL_ERROR = 'FATAL_ERROR';

// Add-on types.
export const API_THEME_TYPE = 'persona';
export const EXTENSION_TYPE = 'extension';
export const THEME_TYPE = 'theme';
export const validAddonTypes = [
EXTENSION_TYPE,
THEME_TYPE,
];

// Theme preview actions.
export const THEME_INSTALL = 'InstallBrowserTheme';
export const THEME_PREVIEW = 'PreviewBrowserTheme';
export const THEME_RESET_PREVIEW = 'ResetBrowserThemePreview';
export const validThemeActions = [
THEME_INSTALL,
THEME_PREVIEW,
THEME_RESET_PREVIEW,
];

export const installEventList = [
'onDownloadStarted',
'onDownloadProgress',
'onDownloadEnded',
'onDownloadCancelled',
'onDownloadFailed',
'onInstallStarted',
'onInstallProgress',
'onInstallEnded',
'onInstallCancelled',
'onInstallFailed',
];

// Install Types
export const INSTALL_STATE = 'INSTALL_STATE';
export const START_DOWNLOAD = 'START_DOWNLOAD';
export const DOWNLOAD_PROGRESS = 'DOWNLOAD_PROGRESS';
export const INSTALL_COMPLETE = 'INSTALL_COMPLETE';
export const UNINSTALL_COMPLETE = 'UNINSTALL_COMPLETE';
export const INSTALL_ERROR = 'INSTALL_ERROR';

export const acceptedInstallTypes = [
INSTALL_STATE,
START_DOWNLOAD,
DOWNLOAD_PROGRESS,
INSTALL_COMPLETE,
UNINSTALL_COMPLETE,
INSTALL_ERROR,
];
2 changes: 1 addition & 1 deletion src/core/reducers/addons.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API_THEME_TYPE, THEME_TYPE } from 'disco/constants';
import { API_THEME_TYPE, THEME_TYPE } from 'core/constants';

const initialState = {};

Expand Down
4 changes: 3 additions & 1 deletion src/disco/addonManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import log from 'core/logger';
import {
globalEvents,
globalEventStatusMap,
installEventList,
SET_ENABLE_NOT_AVAILABLE,
} from 'disco/constants';
import {
installEventList,
} from 'core/constants';


export function getAddon(guid, { _mozAddonManager = window.navigator.mozAddonManager } = {}) {
Expand Down
14 changes: 8 additions & 6 deletions src/disco/components/Addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import tracking from 'core/tracking';
import * as addonManager from 'disco/addonManager';
import log from 'core/logger';

import InstallButton from 'disco/components/InstallButton';
import InstallButton from 'core/components/InstallButton';
import {
CLOSE_INFO,
DISABLED,
DOWNLOAD_FAILED,
DOWNLOAD_PROGRESS,
Expand All @@ -24,22 +23,25 @@ import {
FATAL_ERROR,
FATAL_INSTALL_ERROR,
FATAL_UNINSTALL_ERROR,
INSTALL_CATEGORY,
INSTALL_ERROR,
INSTALL_FAILED,
INSTALL_STATE,
SET_ENABLE_NOT_AVAILABLE,
SHOW_INFO,
START_DOWNLOAD,
THEME_INSTALL,
THEME_PREVIEW,
THEME_RESET_PREVIEW,
THEME_TYPE,
UNINSTALLED,
UNINSTALLING,
UNINSTALL_CATEGORY,
validAddonTypes,
validInstallStates,
} from 'core/constants';
import {
CLOSE_INFO,
INSTALL_CATEGORY,
SET_ENABLE_NOT_AVAILABLE,
SHOW_INFO,
UNINSTALL_CATEGORY,
} from 'disco/constants';

import 'disco/css/Addon.scss';
Expand Down
83 changes: 2 additions & 81 deletions src/disco/constants.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,19 @@
// Addon States.
export const DISABLED = 'DISABLED';
export const DISABLING = 'DISABLING';
export const DOWNLOADING = 'DOWNLOADING';
export const ENABLED = 'ENABLED';
export const ENABLING = 'ENABLING';
export const ERROR = 'ERROR';
export const INSTALLED = 'INSTALLED';
export const INSTALLING = 'INSTALLING';
export const UNINSTALLED = 'UNINSTALLED';
export const UNINSTALLING = 'UNINSTALLING';
export const UNKNOWN = 'UNKNOWN';
export const validInstallStates = [
import {
DISABLED,
DISABLING,
ENABLED,
ENABLING,
DOWNLOADING,
ENABLED,
ERROR,
INSTALLED,
INSTALLING,
UNINSTALLED,
UNINSTALLING,
UNKNOWN,
];

// Add-on error states.
export const DOWNLOAD_FAILED = 'DOWNLOAD_FAILED';
export const INSTALL_FAILED = 'INSTALL_FAILED';

// Unrecoverable errors.
export const FATAL_INSTALL_ERROR = 'FATAL_INSTALL_ERROR';
export const FATAL_UNINSTALL_ERROR = 'FATAL_UNINSTALL_ERROR';
export const FATAL_ERROR = 'FATAL_ERROR';

// Add-on types.
export const API_THEME_TYPE = 'persona';
export const EXTENSION_TYPE = 'extension';
export const THEME_TYPE = 'theme';
// These types are not used.
// export const DICT_TYPE = 'dictionary';
// export const SEARCH_TYPE = 'search';
// export const LPAPP_TYPE = 'language';
// export const PERSONA_TYPE = 'persona';
export const validAddonTypes = [
EXTENSION_TYPE,
THEME_TYPE,
];

// Theme preview actions.
export const THEME_INSTALL = 'InstallBrowserTheme';
export const THEME_PREVIEW = 'PreviewBrowserTheme';
export const THEME_RESET_PREVIEW = 'ResetBrowserThemePreview';
export const validThemeActions = [
THEME_INSTALL,
THEME_PREVIEW,
THEME_RESET_PREVIEW,
];

export const installEventList = [
'onDownloadStarted',
'onDownloadProgress',
'onDownloadEnded',
'onDownloadCancelled',
'onDownloadFailed',
'onInstallStarted',
'onInstallProgress',
'onInstallEnded',
'onInstallCancelled',
'onInstallFailed',
];
} from 'core/constants';

export const INSTALL_CATEGORY = 'AMO Addon / Theme Installs';
export const UNINSTALL_CATEGORY = 'AMO Addon / Theme Uninstalls';
export const VIDEO_CATEGORY = 'Discovery Video';
export const NAVIGATION_CATEGORY = 'Discovery Navigation';

// Install Types
export const INSTALL_STATE = 'INSTALL_STATE';
export const START_DOWNLOAD = 'START_DOWNLOAD';
export const DOWNLOAD_PROGRESS = 'DOWNLOAD_PROGRESS';
export const INSTALL_COMPLETE = 'INSTALL_COMPLETE';
export const UNINSTALL_COMPLETE = 'UNINSTALL_COMPLETE';
export const INSTALL_ERROR = 'INSTALL_ERROR';

export const acceptedInstallTypes = [
INSTALL_STATE,
START_DOWNLOAD,
DOWNLOAD_PROGRESS,
INSTALL_COMPLETE,
UNINSTALL_COMPLETE,
INSTALL_ERROR,
];

export const globalEventStatusMap = {
onDisabled: DISABLED,
onEnabled: ENABLED,
Expand Down
2 changes: 1 addition & 1 deletion src/disco/containers/DiscoPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { discoResults } from 'disco/actions';
import { loadEntities } from 'core/actions';
import { addChangeListeners } from 'disco/addonManager';
import {
INSTALL_STATE,
NAVIGATION_CATEGORY,
VIDEO_CATEGORY,
} from 'disco/constants';
import { INSTALL_STATE } from 'core/constants';

import Addon from 'disco/components/Addon';
import InfoDialog from 'disco/components/InfoDialog';
Expand Down
2 changes: 1 addition & 1 deletion src/disco/reducers/installations.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
UNINSTALLED,
UNINSTALL_COMPLETE,
acceptedInstallTypes,
} from 'disco/constants';
} from 'core/constants';


export default function installations(state = {}, { type, payload }) {
Expand Down
2 changes: 1 addition & 1 deletion src/disco/themePreview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validThemeActions } from 'disco/constants';
import { validThemeActions } from 'core/constants';

export default function themeAction(node, action, _doc = document) {
if (!validThemeActions.includes(action)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/client/amo/components/TestAddonDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import AddonDetail, { allowedDescriptionTags }
from 'amo/components/AddonDetail';
import I18nProvider from 'core/i18n/Provider';
import InstallButton from 'disco/components/InstallButton';
import InstallButton from 'core/components/InstallButton';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { findDOMNode } from 'react-dom';

import {
InstallButton,
} from 'disco/components/InstallButton';
} from 'core/components/InstallButton';
import {
DISABLED,
DISABLING,
Expand All @@ -17,7 +17,7 @@ import {
UNINSTALLED,
UNINSTALLING,
UNKNOWN,
} from 'disco/constants';
} from 'core/constants';
import { getFakeI18nInst } from 'tests/client/helpers';


Expand Down
2 changes: 1 addition & 1 deletion tests/client/core/reducers/test_addons.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import addons from 'core/reducers/addons';
import { API_THEME_TYPE, THEME_TYPE } from 'disco/constants';
import { API_THEME_TYPE, THEME_TYPE } from 'core/constants';

describe('addon reducer', () => {
let originalState;
Expand Down
2 changes: 1 addition & 1 deletion tests/client/disco/TestAddonManager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as addonManager from 'disco/addonManager';
import { unexpectedSuccess } from 'tests/client/helpers';
import { installEventList } from 'core/constants';
import {
globalEventStatusMap,
installEventList,
SET_ENABLE_NOT_AVAILABLE,
} from 'disco/constants';

Expand Down
2 changes: 1 addition & 1 deletion tests/client/disco/TestThemePreview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import themeAction from 'disco/themePreview';
import { THEME_PREVIEW } from 'disco/constants';
import { THEME_PREVIEW } from 'core/constants';


describe('Theme Preview Lib', () => {
Expand Down
10 changes: 6 additions & 4 deletions tests/client/disco/components/TestAddon.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
mapStateToProps,
} from 'disco/components/Addon';
import {
CLOSE_INFO,
DISABLED,
DOWNLOAD_FAILED,
DOWNLOAD_PROGRESS,
Expand All @@ -24,18 +23,21 @@ import {
FATAL_INSTALL_ERROR,
FATAL_UNINSTALL_ERROR,
INSTALLED,
INSTALL_CATEGORY,
INSTALL_FAILED,
INSTALL_STATE,
SET_ENABLE_NOT_AVAILABLE,
SHOW_INFO,
START_DOWNLOAD,
THEME_INSTALL,
THEME_PREVIEW,
THEME_RESET_PREVIEW,
THEME_TYPE,
UNINSTALLED,
UNINSTALLING,
} from 'core/constants';
import {
CLOSE_INFO,
INSTALL_CATEGORY,
SET_ENABLE_NOT_AVAILABLE,
SHOW_INFO,
UNINSTALL_CATEGORY,
} from 'disco/constants';
import { getFakeAddonManagerWrapper, getFakeI18nInst } from 'tests/client/helpers';
Expand Down
2 changes: 2 additions & 0 deletions tests/client/disco/containers/TestDiscoPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import createStore from 'disco/store';
import {
EXTENSION_TYPE,
INSTALL_STATE,
} from 'core/constants';
import {
NAVIGATION_CATEGORY,
VIDEO_CATEGORY,
globalEvents,
Expand Down
Loading

0 comments on commit 087f2d2

Please sign in to comment.