forked from harness/canary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds the repo empty view (harness#836)
* feat: add repo empty view * feat: add preview * fix: minor design fixes * fix: spacing
- Loading branch information
1 parent
61a148e
commit 68c6db2
Showing
5 changed files
with
130 additions
and
6 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
12 changes: 12 additions & 0 deletions
12
apps/design-system/src/subjects/views/repo-empty/repo-empty-view.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,12 @@ | ||
import { RepoEmptyView } from '@harnessio/ui/views' | ||
|
||
export const RepoEmpty = () => { | ||
return ( | ||
<RepoEmptyView | ||
httpUrl="https://github.com/mock-repo" | ||
repoName="mock-repo" | ||
projName="mock-project" | ||
sshUrl="[email protected]:mock-repo.git" | ||
/> | ||
) | ||
} |
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
105 changes: 105 additions & 0 deletions
105
packages/ui/src/views/repo/repo-summary/repo-empty-view.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,105 @@ | ||
import { | ||
Button, | ||
ButtonGroup, | ||
ControlGroup, | ||
CopyButton, | ||
Fieldset, | ||
FormSeparator, | ||
Input, | ||
MarkdownViewer, | ||
NoData, | ||
Spacer, | ||
StyledLink, | ||
Text | ||
} from '@/components' | ||
import { SandboxLayout } from '@/views' | ||
|
||
interface RepoEmptyViewProps { | ||
repoName: string | ||
projName: string | ||
httpUrl: string | ||
sshUrl: string | ||
} | ||
|
||
export const RepoEmptyView: React.FC<RepoEmptyViewProps> = ({ repoName, projName, httpUrl, sshUrl }) => { | ||
const getInitialCommitMarkdown = () => { | ||
return ` | ||
\`\`\`shell | ||
cd ${repoName} | ||
git branch -M main | ||
echo '# Hello World' >> README.md | ||
git add README.md | ||
git commit -m 'Initial commit' | ||
git push -u origin main | ||
\`\`\` | ||
` | ||
} | ||
|
||
const getExistingRepoMarkdown = () => { | ||
return ` | ||
\`\`\`shell | ||
git remote add origin http://localhost:3000/git/${projName}/${repoName}.git | ||
git branch -M main | ||
git push -u origin main | ||
\`\`\` | ||
` | ||
} | ||
return ( | ||
<SandboxLayout.Main> | ||
<SandboxLayout.Content className="max-w-[850px] mx-auto"> | ||
<Text size={5} weight={'medium'}> | ||
Repository | ||
</Text> | ||
<Spacer size={6} /> | ||
<NoData | ||
withBorder | ||
iconName="no-repository" | ||
title="This repository is empty" | ||
description={['We recommend every repository include a', 'README, LICENSE, and .gitignore.']} | ||
primaryButton={{ label: 'New file' }} | ||
className="py-0 pb-0 min-h-[40vh]" | ||
/> | ||
<Spacer size={6} /> | ||
|
||
<Fieldset> | ||
<Text size={4} weight="medium"> | ||
Please Generate Git Cradentials if it’s your first time cloning the repository | ||
</Text> | ||
<Text size={3}>Git clone URL</Text> | ||
<Input label="HTTP" value={httpUrl} readOnly rightElement={<CopyButton name={httpUrl} />} /> | ||
<Input label="SSH" value={sshUrl} readOnly rightElement={<CopyButton name={sshUrl} />} /> | ||
<ControlGroup> | ||
<ButtonGroup> | ||
<Button>Generate Clone Credentials</Button> | ||
</ButtonGroup> | ||
<p className="mt-2"> | ||
You can also manage your git credential{' '} | ||
<StyledLink to="/" relative="path"> | ||
here | ||
</StyledLink> | ||
</p> | ||
</ControlGroup> | ||
|
||
<FormSeparator /> | ||
<Text size={4} weight="medium"> | ||
Then push some content into it | ||
</Text> | ||
<MarkdownViewer source={getInitialCommitMarkdown()} /> | ||
<Text size={4} weight="medium"> | ||
Or you can push an existing repository | ||
</Text> | ||
<ControlGroup> | ||
<MarkdownViewer source={getExistingRepoMarkdown()} /> | ||
<p> | ||
You might need to{' '} | ||
<StyledLink to="/" relative="path"> | ||
create an API token | ||
</StyledLink>{' '} | ||
In order to pull from or push into this repository. | ||
</p> | ||
</ControlGroup> | ||
</Fieldset> | ||
</SandboxLayout.Content> | ||
</SandboxLayout.Main> | ||
) | ||
} |
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