Skip to content

Commit

Permalink
dont show Add Readme button for nested package tree
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus committed Jul 29, 2022
1 parent aa9173a commit e1ab582
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion catalog/app/containers/Bucket/Dir.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function DirContents({ response, locked, bucket, path, loadMore }: DirContentsPr
/>
{/* Remove TS workaround when Summary will be converted to .tsx */}
{/* @ts-expect-error */}
<Summary files={response.files} mkUrl={null} />
<Summary files={response.files} mkUrl={null} path={path} />
</>
)
}
Expand Down
1 change: 1 addition & 0 deletions catalog/app/containers/Bucket/PackageTree/PackageTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ function DirDisplay({
<M.Box mt={2}>
{preferences?.ui?.blocks?.browser && <Listing items={items} key={hash} />}
<Summary
path={path}
files={summaryHandles}
mkUrl={mkUrl}
packageHandle={packageHandle}
Expand Down
18 changes: 10 additions & 8 deletions catalog/app/containers/Bucket/Summary.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path'
import { basename, join } from 'path'

import * as R from 'ramda'
import * as React from 'react'
Expand Down Expand Up @@ -29,7 +29,7 @@ function AddReadmeSection({ packageHandle: { bucket, name } }) {
const classes = useAddReadmeSectionStyles()
const { urls } = NamedRoutes.use()
const next = urls.bucketPackageDetail(bucket, name, { action: 'revisePackage' })
const toConfig = urls.bucketFile(bucket, path.join(name, 'README.md'), {
const toConfig = urls.bucketFile(bucket, join(name, 'README.md'), {
add: true,
edit: true,
next,
Expand Down Expand Up @@ -109,7 +109,7 @@ function SummaryItemFile({ handle, name, mkUrl }) {
<Container>
<Header>
<StyledLink to={mkUrl(handle)}>
{name || path.basename(handle.logicalKey || handle.key)}
{name || basename(handle.logicalKey || handle.key)}
</StyledLink>
</Header>
<M.CardContent>{withData(Preview.display({ renderContents }))}</M.CardContent>
Expand Down Expand Up @@ -171,8 +171,8 @@ function Thumbnails({ images, mkUrl }) {
<Thumbnail
handle={resolved}
className={classes.img}
alt={path.basename(i.logicalKey || i.key)}
title={path.basename(i.logicalKey || i.key)}
alt={basename(i.logicalKey || i.key)}
title={basename(i.logicalKey || i.key)}
/>
),
})}
Expand All @@ -199,7 +199,7 @@ function Thumbnails({ images, mkUrl }) {
}

// files: Array of s3 handles
export default function BucketSummary({ files, mkUrl: mkUrlProp, packageHandle }) {
export default function BucketSummary({ files, mkUrl: mkUrlProp, packageHandle, path }) {
const { urls } = NamedRoutes.use()
const mkUrl = React.useCallback(
(handle) =>
Expand All @@ -214,12 +214,14 @@ export default function BucketSummary({ files, mkUrl: mkUrlProp, packageHandle }
<>
{readme && (
<SummaryItemFile
title={path.basename(readme.logicalKey || readme.key)}
title={basename(readme.logicalKey || readme.key)}
handle={readme}
mkUrl={mkUrl}
/>
)}
{!readme && !!packageHandle && <AddReadmeSection packageHandle={packageHandle} />}
{!readme && !path && !!packageHandle && (
<AddReadmeSection packageHandle={packageHandle} />
)}
{!!images.length && <Thumbnails {...{ images, mkUrl }} />}
{summarize && (
<Summarize.SummaryNested
Expand Down
2 changes: 1 addition & 1 deletion catalog/app/embed/Dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default function Dir({
/>
}
/>
<Summary files={res.files} />
<Summary files={res.files} path={path} />
</>
)
},
Expand Down

0 comments on commit e1ab582

Please sign in to comment.