mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
95c37e1ba3
* feat: add yaml feature management Add yaml feature file per build type. Also add method to parse yaml and set enabled features env to true. The build process will then replace any process.env[feature] that exists on the config by its value * chore: add example for desktop * Added initial draft of build features * [TMP] Sync between computers * Is able to succesfully build stable extension with snaps feature * Removing var context from builds.yml * Add asssets to builds.yml * Minor bug fixes and removing debug logs * [WIP] Test changes * Removed TODOs * Fix regession bug Also * remove debug logs * merge Variables.set and Variables.setMany with an overload * Fix build, lint and a bunch of issues * Update LavaMoat policies * Re-add desktop build type * Fix some tests * Fix desktop build * Define some env variables used by MV3 * Fix lint * Fix remove-fenced-code tests * Fix README typo * Move new code * Fix missing asset copy * Move Jest env setup * Fix path for test after rebase * Fix code fences * Fix fencing and LavaMoat policies * Fix MMI code-fencing after rebase * Fix MMI code fencing after merge * Fix more MMI code fencing --------- Co-authored-by: cryptotavares <joao.tavares@consensys.net> Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com> Co-authored-by: Brad Decker <bhdecker84@gmail.com>
104 lines
2.8 KiB
JavaScript
104 lines
2.8 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classnames from 'classnames';
|
|
import { getSnapPrefix } from '@metamask/snaps-utils';
|
|
import { useSelector } from 'react-redux';
|
|
import Box from '../../../ui/box';
|
|
import {
|
|
BackgroundColor,
|
|
TextColor,
|
|
IconColor,
|
|
FLEX_DIRECTION,
|
|
TextVariant,
|
|
BorderColor,
|
|
AlignItems,
|
|
DISPLAY,
|
|
BorderRadius,
|
|
BLOCK_SIZES,
|
|
} from '../../../../helpers/constants/design-system';
|
|
import {
|
|
getSnapName,
|
|
removeSnapIdPrefix,
|
|
} from '../../../../helpers/utils/util';
|
|
import { ButtonIcon, IconName, Text } from '../../../component-library';
|
|
|
|
import { getTargetSubjectMetadata } from '../../../../selectors';
|
|
import SnapAvatar from '../snap-avatar';
|
|
|
|
const SnapAuthorship = ({ snapId, className }) => {
|
|
// We're using optional chaining with snapId, because with the current implementation
|
|
// of snap update in the snap controller, we do not have reference to snapId when an
|
|
// update request is rejected because the reference comes from the request itself and not subject metadata
|
|
// like it is done with snap install
|
|
const snapPrefix = snapId && getSnapPrefix(snapId);
|
|
const packageName = snapId && removeSnapIdPrefix(snapId);
|
|
const isNPM = snapPrefix === 'npm:';
|
|
const url = isNPM
|
|
? `https://www.npmjs.com/package/${packageName}`
|
|
: packageName;
|
|
|
|
const subjectMetadata = useSelector((state) =>
|
|
getTargetSubjectMetadata(state, snapId),
|
|
);
|
|
|
|
const friendlyName = snapId && getSnapName(snapId, subjectMetadata);
|
|
|
|
return (
|
|
<Box
|
|
className={classnames('snaps-authorship', className)}
|
|
backgroundColor={BackgroundColor.backgroundDefault}
|
|
borderColor={BorderColor.borderDefault}
|
|
borderWidth={1}
|
|
alignItems={AlignItems.center}
|
|
paddingLeft={2}
|
|
paddingTop={2}
|
|
paddingBottom={2}
|
|
paddingRight={4}
|
|
borderRadius={BorderRadius.pill}
|
|
display={DISPLAY.FLEX}
|
|
width={BLOCK_SIZES.FULL}
|
|
>
|
|
<Box>
|
|
<SnapAvatar snapId={snapId} />
|
|
</Box>
|
|
<Box
|
|
marginLeft={4}
|
|
marginRight={2}
|
|
display={DISPLAY.FLEX}
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
|
style={{ overflow: 'hidden' }}
|
|
>
|
|
<Text ellipsis>{friendlyName}</Text>
|
|
<Text
|
|
ellipsis
|
|
variant={TextVariant.bodySm}
|
|
color={TextColor.textAlternative}
|
|
>
|
|
{packageName}
|
|
</Text>
|
|
</Box>
|
|
<ButtonIcon
|
|
rel="noopener noreferrer"
|
|
target="_blank"
|
|
href={url}
|
|
iconName={IconName.Export}
|
|
color={IconColor.infoDefault}
|
|
style={{ marginLeft: 'auto' }}
|
|
/>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
SnapAuthorship.propTypes = {
|
|
/**
|
|
* The id of the snap
|
|
*/
|
|
snapId: PropTypes.string,
|
|
/**
|
|
* The className of the SnapAuthorship
|
|
*/
|
|
className: PropTypes.string,
|
|
};
|
|
|
|
export default SnapAuthorship;
|