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

Vue reenable skipped unit tests #4676

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,7 @@ with the exception of `address`, `gender`, `locale`, `picture`, `updated_at`, an
<Fragment useCommonWebContent platforms={['web', 'react-native', 'swift']}>
{({ platform }) => import(`./hidesignup.${platform}.mdx`)}
</Fragment>

<Fragment useCommonWebContent platforms={['swift']}>
{({ platform }) => import(`./totpIssuer.${platform}.mdx`)}
</Fragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## TOTP Issuer

The TOTP issuer is the name that will be shown in TOTP applications preceding the account name. In most cases, this should be the name of your app. For example, if your app is called "My App", your user will see "My App" - "username" in their TOTP app. This can be customized by adding the `totpOptions` argument to the Authenticator component with a value for `issuer`.

Note: Unless changed, the default issuer is the application name retrieved from the project configuration. The key for this value is `CFBundleDisplayName` on iOS found in `info.plist`.

```swift
Authenticator(totpOptions: .init(issuer: "My App")) { _ in
Text("Signed In Content")
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,30 @@ struct CustomSignInView: View {
}

```

### TOTP Setup

You can also customize the TOTP setup experience. We make available arguments in the `ContinueSignInWithTOTPSetupView` i.e. `qrCodeContent` and `copyKeyContent` that can help you provide custom content for the TOTP Setup Experience. In the example below, examine how you could customize the setup screen.

