Skip to content

Commit

Permalink
Component and story updates
Browse files Browse the repository at this point in the history
  • Loading branch information
georgewrmarshall committed Jun 14, 2023
1 parent 2bdc355 commit ef03487
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 67 deletions.
1 change: 0 additions & 1 deletion ui/components/app/app-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
@import 'flask/experimental-area/index';
@import 'snaps/snap-content-footer/index';
@import 'snaps/snap-install-warning/index';
@import 'snaps/snap-remove-warning/index';
@import 'snaps/snap-ui-renderer/index';
@import 'snaps/snap-ui-markdown/index';
@import 'snaps/snap-delineator/index';
Expand Down
12 changes: 0 additions & 12 deletions ui/components/app/snaps/snap-remove-warning/index.scss

This file was deleted.

98 changes: 60 additions & 38 deletions ui/components/app/snaps/snap-remove-warning/snap-remove-warning.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,67 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { Text, Box, Button } from '../../../component-library';
import { TextVariant } from '../../../../helpers/constants/design-system';
import Popover from '../../../ui/popover';
import {
Text,
Box,
Button,
Modal,
ModalContent,
ModalHeader,
ModalOverlay,
BUTTON_VARIANT,
BUTTON_SIZES,
} from '../../../component-library';

export default function SnapRemoveWarning({ onCancel, onSubmit, snapName }) {
const t = useI18nContext();

const SnapRemoveWarningFooter = () => {
return (
<>
<Button
className="snap-remove-warning__footer-button"
type="default"
onClick={onCancel}
>
{t('nevermind')}
</Button>
<Button
id="popoverRemoveSnapButton"
className="snap-remove-warning__footer-button"
type="danger-primary"
onClick={onSubmit}
>
{t('removeSnap')}
</Button>
</>
);
};
import {
BlockSize,
Display,
FlexDirection,
TextVariant,
} from '../../../../helpers/constants/design-system';

export default function SnapRemoveWarning({
isOpen,
onCancel,
onSubmit,
snapName,
}) {
const t = useI18nContext();
return (
<Popover
className="snap-remove-warning"
title={t('pleaseConfirm')}
footer={<SnapRemoveWarningFooter />}
onClose={onCancel}
headerProps={{ padding: [6, 4, 0, 6] }}
>
<Box paddingRight={4} paddingBottom={4} paddingLeft={6}>
<Text variant={TextVariant.headingSm} as="h4">
<Modal isOpen={isOpen} onClose={onCancel}>
<ModalOverlay />
<ModalContent
modalDialogProps={{
display: Display.Flex,
flexDirection: FlexDirection.Column,
gap: 4,
}}
>
<ModalHeader onClose={onCancel}>{t('pleaseConfirm')}</ModalHeader>
<Text variant={TextVariant.bodyLgMedium}>
{t('removeSnapConfirmation', [snapName])}
</Text>
</Box>
</Popover>
<Box width={BlockSize.Full} display={Display.Flex} gap={4}>
<Button
block
variant={BUTTON_VARIANT.SECONDARY}
size={BUTTON_SIZES.LG}
onClick={onCancel}
>
{t('nevermind')}
</Button>
<Button
block
size={BUTTON_SIZES.LG}
id="popoverRemoveSnapButton"
danger
onClick={onSubmit}
>
{t('removeSnap')}
</Button>
</Box>
</ModalContent>
</Modal>
);
}

Expand All @@ -60,4 +78,8 @@ SnapRemoveWarning.propTypes = {
* Name of snap
*/
snapName: PropTypes.string,
/**
* Whether the modal is open
*/
isOpen: PropTypes.bool,
};
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import React from 'react';
import SnapRemoveWarningFooter from './snap-remove-warning';
import SnapRemoveWarning from './snap-remove-warning';

export default {
title: 'Components/App/Snaps/SnapRemoveWarningFooter',
component: SnapRemoveWarningFooter,
title: 'Components/App/Snaps/SnapRemoveWarning',
component: SnapRemoveWarning,
argTypes: {
onCancel: {
control: 'onCancel',
action: 'onCancel',
},
onSubmit: {
control: 'onSubmit',
action: 'onSubmit',
},
snapName: {
control: 'text',
},
isOpen: {
control: 'boolean',
},
},
args: {
snapName: 'Snap Name',
isOpen: true,
},
};

export const DefaultStory = (args) => <SnapRemoveWarningFooter {...args} />;
export const DefaultStory = (args) => <SnapRemoveWarning {...args} />;

DefaultStory.storyName = 'Default';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const Paragraph = (props) => (
<Text
{...props}
variant={TextVariant.bodySm}
as="h6"
className="snap-ui-markdown__text"
overflowWrap={OverflowWrap.BreakWord}
/>
Expand Down
17 changes: 8 additions & 9 deletions ui/pages/settings/snaps/view-snap/view-snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,14 @@ function ViewSnap() {
{`${t('remove')} ${snapName}`}
</Text>
</Button>
{isShowingRemoveWarning && (
<SnapRemoveWarning
onCancel={() => setIsShowingRemoveWarning(false)}
onSubmit={async () => {
await dispatch(removeSnap(snap.id));
}}
snapName={snapName}
/>
)}
<SnapRemoveWarning
isOpen={isShowingRemoveWarning}
onCancel={() => setIsShowingRemoveWarning(false)}
onSubmit={async () => {
await dispatch(removeSnap(snap.id));
}}
snapName={snapName}
/>
</Box>
</Box>
</Box>
Expand Down

0 comments on commit ef03487

Please sign in to comment.