-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from overture-stack/rc/0.6.0
🔖 Rc/0.6.0
- Loading branch information
Showing
9 changed files
with
403 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { css } from '@emotion/core'; | ||
import { Error } from './theme/icons'; | ||
|
||
const ErrorContainer = ({ children, title }: { children: React.ReactNode; title: string }) => ( | ||
<div | ||
css={css` | ||
display: flex; | ||
flex: 1; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
`} | ||
> | ||
<div | ||
css={(theme) => | ||
css` | ||
padding: 1rem 2rem; | ||
border: 1px solid ${theme.colors.error_2}; | ||
border-radius: 5px; | ||
${theme.shadow.default}; | ||
${theme.typography.subheading}; | ||
font-weight: normal; | ||
line-height: 26px; | ||
max-width: 600px; | ||
background-color: ${theme.colors.error_1}; | ||
color: ${theme.colors.accent_dark}; | ||
` | ||
} | ||
> | ||
<h2 | ||
css={css` | ||
display: flex; | ||
align-items: center; | ||
margin: 0.5rem 0 1rem; | ||
font-size: 24px; | ||
line-height: 38px; | ||
`} | ||
> | ||
<Error | ||
height={27} | ||
width={26} | ||
style={css` | ||
padding-right: 15px; | ||
`} | ||
/>{' '} | ||
{title} | ||
</h2> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
|
||
export default ErrorContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
import { ReactNode } from 'react'; | ||
import { css } from '@emotion/core'; | ||
|
||
import { Checkmark, Warning } from '../../theme/icons'; | ||
import theme from '../../theme/'; | ||
import StyledLink from '../../Link'; | ||
|
||
import { getConfig } from '../../../global/config'; | ||
import { Project } from './'; | ||
|
||
const ArrangerAdminUILink = () => { | ||
const { NEXT_PUBLIC_ARRANGER_API } = getConfig(); | ||
const splitApi: string[] = NEXT_PUBLIC_ARRANGER_API.split('//'); | ||
const adminUiUrl: string = [splitApi[0], '//ui.', splitApi[1]].join(''); | ||
return ( | ||
<StyledLink href={adminUiUrl} target="_blank"> | ||
Arranger Admin UI | ||
</StyledLink> | ||
); | ||
}; | ||
|
||
const ListItem = ({ | ||
Icon, | ||
value, | ||
fieldName, | ||
}: { | ||
Icon?: ReactNode; | ||
value: string; | ||
fieldName: string; | ||
}) => ( | ||
<li | ||
css={(theme) => | ||
css` | ||
display: flex; | ||
align-items: center; | ||
${value === 'Missing' && | ||
css` | ||
color: ${theme.colors.error_dark}; | ||
`} | ||
` | ||
} | ||
> | ||
{Icon || <Checkmark height={16} width={16} fill={theme.colors.primary} />} | ||
<span | ||
css={css` | ||
padding-left: 6px; | ||
`} | ||
> | ||
{fieldName}:{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
{value} | ||
</span> | ||
</span> | ||
</li> | ||
); | ||
|
||
const WarningListItem = ({ fieldName }: { fieldName: string }) => ( | ||
<ListItem Icon={<Warning height={16} width={16} />} fieldName={fieldName} value={'Missing'} /> | ||
); | ||
|
||
const getConfigError = ({ | ||
availableProjects, | ||
projectId, | ||
index, | ||
graphqlField, | ||
}: { | ||
availableProjects: Project[]; | ||
projectId: string; | ||
index: string; | ||
graphqlField: string; | ||
}) => { | ||
if (!(projectId && index && graphqlField)) { | ||
return ( | ||
<span> | ||
One or more of the following values required by the DMS portal do not exist. Please make | ||
sure the values are specified in the DMS{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
config.yaml | ||
</span>{' '} | ||
file during installation and have been used to create your project in the{' '} | ||
<ArrangerAdminUILink />. | ||
<ul | ||
css={css` | ||
list-style-type: none; | ||
padding-left: 0px; | ||
`} | ||
> | ||
{[ | ||
{ field: 'Project ID', value: projectId }, | ||
{ field: 'Alias name', value: graphqlField }, | ||
{ field: 'Elasticsearch index', value: index }, | ||
].map(({ field, value }) => { | ||
return value ? ( | ||
<ListItem key={`${field}-${value}`} fieldName={field} value={value} /> | ||
) : ( | ||
<WarningListItem key={`${field}-${value}`} fieldName={field} /> | ||
); | ||
})} | ||
</ul> | ||
</span> | ||
); | ||
} | ||
|
||
if (!availableProjects.filter((project) => project.active).length) { | ||
return ( | ||
<span> | ||
No active projects for the DMS portal exist. Please make sure the project specified in the | ||
DMS{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
config.yaml | ||
</span>{' '} | ||
file during installation has been created in the <ArrangerAdminUILink />. | ||
</span> | ||
); | ||
} | ||
|
||
const foundProject = | ||
availableProjects.length && availableProjects.find((project) => project.id === projectId); | ||
|
||
if (!foundProject) { | ||
return ( | ||
<span> | ||
The project ID:{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
"{projectId}" | ||
</span>{' '} | ||
configured for the DMS portal does not match any existing project. Please make sure the | ||
project ID specified in the DMS{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
config.yaml | ||
</span>{' '} | ||
file during installation has been created in the <ArrangerAdminUILink />. | ||
</span> | ||
); | ||
} | ||
|
||
const aliasFromList = foundProject.indices.find((i) => i.id.match(projectId))?.graphqlField; | ||
const matchesConfiguredAlias = graphqlField === aliasFromList; | ||
|
||
if (!matchesConfiguredAlias) { | ||
return ( | ||
<div> | ||
The Elasticsearch alias name (graphQL field):{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
"{aliasFromList}" | ||
</span>{' '} | ||
required by the DMS portal for project ID:{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
"{projectId}" | ||
</span>{' '} | ||
does not match your configured alias name:{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
"{graphqlField}" | ||
</span> | ||
. Please make sure the value specified in the DMS{' '} | ||
<span | ||
css={css` | ||
font-weight: bold; | ||
`} | ||
> | ||
config.yaml | ||
</span>{' '} | ||
file during installation has been used to create your project in the <ArrangerAdminUILink /> | ||
. | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
export default getConfigError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.