Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/components/common/CopyFileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React, { useState } from 'react'
import styled from '@emotion/styled'
import { Button, Popover } from 'antd'
import type { ButtonProps } from 'antd'
import { getBinaryFileURL } from '../../utils'
import { getBinaryFileURL, USE_YARN_PLUGIN } from '../../utils'
import { CopyOutlined } from '@ant-design/icons'
import { useSettings } from '../../SettingsProvider'

const popoverContentOpts = {
default: 'Copy raw contents',
Expand Down Expand Up @@ -33,10 +34,14 @@ const CopyFileButton = styled(
popoverContentOpts.default
)

const {
settings: { [USE_YARN_PLUGIN]: useYarnPlugin },
} = useSettings()

const fetchContent = () =>
fetch(getBinaryFileURL({ packageName, version, path })).then((response) =>
response.text()
)
fetch(
getBinaryFileURL({ packageName, version, path, useYarnPlugin })
).then((response) => response.text())
// .then((content) => replaceAppDetails(content, appName, appPackage))

const copyContent = () => {
Expand Down
9 changes: 7 additions & 2 deletions src/components/common/DownloadFileButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import { Button, ButtonProps } from 'antd'
import { DownloadOutlined } from '@ant-design/icons'
import { getBinaryFileURL } from '../../utils'
import { getBinaryFileURL, USE_YARN_PLUGIN } from '../../utils'
import { useSettings } from '../../SettingsProvider'

interface DownloadFileButtonProps extends ButtonProps {
open: boolean
Expand All @@ -16,13 +17,17 @@ const DownloadFileButton = ({
packageName,
...props
}: DownloadFileButtonProps) => {
const {
settings: { [USE_YARN_PLUGIN]: useYarnPlugin },
} = useSettings()

return open ? (
<Button
{...props}
shape="circle"
icon={<DownloadOutlined />}
target="_blank"
href={getBinaryFileURL({ packageName, version, path })}
href={getBinaryFileURL({ packageName, version, path, useYarnPlugin })}
/>
) : null
}
Expand Down
8 changes: 7 additions & 1 deletion src/components/common/RawDiffLinkButton.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import styled from '@emotion/styled'
import { Button as AntdButton } from 'antd'
import { getDiffURL } from '../../utils'
import { getDiffURL, USE_YARN_PLUGIN } from '../../utils'
import { useSettings } from '../../SettingsProvider'

const Container = styled.div`
display: flex;
Expand All @@ -23,6 +24,10 @@ const RawDiffLinkButton = ({
fromVersion,
toVersion,
}) => {
const {
settings: { [USE_YARN_PLUGIN]: useYarnPlugin },
} = useSettings()

if (fromVersion === '') {
return null
}
Expand All @@ -31,6 +36,7 @@ const RawDiffLinkButton = ({
language,
fromVersion,
toVersion,
useYarnPlugin,
})
return (
<Container>
Expand Down
9 changes: 7 additions & 2 deletions src/components/common/ViewFileButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import styled from '@emotion/styled'
import { Button, ButtonProps } from 'antd'
import { getBinaryFileURL } from '../../utils'
import { getBinaryFileURL, USE_YARN_PLUGIN } from '../../utils'
import { useSettings } from '../../SettingsProvider'

interface ViewFileButtonProps extends ButtonProps {
open: boolean
Expand All @@ -15,12 +16,16 @@ const ViewFileButton = styled(
return null
}

const {
settings: { [USE_YARN_PLUGIN]: useYarnPlugin },
} = useSettings()

return (
<Button
{...props}
target="_blank"
size="small"
href={getBinaryFileURL({ packageName, version, path })}
href={getBinaryFileURL({ packageName, version, path, useYarnPlugin })}
>
Raw
</Button>
Expand Down
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ export const getBinaryFileURL = ({
language,
version,
path,
}: GetBinaryFileURLProps) => {
useYarnPlugin,
}: GetBinaryFileURLProps & { useYarnPlugin: boolean }) => {
const branch = getBranch({ packageName, language, version })

return `https://raw.githubusercontent.com/${getRNDiffRepository({
packageName,
})}/release/${branch}/${path}`
})}/release/${useYarnPlugin ? 'yarn-plugin/' : ''}${branch}/${path}`
}

export const removeAppPathPrefix = (path: string, appName = DEFAULT_APP_NAME) =>
Expand Down
Loading