-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
354 additions
and
4 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
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
107 changes: 107 additions & 0 deletions
107
src/Pages/Templates/TemplateDetails/components/UseTemplate/AnsibleTab.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,107 @@ | ||
import { | ||
ClipboardCopy, | ||
ClipboardCopyButton, | ||
ClipboardCopyVariant, CodeBlock, CodeBlockAction, CodeBlockCode, | ||
TabContent, | ||
Text, TextContent, | ||
TextList, | ||
TextListItem, | ||
TextVariants | ||
} from '@patternfly/react-core'; | ||
import React from 'react'; | ||
import {createUseStyles} from 'react-jss'; | ||
import {useParams} from 'react-router-dom'; | ||
|
||
export const ANSIBLE_TAB = 'ansible' | ||
|
||
const useStyles = createUseStyles({ | ||
textGroup: { | ||
paddingTop: '8px', | ||
}, | ||
}) | ||
|
||
type Props = { | ||
tabContentRef: React.RefObject<HTMLElement> | ||
} | ||
|
||
const playbook1 = `--- | ||
- hosts: all | ||
tasks: | ||
- name: Download template.repo | ||
ansible.builtin.get_url: | ||
url: https://console.redhat.com/api/content-sources/v1/templates/` | ||
const playbook2 = `/config.repo | ||
dest: /etc/yum.repos.d/template.repo | ||
mode: '0444' | ||
client_cert: /etc/pki/consumer/cert.pem | ||
client_key: /etc/pki/consumer/cert.key | ||
` | ||
|
||
const AnsibleTab = ({ tabContentRef }: Props) => { | ||
const classes = useStyles(); | ||
const { templateUUID } = useParams(); | ||
const [copied, setCopied] = React.useState(false); | ||
|
||
const clipboardCopyFunc = (event, text) => { | ||
navigator.clipboard.writeText(text.toString()); | ||
}; | ||
|
||
const onClick = (event, text) => { | ||
clipboardCopyFunc(event, text); | ||
setCopied(true); | ||
}; | ||
|
||
const actions = ( | ||
<React.Fragment> | ||
<CodeBlockAction> | ||
<ClipboardCopyButton | ||
id="basic-copy-button" | ||
textId="code-content" | ||
aria-label="Copy to clipboard" | ||
onClick={(e) => onClick(e, playbook1+`${templateUUID}`+playbook2)} | ||
exitDelay={copied ? 1500 : 600} | ||
maxWidth="110px" | ||
variant="plain" | ||
onTooltipHidden={() => setCopied(false)} | ||
> | ||
{copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'} | ||
</ClipboardCopyButton> | ||
</CodeBlockAction> | ||
</React.Fragment> | ||
); | ||
|
||
return ( | ||
<TabContent eventKey={ANSIBLE_TAB} id={ANSIBLE_TAB} ref={tabContentRef} hidden> | ||
<TextContent className={classes.textGroup}> | ||
<Text component={TextVariants.h2}>Register for subscriptions</Text> | ||
<TextList isPlain> | ||
<TextListItem> | ||
<Text component="h6">Register with rhc</Text> | ||
<ClipboardCopy isReadOnly hoverTip="Copy" clickTip="Copied" variant={ClipboardCopyVariant.expansion}> | ||
rhc connect | ||
</ClipboardCopy> | ||
</TextListItem> | ||
<TextListItem> | ||
<Text component="h6">Or register with subscription manager</Text> | ||
<ClipboardCopy isReadOnly hoverTip="Copy" clickTip="Copied" variant={ClipboardCopyVariant.expansion}> | ||
subscription-manager register | ||
</ClipboardCopy> | ||
</TextListItem> | ||
</TextList> | ||
<TextList isPlain> | ||
<TextListItem> | ||
<Text component={TextVariants.h2}>Use this ansible playbook to download the repo file</Text> | ||
<CodeBlock actions={actions}> | ||
<CodeBlockCode> | ||
{playbook1+`${templateUUID}`+playbook2} | ||
</CodeBlockCode> | ||
</CodeBlock> | ||
<Text>Note: Adding or removing a repository from the template will not be reflected on the client until this file is re-downloaded</Text> | ||
</TextListItem> | ||
</TextList> | ||
</TextContent> | ||
</TabContent> | ||
) | ||
} | ||
|
||
export default AnsibleTab; |
62 changes: 62 additions & 0 deletions
62
src/Pages/Templates/TemplateDetails/components/UseTemplate/CurlTab.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,62 @@ | ||
import { | ||
ClipboardCopy, | ||
ClipboardCopyVariant, | ||
TabContent, | ||
Text, TextContent, | ||
TextList, | ||
TextListItem, | ||
TextVariants | ||
} from '@patternfly/react-core'; | ||
import React from 'react'; | ||
import {createUseStyles} from 'react-jss'; | ||
import {useParams} from 'react-router-dom'; | ||
|
||
export const CURL_TAB = 'curl' | ||
|
||
const useStyles = createUseStyles({ | ||
textGroup: { | ||
paddingTop: '8px', | ||
}, | ||
}) | ||
|
||
type Props = { | ||
tabContentRef: React.RefObject<HTMLElement> | ||
} | ||
|
||
const CurlTab = ({ tabContentRef }: Props) => { | ||
const classes = useStyles(); | ||
const { templateUUID } = useParams(); | ||
|
||
return ( | ||
<TabContent eventKey={CURL_TAB} id={CURL_TAB} ref={tabContentRef} hidden> | ||
<TextContent className={classes.textGroup}> | ||
<Text component={TextVariants.h2}>Register for subscriptions</Text> | ||
<TextList isPlain> | ||
<TextListItem> | ||
<Text component="h6">Register with rhc</Text> | ||
<ClipboardCopy isReadOnly hoverTip="Copy" clickTip="Copied" variant={ClipboardCopyVariant.expansion}> | ||
rhc connect | ||
</ClipboardCopy> | ||
</TextListItem> | ||
<TextListItem> | ||
<Text component="h6">Or register with subscription manager</Text> | ||
<ClipboardCopy isReadOnly hoverTip="Copy" clickTip="Copied" variant={ClipboardCopyVariant.expansion}> | ||
subscription-manager register | ||
</ClipboardCopy> | ||
</TextListItem> | ||
</TextList> | ||
<TextList isPlain> | ||
<TextListItem> | ||
<Text component={TextVariants.h2}>Download the repo file</Text> | ||
<ClipboardCopy isReadOnly hoverTip="Copy" clickTip="Copied" variant={ClipboardCopyVariant.expansion}> | ||
{'curl -o /etc/yum.repos.d/template.repo https://console.redhat.com/api/content-sources/v1/templates/'+templateUUID+'/config.repo'} | ||
</ClipboardCopy> | ||
<Text>Note: Adding or removing a repository from the template will not be reflected on the client until this file is re-downloaded.</Text> | ||
</TextListItem> | ||
</TextList> | ||
</TextContent> | ||
</TabContent> | ||
) | ||
} | ||
|
||
export default CurlTab; |
63 changes: 63 additions & 0 deletions
63
src/Pages/Templates/TemplateDetails/components/UseTemplate/InsightsTab.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,63 @@ | ||
import { | ||
ClipboardCopy, | ||
ClipboardCopyVariant, | ||
TabContent, | ||
Text, TextContent, | ||
TextList, | ||
TextListItem, | ||
TextVariants | ||
} from '@patternfly/react-core'; | ||
import React from 'react'; | ||
import {ADD_ROUTE, DETAILS_ROUTE, SYSTEMS_ROUTE} from '../../../../../Routes/constants'; | ||
import {ExternalLinkAltIcon} from '@patternfly/react-icons'; | ||
import {createUseStyles} from 'react-jss'; | ||
import {useLocation} from 'react-router-dom'; | ||
|
||
export const INSIGHTS_TAB = 'insights' | ||
|
||
const useStyles = createUseStyles({ | ||
textGroup: { | ||
paddingTop: '8px', | ||
}, | ||
}) | ||
|
||
type Props = { | ||
tabContentRef: React.RefObject<HTMLElement> | ||
} | ||
|
||
const InsightsTab = ({ tabContentRef }: Props) => { | ||
const classes = useStyles(); | ||
|
||
const { pathname } = useLocation(); | ||
const [mainRoute] = pathname?.split(`${DETAILS_ROUTE}/`) || []; | ||
const addSystemsRoute = mainRoute + `${DETAILS_ROUTE}/`+ `${SYSTEMS_ROUTE}/` + `${ADD_ROUTE}/`; | ||
|
||
return ( | ||
<TabContent eventKey={INSIGHTS_TAB} id={INSIGHTS_TAB} ref={tabContentRef}> | ||
<TextContent className={classes.textGroup}> | ||
<Text component={TextVariants.h2}>Register for subscriptions</Text> | ||
<TextList isPlain> | ||
<TextListItem> | ||
<Text component="h6">Register with rhc</Text> | ||
<ClipboardCopy isReadOnly hoverTip="Copy" clickTip="Copied" variant={ClipboardCopyVariant.expansion}> | ||
rhc connect | ||
</ClipboardCopy> | ||
</TextListItem> | ||
</TextList> | ||
<Text component={TextVariants.h2}>Assign the template to a system</Text> | ||
<TextList isPlain> | ||
<TextListItem> | ||
<Text> | ||
Add template in {' '} | ||
<a href={addSystemsRoute} rel='noreferrer' target='_blank'> | ||
Systems <ExternalLinkAltIcon/> | ||
</a> | ||
</Text> | ||
</TextListItem> | ||
</TextList> | ||
</TextContent> | ||
</TabContent> | ||
) | ||
} | ||
|
||
export default InsightsTab; |
Oops, something went wrong.