Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 819 upload component improvements #820

Merged
merged 4 commits into from
Oct 28, 2024

Conversation

AdrianBielecAriane
Copy link
Collaborator

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.26%. Comparing base (26c0727) to head (3a2e4d5).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #820   +/-   ##
=======================================
  Coverage   90.26%   90.26%           
=======================================
  Files         163      163           
  Lines        6061     6061           
  Branches      927      927           
=======================================
  Hits         5471     5471           
  Misses        590      590           
Flag Coverage Δ
common 92.11% <ø> (ø)
core-sdk 59.50% <ø> (ø)
e2e 87.19% <ø> (ø)
eth-connect-sdk 94.87% <ø> (ø)
ethers-sdk 69.62% <ø> (ø)
ipfs-storage 89.41% <ø> (ø)
metadata 94.70% <ø> (ø)
unittests 62.91% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 192 to 204
${({ $v2 }) =>
$v2 &&
css`
aspect-ratio: 1/1;
padding-inline: 1.5rem;
background: ${colors.white};
min-width: 9.375rem;
width: auto;
height: auto;
border-radius: 12px;
border: 2px solid ${theme.colors.light.border};
color: ${theme.colors.light.greyText};
`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${({ $v2 }) =>
$v2 &&
css`
aspect-ratio: 1/1;
padding-inline: 1.5rem;
background: ${colors.white};
min-width: 9.375rem;
width: auto;
height: auto;
border-radius: 12px;
border: 2px solid ${theme.colors.light.border};
color: ${theme.colors.light.greyText};
`}
${({ theme : {overrides}) => overrides}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme.overrides should be what css`` returns which isRuleSet<object>

and these styles should be passed in the Upload component in fermion react-kit

@@ -137,6 +137,8 @@ export type UploadProps = BaseProps & {
borderRadiusUnit?: "px" | "%";
width?: number;
height?: number;
errorComponent?: (errorMessage: string) => React.ReactNode;
v2?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
v2?: boolean;

@@ -39,7 +40,7 @@ export function WithUploadToIpfs<P extends WithUploadToIpfsProps>(
const { saveFile, loadMedia, removeFile } = useSaveImageToIpfs();

const saveToIpfs: WithUploadToIpfsProps["saveToIpfs"] = useCallback(
async (filesArray: File[] | null) => {
async (filesArray: File[] | null, throwOnError?: boolean) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async (filesArray: File[] | null, throwOnError?: boolean) => {
async (filesArray: File[] | null, options:{throwOnError?:boolean}={}) => {

`There has been an error because 'files' ${files} is falsy in handleSave`
);
try {
const files = await saveToIpfs(efiles, true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const files = await saveToIpfs(efiles, true);
const files = await saveToIpfs(efiles, {throwOnError:true});

@@ -52,6 +52,8 @@ function BaseUpload({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
removeFile,
saveButtonTheme,
errorComponent,
v2,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
v2,

@@ -128,6 +128,7 @@ export type FileUploadWrapperTheme = Partial<{
}>;
export const FileUploadWrapper = styled.div<{
$error: unknown;
$v2?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$v2?: boolean;

} catch (err) {
if (err instanceof Error) {
setErrorMessage(err.message);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}else{
setErrorMessage("Something went wrong");
}

@@ -306,6 +319,7 @@ function BaseUpload({
data-disabled={disabled}
onClick={handleChooseFile}
$error={errorMessage}
$v2={v2}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$v2={v2}

@AdrianBielecAriane AdrianBielecAriane merged commit 323e876 into main Oct 28, 2024
7 of 10 checks passed
@AdrianBielecAriane AdrianBielecAriane deleted the 819_upload_component_fix branch October 28, 2024 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants