mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-21 15:59:48 +01:00
Feature/mirror (#1683)
Add mirror command and extension points. Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com> Co-authored-by: Sebastian Sdorra <sebastian.sdorra@cloudogu.com> Co-authored-by: Konstantin Schaper <konstantin.schaper@cloudogu.com>
This commit is contained in:
86
scm-ui/ui-components/src/forms/FileInput.tsx
Normal file
86
scm-ui/ui-components/src/forms/FileInput.tsx
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React, { ChangeEvent, FC, FocusEvent } from "react";
|
||||
import classNames from "classnames";
|
||||
import LabelWithHelpIcon from "./LabelWithHelpIcon";
|
||||
import { createAttributesForTesting } from "../devBuild";
|
||||
|
||||
type Props = {
|
||||
name?: string;
|
||||
className?: string;
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
helpText?: string;
|
||||
disabled?: boolean;
|
||||
testId?: string;
|
||||
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
||||
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
||||
ref?: React.Ref<HTMLInputElement>;
|
||||
};
|
||||
|
||||
const FileInput: FC<Props> = ({
|
||||
name,
|
||||
testId,
|
||||
helpText,
|
||||
placeholder,
|
||||
disabled,
|
||||
label,
|
||||
className,
|
||||
ref,
|
||||
onBlur,
|
||||
onChange
|
||||
}) => {
|
||||
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
||||
if (onChange && event.target.files) {
|
||||
onChange(event);
|
||||
}
|
||||
};
|
||||
|
||||
const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
|
||||
if (onBlur && event.target.files) {
|
||||
onBlur(event);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={classNames("field", className)}>
|
||||
<LabelWithHelpIcon label={label} helpText={helpText} />
|
||||
<div className="control">
|
||||
<input
|
||||
ref={ref}
|
||||
name={name}
|
||||
className={classNames("input", "p-1", className)}
|
||||
type="file"
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
{...createAttributesForTesting(testId)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FileInput;
|
||||
@@ -56,7 +56,7 @@ export default class TagGroup extends React.Component<Props> {
|
||||
return (
|
||||
<div className="control" key={key}>
|
||||
<div className="tags has-addons">
|
||||
<Tag color="info is-outlined" label={item.displayName} onRemove={() => this.removeEntry(item)} />
|
||||
<Tag color="info" outlined={true} label={item.displayName} onRemove={() => this.removeEntry(item)} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -66,7 +66,7 @@ export default class TagGroup extends React.Component<Props> {
|
||||
}
|
||||
|
||||
removeEntry = (item: DisplayedUser) => {
|
||||
const newItems = this.props.items.filter(name => name !== item);
|
||||
const newItems = this.props.items.filter((name) => name !== item);
|
||||
this.props.onRemove(newItems);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,3 +39,4 @@ export { default as PasswordConfirmation } from "./PasswordConfirmation";
|
||||
export { default as LabelWithHelpIcon } from "./LabelWithHelpIcon";
|
||||
export { default as DropDown } from "./DropDown";
|
||||
export { default as FileUpload } from "./FileUpload";
|
||||
export { default as FileInput } from "./FileInput";
|
||||
|
||||
Reference in New Issue
Block a user