-
Notifications
You must be signed in to change notification settings - Fork 96
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 #620 from lightninglabs/disabled-subservers
Front-end integration for disabled subservers
- Loading branch information
Showing
19 changed files
with
380 additions
and
60 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
app/src/__tests__/components/common/SubServerStatusMessage.spec.tsx
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,30 @@ | ||
import React from 'react'; | ||
import { renderWithProviders } from 'util/tests'; | ||
import { prefixTranslation } from 'util/translate'; | ||
import { SubServerStatusMessage } from 'components/common/SubServerRequired'; | ||
|
||
describe('SubServer Status Message Component', () => { | ||
const render = (isDisabled: boolean, errorMessage?: string) => { | ||
const cmp = ( | ||
<SubServerStatusMessage isDisabled={isDisabled} errorMessage={errorMessage} /> | ||
); | ||
return renderWithProviders(cmp); | ||
}; | ||
|
||
it('should display disabled', () => { | ||
const { getByText } = render(true); | ||
const { l } = prefixTranslation('cmps.common.SubServerStatus'); | ||
expect(getByText(l('isDisabled'))).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display error', () => { | ||
const { getByText } = render(false); | ||
const { l } = prefixTranslation('cmps.common.SubServerStatus'); | ||
expect(getByText(l('isError'))).toBeInTheDocument(); | ||
}); | ||
|
||
it('should match error message', () => { | ||
const { getByText } = render(false, 'Test error message'); | ||
expect(getByText('Test error message')).toBeInTheDocument(); | ||
}); | ||
}); |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { usePrefixedTranslation } from 'hooks'; | ||
import { Plug } from '../base'; | ||
import { SubServerStatus } from 'types/state'; | ||
|
||
const Styled = { | ||
Wrapper: styled.div` | ||
min-height: 100vh; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`, | ||
StatusMessage: styled.div` | ||
display: inline-block; | ||
border-radius: 24px; | ||
padding: 3px 16px 3px 6px; | ||
font-size: ${props => props.theme.sizes.s}; | ||
color: ${props => props.theme.colors.lightningGray}; | ||
font-weight: 600; | ||
white-space: nowrap; | ||
text-align: center; | ||
svg { | ||
margin-bottom: 16px; | ||
color: ${props => props.theme.colors.gold}; | ||
} | ||
`, | ||
Error: styled.div` | ||
font-weight: bold; | ||
`, | ||
}; | ||
|
||
interface StatusProps { | ||
isDisabled: boolean; | ||
errorMessage?: string; | ||
} | ||
|
||
export const SubServerStatusMessage: React.FC<StatusProps> = ({ | ||
isDisabled, | ||
errorMessage, | ||
}) => { | ||
const { l } = usePrefixedTranslation('cmps.common.SubServerStatus'); | ||
const { Wrapper, StatusMessage, Error } = Styled; | ||
return ( | ||
<Wrapper> | ||
<StatusMessage> | ||
<Plug size="x-large" /> | ||
|
||
{isDisabled ? ( | ||
<p>{l('isDisabled')}</p> | ||
) : ( | ||
<> | ||
<p>{l('isError')}</p> | ||
<Error>{errorMessage}</Error> | ||
</> | ||
)} | ||
</StatusMessage> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
interface Props { | ||
status: SubServerStatus; | ||
} | ||
|
||
const SubServerRequired: React.FC<Props> = ({ status, children }) => { | ||
if (status.disabled) { | ||
return <SubServerStatusMessage isDisabled />; | ||
} else if (status.error) { | ||
return <SubServerStatusMessage isDisabled={false} errorMessage={status.error} />; | ||
} | ||
|
||
return <>{children}</>; | ||
}; | ||
|
||
export default SubServerRequired; |
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.