Skip to content

Commit

Permalink
chore: resolve PR convos, ts, lint, prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
thekidnamedkd committed Sep 16, 2024
1 parent da2f2d1 commit c881ad4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/core/components/states/emptyState/emptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const EmptyState: React.FC<IEmptyStateProps> = ({

<div
className={classNames('flex h-full items-center', {
'flex w-full flex-col': isStacked,
'w-full flex-col': isStacked,
'space-y-6': (isStacked && !!primaryButton) || !!secondaryButton,
'space-y-4': (!isStacked && !!primaryButton) || !!secondaryButton,
})}
Expand Down
2 changes: 0 additions & 2 deletions src/modules/assets/copy/modulesCopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export const modulesCopy = {
collapse: 'Collapse all',
expand: 'Expand all',
empty: {
description:
'Add actions by selecting them, interacting with custom contracts, uploading actions or connect with any DApp.',
heading: 'No actions added',
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react';

import { useOdsModulesContext } from '../../../odsModulesProvider';
import {
generateProposalAction,
generateProposalActionUpdateMetadata,
Expand Down Expand Up @@ -123,6 +122,7 @@ export const CustomActions: Story = {
customActionComponents={{
CUSTOM_ACTION: CustomActionComponent,
}}
emptyStateDescription="No actions added. Consider adding some."
/>
);
},
Expand All @@ -132,14 +132,7 @@ export const EmptyActions: Story = {
render: () => {
const actions: IProposalAction[] = [];

const { copy } = useOdsModulesContext();

return (
<ProposalActions
actions={actions}
emptyStateDescription={copy.proposalActionsContainer.empty.description}
/>
);
return <ProposalActions actions={actions} emptyStateDescription="No actions added. Consider adding some." />;
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('<ProposalActions /> component', () => {
const createTestComponent = (props?: Partial<IProposalActionsProps>) => {
const completeProps: IProposalActionsProps = {
actions: [],
emptyStateDescription: 'Please add actions',
...props,
};

Expand Down Expand Up @@ -113,10 +114,11 @@ describe('<ProposalActions /> component', () => {
});

it('renders an empty state if no actions are provided', () => {
const emptyStateDescription = 'Custom empty state description';
const actions: IProposalAction[] = [];
render(createTestComponent({ actions }));
render(createTestComponent({ actions, emptyStateDescription }));
expect(screen.getByText(modulesCopy.proposalActionsContainer.empty.heading)).toBeInTheDocument();
expect(screen.getByText(modulesCopy.proposalActionsContainer.empty.description)).toBeInTheDocument();
expect(screen.getByText(emptyStateDescription)).toBeInTheDocument();
});

it('renders a custom empty state description if provided', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface IProposalActionsProps extends IWeb3ComponentProps {
/**
* Actions to render.
*/
actions: IProposalAction[] | [];
actions: IProposalAction[];
/**
* Map of action-type <=> action-name displayed on the action header.
*/
Expand All @@ -30,7 +30,7 @@ export interface IProposalActionsProps extends IWeb3ComponentProps {
/**
* Custom description for the empty state.
*/
emptyStateDescription?: string;
emptyStateDescription: string;
}

export const ProposalActions: React.FC<IProposalActionsProps> = (props) => {
Expand Down Expand Up @@ -78,7 +78,7 @@ export const ProposalActions: React.FC<IProposalActionsProps> = (props) => {
{actions.length === 0 && (
<EmptyState
heading={copy.proposalActionsContainer.empty.heading}
description={emptyStateDescription ?? copy.proposalActionsContainer.empty.description}
description={emptyStateDescription}
isStacked={false}
objectIllustration={{ object: 'SMART_CONTRACT' }}
/>
Expand All @@ -96,9 +96,9 @@ export const ProposalActions: React.FC<IProposalActionsProps> = (props) => {
? copy.proposalActionsContainer.collapse
: copy.proposalActionsContainer.expand}
</Button>
{children}
</div>
)}
{children}
</div>
</Accordion.Container>
</Card>
Expand Down

0 comments on commit c881ad4

Please sign in to comment.