</div>
<Header />
<EditionBoxes
+ canInstall={standaloneMode && !this.props.editionsReadOnly}
+ canUninstall={standaloneMode}
editions={editions}
loading={this.props.loadingEditions}
editionStatus={editionStatus}
- readOnly={!standaloneMode || this.props.editionsReadOnly}
updateCenterActive={this.props.updateCenterActive}
updateEditionStatus={this.props.setEditionStatus}
/>
import { translate } from '../../helpers/l10n';
export interface Props {
+ canInstall: boolean;
+ canUninstall: boolean;
editions?: Edition[];
editionStatus?: EditionStatus;
loading: boolean;
- readOnly: boolean;
updateCenterActive: boolean;
updateEditionStatus: (editionStatus: EditionStatus) => void;
}
handleCloseUninstallForm = () => this.setState({ openUninstallForm: false });
render() {
- const { editions, editionStatus, loading, readOnly } = this.props;
+ const { canInstall, canUninstall, editions, editionStatus, loading } = this.props;
const { installEdition, openUninstallForm } = this.state;
if (loading) {
return <i className="big-spacer-bottom spinner" />;
<div className="spacer-bottom marketplace-editions">
{editions.map(edition => (
<EditionBox
+ canInstall={canInstall}
+ canUninstall={canUninstall}
edition={edition}
editionStatus={editionStatus}
key={edition.key}
onInstall={this.handleOpenLicenseForm}
onUninstall={this.handleOpenUninstallForm}
- readOnly={readOnly}
/>
))}
- {!readOnly &&
+ {canInstall &&
installEdition && (
<LicenseEditionForm
edition={installEdition}
/>
)}
- {!readOnly &&
+ {canUninstall &&
openUninstallForm &&
editionStatus &&
editionStatus.currentEditionKey && (
function getWrapper(props = {}) {
return shallow(
<EditionBoxes
+ canInstall={true}
+ canUninstall={true}
loading={false}
editionStatus={DEFAULT_STATUS}
- readOnly={false}
updateCenterActive={true}
updateEditionStatus={jest.fn()}
{...props}
className="spacer-bottom marketplace-editions"
>
<EditionBox
+ canInstall={true}
+ canUninstall={true}
edition={
Object {
"downloadUrl": "download_url",
}
onInstall={[Function]}
onUninstall={[Function]}
- readOnly={false}
/>
<EditionBox
+ canInstall={true}
+ canUninstall={true}
edition={
Object {
"downloadUrl": "download_url",
}
onInstall={[Function]}
onUninstall={[Function]}
- readOnly={false}
/>
</div>
`;
import { translate } from '../../../helpers/l10n';
interface Props {
+ canInstall: boolean;
+ canUninstall: boolean;
edition: Edition;
editionStatus?: EditionStatus;
onInstall: (edition: Edition) => void;
onUninstall: () => void;
- readOnly: boolean;
}
export default class EditionBox extends React.PureComponent<Props> {
}
render() {
- const { edition, editionStatus, readOnly } = this.props;
+ const { canInstall, canUninstall, edition, editionStatus } = this.props;
const isInstalled = editionStatus && editionStatus.currentEditionKey === edition.key;
const uninstallInProgress =
editionStatus && editionStatus.installationStatus === 'UNINSTALL_IN_PROGRESS';
<a href={edition.homeUrl} target="_blank">
{translate('marketplace.learn_more')}
</a>
- {!readOnly &&
- (isInstalled ? (
- <button
- className="button-red"
- disabled={installInProgress || uninstallInProgress}
- onClick={this.props.onUninstall}>
- {translate('marketplace.uninstall')}
- </button>
- ) : (
- <button
- disabled={installInProgress || uninstallInProgress}
- onClick={this.handleInstall}>
- {translate('marketplace.install')}
- </button>
- ))}
+ {canUninstall &&
+ isInstalled && (
+ <button
+ className="button-red"
+ disabled={installInProgress || uninstallInProgress}
+ onClick={this.props.onUninstall}>
+ {translate('marketplace.uninstall')}
+ </button>
+ )}
+ {canInstall &&
+ !isInstalled && (
+ <button
+ disabled={installInProgress || uninstallInProgress}
+ onClick={this.handleInstall}>
+ {translate('marketplace.install')}
+ </button>
+ )}
</div>
</div>
);
function getWrapper(props = {}) {
return shallow(
<EditionBox
+ canInstall={true}
+ canUninstall={true}
edition={DEFAULT_EDITION}
editionStatus={DEFAULT_STATUS}
onInstall={jest.fn()}
onUninstall={jest.fn()}
- readOnly={false}
{...props}
/>
);