```swift
Authenticator(
continueSignInWithTOTPSetupContent: { state in
ContinueSignInWithTOTPSetupView(
state: state,

// Example of how a customer can pass a custom QR code
qrCodeContent: { state in
// Your custom QR Code implementation goes here

},
copyKeyContent: { state in
// YOUR custom implementation goes here
}
)
},
content: { state in
Text("Signed In Content")
}
)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import awsExports from '@environments/storage/file-uploader/src/aws-exports';
export default awsExports;
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Amplify } from 'aws-amplify';
import { StorageManager } from '@aws-amplify/ui-react-storage';
import '@aws-amplify/ui-react/styles.css';
import awsExports from './aws-exports';
Amplify.configure(awsExports);

export function StorageManagerExample() {
return (
<>
<StorageManager
acceptedFileTypes={['.png']}
accessLevel="public"
maxFileCount={1}
showThumbnails
/>
</>
);
}
export default StorageManagerExample;
6 changes: 3 additions & 3 deletions packages/react-core/src/components/FormCore/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface RegisterFieldParams<Values extends FormValues = FormValues> {

export interface UseFormParams<
Values extends FormValues = FormValues,
OnSubmit extends SubmitHandler<Values> = SubmitHandler<Values>
OnSubmit extends SubmitHandler<Values> = SubmitHandler<Values>,
> {
/**
* Custom error message provided to `Error` on call to `useForm` outside `FormProvider`
Expand Down Expand Up @@ -193,7 +193,7 @@ export interface UseField<Name extends string = string>
export interface UseFieldParams<
OnBlur extends FocusHandler | undefined,
OnChange extends ChangeHandler | undefined,
Values extends FormValues = FormValues
Values extends FormValues = FormValues,
> {
/**
* Controlled `disabled` state
Expand Down Expand Up @@ -252,7 +252,7 @@ export interface UseFieldParams<
*/
export interface UseControlledFieldParams<
OnBlur extends FocusHandler | undefined,
Values extends FormValues = FormValues
Values extends FormValues = FormValues,
> extends Omit<UseFieldParams<OnBlur, undefined, Values>, 'onChange'> {
/**
* Controlled text change event handler
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/components/FormCore/useField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const DEFAULT_ERROR_MESSAGE =
*/
export default function useField<
OnBlur extends FocusHandler,
OnChange extends ChangeHandler
OnChange extends ChangeHandler,
>(params: UseFieldParams<OnBlur, OnChange>): UseField {
const { getFieldState, registerField } = useForm({
errorMessage: DEFAULT_ERROR_MESSAGE,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/components/FormCore/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const DEFAULT_ERROR_MESSAGE =
*/
export default function useForm<
Values extends FormValues = FormValues,
OnSubmit extends SubmitHandler = SubmitHandler
OnSubmit extends SubmitHandler = SubmitHandler,
>(options: UseFormParams<Values, OnSubmit> = {}): UseForm<Values> {
const formContext = useFormContext();
const { errorMessage, onSubmit: _onSubmit } = options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FormHandle, FormProviderProps } from './types';
export default function withFormProvider<
ChildComp extends AnyComponent,
ChildProps extends React.ComponentPropsWithRef<ChildComp>,
Props extends MergeProps<FormProviderProps, ChildProps>
Props extends MergeProps<FormProviderProps, ChildProps>,
>(
Child: ChildComp
): React.ForwardRefExoticComponent<
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/utils/createContextUtilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type CreateContextUtilitiesReturn<ContextType, ContextName extends string> = {
export default function createContextUtilities<
ContextType,
ContextName extends string = string,
Message extends string | undefined = string | undefined
Message extends string | undefined = string | undefined,
>(
options: ContextOptions<ContextType, ContextName, Message>
): CreateContextUtilitiesReturn<ContextType, ContextName> {
Expand Down
7 changes: 7 additions & 0 deletions packages/react-liveness/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @aws-amplify/ui-react-liveness

## 2.0.11

### Patch Changes

- Updated dependencies [[`1dbe3f46c`](https://github.com/aws-amplify/amplify-ui/commit/1dbe3f46c2423c407aa2e499f383745b45b2e640)]:
- @aws-amplify/[email protected]

## 2.0.10

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react-liveness/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@aws-amplify/ui-react-liveness",
"version": "2.0.10",
"version": "2.0.11",
"main": "dist/index.js",
"module": "dist/esm/index.mjs",
"exports": {
Expand Down Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@aws-amplify/ui": "5.8.1",
"@aws-amplify/ui-react": "5.3.1",
"@aws-amplify/ui-react": "5.3.2",
"@aws-sdk/client-rekognitionstreaming": "3.398.0",
"@aws-sdk/util-format-url": "^3.410.0",
"@smithy/eventstream-serde-browser": "^2.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-liveness/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '2.0.10';
export const VERSION = '2.0.11';
7 changes: 7 additions & 0 deletions packages/react-notifications/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @aws-amplify/ui-react-notifications

## 1.0.14

### Patch Changes

- Updated dependencies [[`1dbe3f46c`](https://github.com/aws-amplify/amplify-ui/commit/1dbe3f46c2423c407aa2e499f383745b45b2e640)]:
- @aws-amplify/[email protected]

## 1.0.13

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react-notifications/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/ui-react-notifications",
"version": "1.0.13",
"version": "1.0.14",
"main": "dist/index.js",
"module": "dist/esm/index.mjs",
"exports": {
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@aws-amplify/ui": "5.8.1",
"@aws-amplify/ui-react": "5.3.1",
"@aws-amplify/ui-react": "5.3.2",
"@aws-amplify/ui-react-core-notifications": "1.0.10",
"classnames": "2.3.1",
"tinycolor2": "1.4.2"
Expand Down
11 changes: 11 additions & 0 deletions packages/react-storage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @aws-amplify/ui-react-storage

## 2.3.2

### Patch Changes

- [#4649](https://github.com/aws-amplify/amplify-ui/pull/4649) [`1dbe3f46c`](https://github.com/aws-amplify/amplify-ui/commit/1dbe3f46c2423c407aa2e499f383745b45b2e640) Thanks [@dbanksdesign](https://github.com/dbanksdesign)! - fix(storage): fixing drop handler for file extensions

Previously, adding a file extension for an `acceptedFileTypes` when a customer would drop a file it would show as rejected even if it was a valid file type. This fixes that issue.

- Updated dependencies [[`1dbe3f46c`](https://github.com/aws-amplify/amplify-ui/commit/1dbe3f46c2423c407aa2e499f383745b45b2e640)]:
- @aws-amplify/[email protected]

## 2.3.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react-storage/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/ui-react-storage",
"version": "2.3.1",
"version": "2.3.2",
"main": "dist/index.js",
"module": "dist/esm/index.mjs",
"exports": {
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@aws-amplify/ui": "5.8.1",
"@aws-amplify/ui-react": "5.3.1",
"@aws-amplify/ui-react": "5.3.2",
"@aws-amplify/ui-react-core": "2.1.33",
"classnames": "2.3.1",
"lodash": "4.17.21",
Expand Down
8 changes: 8 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @aws-amplify/ui-react

## 5.3.2

### Patch Changes

- [#4649](https://github.com/aws-amplify/amplify-ui/pull/4649) [`1dbe3f46c`](https://github.com/aws-amplify/amplify-ui/commit/1dbe3f46c2423c407aa2e499f383745b45b2e640) Thanks [@dbanksdesign](https://github.com/dbanksdesign)! - fix(storage): fixing drop handler for file extensions

Previously, adding a file extension for an `acceptedFileTypes` when a customer would drop a file it would show as rejected even if it was a valid file type. This fixes that issue.

## 5.3.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/ui-react",
"version": "5.3.1",
"version": "5.3.2",
"main": "dist/index.js",
"module": "dist/esm/index.mjs",
"exports": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { filterAllowedFiles } from '../filterAllowedFiles';

describe('filterAllowFiles', () => {
const droppedFiles = [
new File([], 'test.jpg', { type: 'image/jpg' }),
new File([], 'test.png', { type: 'image/png' }),
];

it('should work with * MIME types', () => {
const { acceptedFiles, rejectedFiles } = filterAllowedFiles(droppedFiles, [
'image/*',
]);
expect(rejectedFiles).toHaveLength(0);
expect(acceptedFiles).toHaveLength(2);
});

it('should work with extension types', () => {
const { acceptedFiles, rejectedFiles } = filterAllowedFiles(droppedFiles, [
'.png',
]);
expect(rejectedFiles).toHaveLength(1);
expect(acceptedFiles).toHaveLength(1);
});

it('should work with *', () => {
const { acceptedFiles, rejectedFiles } = filterAllowedFiles(droppedFiles, [
'*',
]);
expect(rejectedFiles).toHaveLength(0);
expect(acceptedFiles).toHaveLength(2);
});
});
50 changes: 50 additions & 0 deletions packages/react/src/primitives/DropZone/filterAllowedFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Drag event file shape is different than the drop event fileshape
type DragFile =
| {
kind: string;
type: string;
name?: string;
}
| File;

export function filterAllowedFiles<FileType extends DragFile = DragFile>(
files: FileType[],
acceptedFileTypes: string[]
): { acceptedFiles: FileType[]; rejectedFiles: FileType[] } {
// Allow any files if acceptedFileTypes is undefined, empty array, or contains '*'
if (
!acceptedFileTypes ||
acceptedFileTypes.length === 0 ||
acceptedFileTypes.includes('*')
) {
return { acceptedFiles: files, rejectedFiles: [] };
}
const acceptedFiles: FileType[] = [];
const rejectedFiles: FileType[] = [];

function filterFile(file: DragFile) {
const { type = '', name = '' } = file;
const mimeType = type.toLowerCase();
const baseMimeType = mimeType.split('/')[0];

return acceptedFileTypes.some((type) => {
const validType = type.trim().toLowerCase();
// if the accepted file type is a file extension
// it will start with '.', check against the file name
if (validType.charAt(0) === '.') {
return name.toLowerCase().endsWith(validType);
}
// This is something like a image/* mime type
if (validType.endsWith('/*')) {
return baseMimeType === validType.split('/')[0];
}
return mimeType === validType;
});
}

files.forEach((file) => {
(filterFile(file) ? acceptedFiles : rejectedFiles).push(file);
});

return { acceptedFiles, rejectedFiles };
}
44 changes: 1 addition & 43 deletions packages/react/src/primitives/DropZone/useDropZone.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,7 @@
import { useState } from 'react';
import { UseDropZoneProps, UseDropZoneReturn, DragState } from './types';
import { isFunction } from '@aws-amplify/ui';

type DragFile =
| {
kind: string;
type: string;
}
| File;

function filterAllowedFiles<FileType extends DragFile = DragFile>(
files: FileType[],
acceptedFileTypes: string[]
): { acceptedFiles: FileType[]; rejectedFiles: FileType[] } {
// Allow any files if acceptedFileTypes is undefined, empty array, or contains '*'
if (
!acceptedFileTypes ||
acceptedFileTypes.length === 0 ||
acceptedFileTypes.includes('*')
) {
return { acceptedFiles: files, rejectedFiles: [] };
}
const acceptedFiles: FileType[] = [];
const rejectedFiles: FileType[] = [];

function filterFile({ type = '' }) {
const mimeType = type.toLowerCase();
const baseMimeType = mimeType.split('/')[0];

return acceptedFileTypes.some((type) => {
const validType = type.trim().toLowerCase();
if (validType.endsWith('/*')) {
// This is something like a image/* mime type
return baseMimeType === validType.split('/')[0];
}
return mimeType === validType;
});
}

files.forEach((file) => {
(filterFile(file) ? acceptedFiles : rejectedFiles).push(file);
});

return { acceptedFiles, rejectedFiles };
}
import { filterAllowedFiles } from './filterAllowedFiles';

export function useDropZone({
onDropComplete,
Expand Down
Loading