Skip to content

Commit

Permalink
Merge branch 'master' into chore/vuln-deps-json-viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
david-shibley-contentful authored Sep 26, 2024
2 parents b239570 + 432dd2a commit 0fb2acf
Show file tree
Hide file tree
Showing 17 changed files with 3,988 additions and 21,103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
22,422 changes: 3,668 additions & 18,754 deletions apps/smartling/frontend/package-lock.json

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions apps/smartling/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"@testing-library/react": "8.0.4",
"@types/jest": "24.0.15",
"@types/lodash.get": "^4.4.6",
"@types/node": "^20.0.0",
"@types/react": "^16.8.17",
"@types/react-dom": "^16.8.4",
"@types/webpack-env": "1.18.5",
Expand All @@ -18,23 +19,27 @@
"whatwg-fetch": "^3.0.0"
},
"scripts": {
"start": "cross-env BROWSER=none react-scripts --openssl-legacy-provider start",
"build": "react-scripts --openssl-legacy-provider build",
"test": "TZ=UTC react-scripts test",
"test:ci": "CI=true react-scripts test",
"test:dev": "TZ=UTC react-scripts test"
"start": "vite",
"build": "vite build",
"test": "vitest",
"test:ci": "vitest",
"test:dev": "TZ=UTC vitest"
},
"dependencies": {
"@contentful/app-sdk": "4.23.0",
"@contentful/forma-36-fcss": "^0.3.5",
"@contentful/forma-36-react-components": "^3.100.7",
"@contentful/forma-36-tokens": "^0.11.2",
"@contentful/f36-components": "^4.70.0",
"@contentful/f36-icons": "^4.29.0",
"@contentful/f36-tokens": "^4.0.5",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/coverage-v8": "^2.1.1",
"contentful-management": "10.31.4",
"happy-dom": "^15.7.4",
"lodash.get": "^4.4.2",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "^5.0.1"
"vite": "^5.4.8",
"vitest": "^2.1.1"
},
"private": true,
"eslintConfig": {
Expand Down
78 changes: 41 additions & 37 deletions apps/smartling/frontend/src/AppConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { AppExtensionSDK } from '@contentful/app-sdk';
import {
Heading,
Paragraph,
Typography,
FieldGroup,
CheckboxField,
TextField,
TextLink,
Note,
} from '@contentful/forma-36-react-components';
Flex,
FormControl,
TextInput,
Checkbox,
} from '@contentful/f36-components';
import get from 'lodash.get';
// @ts-ignore 2307
import logo from './logo.svg';
Expand Down Expand Up @@ -117,7 +117,7 @@ export default class AppConfig extends React.Component<Props, State> {
<div className="body">
<div className="config">
<div className="section">
<Typography>
<>
<Heading>About Smartling</Heading>
<Paragraph className="about-p">
The{' '}
Expand All @@ -129,34 +129,37 @@ export default class AppConfig extends React.Component<Props, State> {
</TextLink>{' '}
app allows you to view the status of your translation without leaving Contentful.
</Paragraph>
</Typography>
</>
<hr />
</div>
<div className="section">
<Typography>
<>
<Heading>Configuration</Heading>
</Typography>
<TextField
required
testId="projectId"
name="projectId"
id="projectId"
className="project-id"
labelText="Smartling project ID"
value={this.state.projectId}
// @ts-ignore 2339
onChange={(e) => this.setProjectId(e.target.value)}
helpText="To get the project ID, see the 'Project Settings > API' of your Smartling project."
/>
<Typography>
</>
<FormControl>
<FormControl.Label>Smartling project ID</FormControl.Label>
<TextInput
isRequired
testId="projectId"
name="projectId"
id="projectId"
className="project-id"
value={this.state.projectId}
onChange={(e) => this.setProjectId(e.target.value)}
/>
<FormControl.HelpText>
To get the project ID, see the 'Project Settings API' of your Smartling project.
</FormControl.HelpText>
</FormControl>
<>
<Heading>Assign to content types</Heading>
<Paragraph>Select which content types to use with Smartling.</Paragraph>
</Typography>
</>
{this.state.contentTypes.length === 0 ? (
<Note noteType="warning">
<Note variant="warning">
There are <strong>no content types</strong> in this environment. You can add one{' '}
<TextLink
linkType="primary"
variant="primary"
target="_blank"
rel="noopener noreferrer"
href={
Expand All @@ -169,20 +172,21 @@ export default class AppConfig extends React.Component<Props, State> {
and assign it to the app from this screen.
</Note>
) : (
<FieldGroup>
<Flex>
{this.state.contentTypes.map((ct) => (
<CheckboxField
onChange={() => this.toggleCt(ct.id)}
labelText={ct.name}
name={ct.name}
checked={this.state.selectedContentTypes.includes(ct.id)}
value={ct.id}
id={ct.name}
key={ct.id}
data-test-id={`ct-item-${ct.id}`}
/>
<FormControl key={ct.id}>
<FormControl.Label>{ct.name}</FormControl.Label>
<Checkbox
onChange={() => this.toggleCt(ct.id)}
name={ct.name}
isChecked={this.state.selectedContentTypes.includes(ct.id)}
value={ct.id}
id={ct.name}
data-test-id={`ct-item-${ct.id}`}
/>
</FormControl>
))}
</FieldGroup>
</Flex>
)}
</div>
</div>
Expand Down
31 changes: 16 additions & 15 deletions apps/smartling/frontend/src/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Icon,
Button,
Paragraph,
Tag,
Badge,
Card,
Tooltip,
TextLink,
Expand All @@ -13,8 +13,9 @@ import {
Spinner,
Note,
Flex,
} from '@contentful/forma-36-react-components';
} from '@contentful/f36-components';
import smartlingClient from './smartlingClient';
import { ExternalLinkIcon, InfoCircleIcon } from '@contentful/f36-icons';

interface Props {
sdk: SidebarExtensionSDK;
Expand Down Expand Up @@ -249,11 +250,11 @@ export default class Sidebar extends React.Component<Props, State> {
const requestButton = (
<Button
testId="request-translation"
buttonType="muted"
variant="secondary"
isFullWidth
className="request-translation"
onClick={() => window.open(smartlingLink)}>
<Icon icon="ExternalLink" color="secondary" /> Request Translation
<ExternalLinkIcon variant="secondary" /> Request Translation
</Button>
);

Expand All @@ -262,7 +263,7 @@ export default class Sidebar extends React.Component<Props, State> {
<>
<Button
testId="open-dialog"
buttonType="primary"
variant="primary"
isFullWidth
className="signin"
onClick={() => this.runAuthFlow()}>
Expand Down Expand Up @@ -295,14 +296,14 @@ export default class Sidebar extends React.Component<Props, State> {

statusTag = (
<Flex justifyContent="start" alignItems="bottom">
<Tag className="job-status" tagType={getStatusColor(smartlingEntry.assetStatus)}>
<Badge className="job-status" variant={getStatusColor(smartlingEntry.assetStatus)}>
{smartlingEntry.assetStatus}
</Tag>
</Badge>
<Tooltip
place="top"
placement="top"
targetWrapperClassName="tooltip"
content={submissionStatusLongText(smartlingEntry.assetStatus)}>
<Icon icon="InfoCircle" />
<InfoCircleIcon />
</Tooltip>
</Flex>
);
Expand All @@ -328,9 +329,9 @@ export default class Sidebar extends React.Component<Props, State> {
)}
</div>
<div className="status">
<Tag className="tag" tagType={getStatusColor(sub.status)}>
<Badge className="tag" variant={getStatusColor(sub.status)}>
{formatSubmissionStatus(sub.status)}
</Tag>
</Badge>
<br />
{showSubmittedByStatus(sub.status) && (
<div className="date">Submitted {formatDate(sub.submitted)}</div>
Expand All @@ -352,13 +353,13 @@ export default class Sidebar extends React.Component<Props, State> {
}
} else if (generalError) {
statusTag = (
<Tag className="job-status" tagType="negative">
<Badge className="job-status" variant="negative">
Disconnected
</Tag>
</Badge>
);

smartlingBody = (
<Note title="Connection error" noteType="negative" className="general-error">
<Note title="Connection error" variant="negative" className="general-error">
Please ensure that you have access to the connected Smartling project.
<br />
<TextLink
Expand Down Expand Up @@ -387,7 +388,7 @@ export default class Sidebar extends React.Component<Props, State> {
target="_blank"
rel="noopener">
Learn how Smartling works with Contentful&nbsp;
<Icon size="tiny" icon="ExternalLink" color="secondary" />
<ExternalLinkIcon size="tiny" variant="secondary" />
</TextLink>
</Paragraph>
</>
Expand Down
Loading

0 comments on commit 0fb2acf

Please sign in to comment.