Skip to content

Commit

Permalink
Release/v3.11.4 (#94)
Browse files Browse the repository at this point in the history
* Release/v3.11.4 (#751)

* fix: ASC-27509 - file upload (#750)

* fix: cannot upload the same file again

* fix: show modal to discard files after upload failed

* chore(release): 3.11.4

---------

Co-authored-by: Pitchaya T. <[email protected]>
Co-authored-by: bmo-amity-bot <[email protected]>

* chore: update lock file

* chore(release): 3.11.4

---------

Co-authored-by: Pitchaya T. <[email protected]>
Co-authored-by: bmo-amity-bot <[email protected]>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent 475a96f commit d70ac6d
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 41 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### 3.11.4 (2024-12-02)

### 3.11.4 (2024-12-02)


### Bug Fixes

* ASC-27509 - file upload ([#750](https://github.com/AmityCo/Amity-Social-Cloud-UIKit-Web/issues/750)) ([53a5b4e](https://github.com/AmityCo/Amity-Social-Cloud-UIKit-Web/commit/53a5b4e1057762e61f839730a3568d253ec0602a))

### 3.11.3 (2024-11-28)

### 3.11.3 (2024-11-28)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@amityco/ui-kit-open-source",
"version": "3.11.3",
"version": "3.11.4",
"engines": {
"node": ">=16",
"pnpm": ">=8"
Expand Down
110 changes: 80 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/core/components/Uploaders/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ const FileLoader: React.FC<FileLoaderProps> = ({
accept={mimeType}
multiple={multiple}
disabled={disabled}
onChange={onLoad}
onChange={(e) => {
e.target.value && onLoad(e);
e.target.value = '';
}}
onClick={onClick}
/>
{children}
Expand Down
22 changes: 19 additions & 3 deletions src/social/components/post/Creator/components/FilesUploaded.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import React, { useEffect } from 'react';
import styled from 'styled-components';

import File from '~/core/components/Uploaders/File';
import useFileUpload from '~/core/hooks/useFileUpload';
import { useShallowCompareEffect } from 'react-use';
import { useConfirmContext } from '~/core/providers/ConfirmProvider';

const StylesFileRows = styled.div<{ uploadLoading?: boolean }>`
display: grid;
Expand Down Expand Up @@ -64,7 +65,7 @@ interface FilesProps {
onChange: (data: { uploaded: Array<Amity.File>; uploading: Array<File> }) => void;
onLoadingChange: (loading: boolean) => void;
uploadLoading: boolean;
onError: (error: string) => void;
onError?: (error: string) => void;
rowDataQaAnchor?: string;
}

Expand All @@ -85,7 +86,22 @@ const Files = ({
onError,
});

const { allFiles } = useFileUploadProps;
const { info } = useConfirmContext();

const { allFiles, rejected, reset } = useFileUploadProps;

useEffect(() => {
if (rejected && rejected.length > 0) {
info({
title: 'Error',
content: 'There was an issue uploading file. Please try again later.',
onOk: () => reset(),
okText: 'Discard',
onCancel: () => reset(),
OkButton: undefined,
});
}
}, [rejected]);

if (allFiles.length === 0) return null;

Expand Down
22 changes: 19 additions & 3 deletions src/social/components/post/Creator/components/ImagesUploaded.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import React, { useEffect } from 'react';
import styled, { css } from 'styled-components';

import GalleryGrid from '~/core/components/GalleryGrid';
import Image from '~/core/components/Uploaders/Image';
import useFileUpload, { isAmityFile } from '~/core/hooks/useFileUpload';
import { useConfirmContext } from '~/core/providers/ConfirmProvider';

const StyledGalleryGrid = styled(GalleryGrid)<
{ uploadLoading?: boolean } & React.ComponentProps<typeof GalleryGrid<Amity.File | File>>
Expand Down Expand Up @@ -68,7 +69,7 @@ interface ImagesUploadedProps {
onChange: (data: { uploaded: Array<Amity.File>; uploading: Array<File> }) => void;
onLoadingChange: (loading: boolean) => void;
uploadLoading: boolean;
onError: (error: string) => void;
onError?: (error: string) => void;
}

const ImagesUploaded = ({
Expand All @@ -87,7 +88,22 @@ const ImagesUploaded = ({
onError,
});

const { allFiles } = useFileUploadProps;
const { info } = useConfirmContext();

const { allFiles, rejected, reset } = useFileUploadProps;

useEffect(() => {
if (rejected && rejected.length > 0) {
info({
title: 'Error',
content: 'There was an issue uploading media. Please try again later.',
onOk: () => reset(),
okText: 'Discard',
onCancel: () => reset(),
OkButton: undefined,
});
}
}, [rejected]);

if (allFiles.length === 0) return null;

Expand Down
3 changes: 0 additions & 3 deletions src/social/components/post/Creator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ const PostCreatorBar = ({
setPostImages(uploaded);
setIncomingImages(uploading);
}}
onError={setError}
/>
<VideosUploaded
files={incomingVideos}
Expand All @@ -372,7 +371,6 @@ const PostCreatorBar = ({
setPostVideos(uploaded);
setIncomingVideos(uploading);
}}
onError={setError}
/>
<FilesUploaded
files={incomingFiles}
Expand All @@ -383,7 +381,6 @@ const PostCreatorBar = ({
setPostFiles(uploaded);
setIncomingFiles(uploading);
}}
onError={setError}
/>
</UploadsContainer>
}
Expand Down

0 comments on commit d70ac6d

Please sign in to comment.