Skip to content

Commit

Permalink
Bugfix/web allow push empty blob (#53)
Browse files Browse the repository at this point in the history
* web: push/preview/update empty blob

* web: ability to view private key and phrase
  • Loading branch information
Roman Matusevich authored Aug 24, 2022
1 parent 7392939 commit 4f957d2
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 29 deletions.
4 changes: 2 additions & 2 deletions web/src/pages/Blob/Blob.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ const BlobPage = () => {
Loading file...
</div>
)}
{monaco && blob.path && blob.content && (
{monaco && blob.path && !blob.isFetching && (
<div className="border rounded overflow-hidden">
<div className="flex bg-gray-100 px-3 py-1 border-b justify-end">
{!Buffer.isBuffer(blob.content) ? (
<>
<CopyClipboard
componentProps={{
text: blob.content,
text: blob.content || '',
}}
iconContainerClassName="text-extblack/60 hover:text-extblack p-1"
iconProps={{
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/BlobUpdate/BlobUpdate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ const BlobUpdatePage = () => {
</div>
)}
</div>
{monaco && blob.path && blob.content && (
{monaco && blob.path && !blob.isFetching && (
<Formik
initialValues={{
name: splitByPath(blob.path)[1],
content: blob.content.toString(),
content: blob.content ? blob.content.toString() : '',
title: '',
message: '',
tags: '',
Expand Down
26 changes: 13 additions & 13 deletions web/src/pages/PullCreate/PullCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,19 @@ const PullCreatePage = () => {
throw new GoshError(EGoshError.PR_NO_MERGE)

// Prepare blobs
const blobs = compare.map(({ from, to }) => {
if (!from.item || !from.blob.content)
throw new GoshError(EGoshError.FILE_EMPTY)
return {
name: `${from.item.path ? `${from.item.path}/` : ''}${
from.item.name
}`,
modified: from.blob.content ?? '',
original: to?.blob.content,
isIpfs: from.blob.isIpfs || to?.blob.isIpfs,
treeItem: from.item,
}
})
const blobs = compare
.filter(({ from }) => !!from.item)
.map(({ from, to }) => {
return {
name: `${from.item.path ? `${from.item.path}/` : ''}${
from.item.name
}`,
modified: from.blob.content ?? '',
original: to?.blob.content,
isIpfs: from.blob.isIpfs || to?.blob.isIpfs,
treeItem: from.item,
}
})
console.debug('Blobs', blobs)

if (branchTo.isProtected) {
Expand Down
74 changes: 62 additions & 12 deletions web/src/pages/Settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,75 @@
import React from 'react'
import { useState } from 'react'
import { useRecoilValue } from 'recoil'
import CopyClipboard from '../../components/CopyClipboard'
import { userStateAtom } from '../../store/user.state'
import { shortString } from '../../utils'

const SettingsPage = () => {
const userState = useRecoilValue(userStateAtom)
const [showPrivate, setShowPrivate] = useState<boolean>(false)
const [showPhrase, setShowPhrase] = useState<boolean>(false)

const onShowPrivateToggle = () => setShowPrivate(!showPrivate)

const onShowPhraseToggle = () => setShowPhrase(!showPhrase)

return (
<div>
<h3 className="text-xl font-semibold">My public key</h3>
<p>Share it with DAO owner to add you to participants list</p>
{userState.keys && (
<CopyClipboard
className="mt-4"
label={shortString(`0x${userState.keys.public}`, 10, 10)}
componentProps={{
text: `0x${userState.keys.public}`,
}}
/>
)}
<div>
<h3 className="text-xl font-semibold">My public key</h3>
<p>Share it with DAO owner to add you to participants list</p>
{userState.keys && (
<CopyClipboard
className="mt-4"
label={shortString(`0x${userState.keys.public}`, 10, 10)}
componentProps={{
text: `0x${userState.keys.public}`,
}}
/>
)}
</div>

<div>
<h3 className="text-xl font-semibold mt-5">My private key</h3>
<p>Don't share it with anybody</p>
{userState.keys?.secret && showPrivate && (
<CopyClipboard
className="mt-4"
label={shortString(`0x${userState.keys.secret}`, 10, 10)}
componentProps={{
text: `0x${userState.keys.secret}`,
}}
/>
)}
<button
className="btn btn--body btn--sm !font-normal px-4 py-1.5 mt-2"
type="button"
onClick={onShowPrivateToggle}
>
{showPrivate ? 'Hide' : 'Show'}
</button>
</div>

<div>
<h3 className="text-xl font-semibold mt-5">My seed phrase</h3>
<p>Don't share it with anybody</p>
{userState.phrase && showPhrase && (
<CopyClipboard
className="mt-4"
label={userState.phrase}
componentProps={{
text: userState.phrase,
}}
/>
)}
<button
className="btn btn--body btn--sm !font-normal px-4 py-1.5 mt-2"
type="button"
onClick={onShowPhraseToggle}
>
{showPhrase ? 'Hide' : 'Show'}
</button>
</div>
</div>
)
}
Expand Down

0 comments on commit 4f957d2

Please sign in to comment.