Skip to content

Commit 4194dc0

Browse files
eviljeffKevinMind
andauthored
Make more information card multi-column; include add to collection input (#13665)
* Make more information card multi-column; include add to collection input * rework components to not return Definition to make Flow happy * change implementation to hide empty dt/dd with css instead * revert reworking and css implemention; relax typing on DefintionList intead * circular reference fix * Fix type issue by moving state to the AddonMoreInfo component. (#13677) Follow the pattern for other more info links where we define the content in listContent and pass it to renderDefinitionList and conditionally render the expected <Definition> element only if the content is truthy --------- Co-authored-by: Kevin Meinhardt <[email protected]>
1 parent f49c7c4 commit 4194dc0

File tree

7 files changed

+138
-181
lines changed

7 files changed

+138
-181
lines changed

src/amo/components/AddAddonToCollection/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { getCurrentUser } from 'amo/reducers/users';
1515
import { withFixedErrorHandler } from 'amo/errorHandler';
1616
import translate from 'amo/i18n/translate';
1717
import log from 'amo/logger';
18-
import Card from 'amo/components/Card';
1918
import Select from 'amo/components/Select';
2019
import Notice from 'amo/components/Notice';
2120
import type { CollectionType } from 'amo/reducers/collections';
@@ -269,10 +268,7 @@ export class AddAddonToCollectionBase extends React.Component<InternalProps> {
269268
const collectionOptLabel = i18n.gettext('Add to…');
270269

271270
return (
272-
<Card
273-
className="AddAddonToCollection"
274-
header={i18n.gettext('Add to collection')}
275-
>
271+
<>
276272
{errorHandler.renderErrorIfPresent()}
277273
{addedNotices}
278274
<Select
@@ -285,7 +281,7 @@ export class AddAddonToCollectionBase extends React.Component<InternalProps> {
285281
<optgroup label={collectionOptLabel}>{collectionOptions}</optgroup>
286282
) : null}
287283
</Select>
288-
</Card>
284+
</>
289285
);
290286
}
291287
}
Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,14 @@
11
/* @flow */
22
import * as React from 'react';
3-
import { connect } from 'react-redux';
43
import { compose } from 'redux';
54

6-
import {
7-
ADDONS_CONTENT_REVIEW,
8-
ADDONS_EDIT,
9-
ADDONS_REVIEW,
10-
ADDON_TYPE_STATIC_THEME,
11-
REVIEWER_TOOLS_VIEW,
12-
STATIC_THEMES_REVIEW,
13-
} from 'amo/constants';
5+
import { ADDON_TYPE_STATIC_THEME } from 'amo/constants';
146
import translate from 'amo/i18n/translate';
15-
import { hasPermission } from 'amo/reducers/users';
167
import type { AddonType } from 'amo/types/addons';
17-
import DefinitionList, { Definition } from 'amo/components/DefinitionList';
188
import type { I18nType } from 'amo/types/i18n';
19-
import type { AppState } from 'amo/store';
209

2110
type Props = {|
22-
addon: AddonType | null,
23-
|};
24-
25-
type PropsFromState = {|
11+
addon: AddonType,
2612
hasCodeReviewPermission: boolean,
2713
hasContentReviewPermission: boolean,
2814
hasEditPermission: boolean,
@@ -31,12 +17,11 @@ type PropsFromState = {|
3117

3218
type InternalProps = {|
3319
...Props,
34-
...PropsFromState,
3520
i18n: I18nType,
3621
|};
3722

3823
export class AddonAdminLinksBase extends React.Component<InternalProps> {
39-
render(): null | React.Node {
24+
render(): React.Node {
4025
const {
4126
addon,
4227
hasCodeReviewPermission,
@@ -46,24 +31,11 @@ export class AddonAdminLinksBase extends React.Component<InternalProps> {
4631
i18n,
4732
} = this.props;
4833

49-
if (addon === null) {
50-
return null;
51-
}
52-
5334
const isTheme = addon.type === ADDON_TYPE_STATIC_THEME;
5435

5536
const showCodeReviewLink = hasCodeReviewPermission && !isTheme;
5637
const showStaticThemeReviewLink = hasStaticThemeReviewPermission && isTheme;
5738
const showContentReviewLink = hasContentReviewPermission && !isTheme;
58-
const hasALink =
59-
hasEditPermission ||
60-
showContentReviewLink ||
61-
showCodeReviewLink ||
62-
showStaticThemeReviewLink;
63-
64-
if (!hasALink) {
65-
return null;
66-
}
6739

6840
const editLink = hasEditPermission ? (
6941
<li>
@@ -128,39 +100,18 @@ export class AddonAdminLinksBase extends React.Component<InternalProps> {
128100
) : null;
129101

130102
return (
131-
<DefinitionList className="AddonAdminLinks">
132-
<Definition
133-
term={
134-
// L10n: This is a list of links to administrative functions.
135-
i18n.gettext('Admin Links')
136-
}
137-
>
138-
<ul className="AddonAdminLinks-list">
139-
{editLink}
140-
{adminLink}
141-
{contentReviewLink}
142-
{codeReviewLink}
143-
</ul>
144-
</Definition>
145-
</DefinitionList>
103+
<ul className="AddonAdminLinks-list">
104+
{editLink}
105+
{adminLink}
106+
{contentReviewLink}
107+
{codeReviewLink}
108+
</ul>
146109
);
147110
}
148111
}
149112

150-
const mapStateToProps = (state: AppState): PropsFromState => {
151-
return {
152-
hasCodeReviewPermission:
153-
hasPermission(state, ADDONS_REVIEW) ||
154-
hasPermission(state, REVIEWER_TOOLS_VIEW),
155-
hasContentReviewPermission: hasPermission(state, ADDONS_CONTENT_REVIEW),
156-
hasEditPermission: hasPermission(state, ADDONS_EDIT),
157-
hasStaticThemeReviewPermission: hasPermission(state, STATIC_THEMES_REVIEW),
158-
};
159-
};
160-
161-
const AddonAdminLinks: React.ComponentType<Props> = compose(
162-
connect(mapStateToProps),
163-
translate(),
164-
)(AddonAdminLinksBase);
113+
const AddonAdminLinks: React.ComponentType<Props> = compose(translate())(
114+
AddonAdminLinksBase,
115+
);
165116

166117
export default AddonAdminLinks;

src/amo/components/AddonAuthorLinks/index.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)