All files / app/components version-info.tsx

0% Statements 0/25
0% Branches 0/11
0% Functions 0/4
0% Lines 0/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82                                                                                                                                                                   
import packageJson from '../../package.json';
import { NETWORK } from '@constants/index';
import { color, Stack, Text } from '@stacks/ui';
import { openExternalLink } from '@utils/external-links';
import React, { FC } from 'react';
 
const sha = CONFIG.SHA;
const shaShort = sha && sha.substr(0, 7);
const pullRequest = CONFIG.PULL_REQUEST;
const branchName = CONFIG.BRANCH_NAME;
const version = packageJson.version;
 
const issueParams = new URLSearchParams();
const issueTitle = `[${String(packageJson.version)}] Bug: <describe issue>`;
const issueLabels = `bug,reported-from-ui,4.x,${NETWORK}`;
const issueBody = `
<!--
 
  Thanks for creating an issue. Please include as much detail as possible,
  including screenshots, operating system, and steps to recreate the problem.
 
  If you have any questions, ask @kyranjamie or @aulneau on Github, Discord and Twitter.
 
-->
 
Bug found testing Leather build ${String(shaShort)}, ${String(version)}.
 
`;
 
issueParams.set('title', issueTitle);
issueParams.set('labels', issueLabels);
issueParams.set('body', issueBody);
 
const openIssueLink = () =>
  openExternalLink(`https://github.com/blockstack/stacks-wallet/issues/new?${String(issueParams)}`);
 
const openPullRequestLink = () =>
  openExternalLink(`https://github.com/blockstack/stacks-wallet/pull/${String(pullRequest)}`);
 
export const VersionInfo: FC = () => {
  return (
    <Stack
      isInline
      textStyle="caption.medium"
      fontSize="11px"
      color={color('text-caption')}
      position="fixed"
      right="8px"
      bottom="8px"
      border={`1px solid ${color('border')}`}
      borderRadius="24px"
      bg={color('bg-4')}
      py="4px"
      px="base-tight"
    >
      <Text onClick={openIssueLink} _hover={{ textDecoration: 'underline' }} cursor="pointer">
        Found a bug? Open an issue
      </Text>
      {pullRequest && branchName && (
        <Text onClick={openPullRequestLink} textDecoration="underline" cursor="pointer">
          {branchName}
        </Text>
      )}
      {shaShort && (
        <Text>
          Commit:{' '}
          <Text
            cursor="pointer"
            textDecoration="underline"
            onClick={() =>
              openExternalLink(`https://github.com/blockstack/stacks-wallet/commit/${sha || ''}`)
            }
          >
            {shaShort}
          </Text>
        </Text>
      )}
      {CONFIG.NODE_ENV === 'production' && <Text>[v{packageJson.version}]</Text>}
    </Stack>
  );
};