mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
use Tag component instead
This commit is contained in:
@@ -1,10 +1,18 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Change, Diff as DiffComponent, DiffObjectProps, File, getChangeKey, Hunk} from "react-diff-view";
|
import {
|
||||||
|
Change,
|
||||||
|
Diff as DiffComponent,
|
||||||
|
DiffObjectProps,
|
||||||
|
File,
|
||||||
|
getChangeKey,
|
||||||
|
Hunk
|
||||||
|
} from "react-diff-view";
|
||||||
import injectSheets from "react-jss";
|
import injectSheets from "react-jss";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { Button, ButtonGroup } from "../buttons";
|
import { Button, ButtonGroup } from "../buttons";
|
||||||
|
import Tag from "../Tag";
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
panel: {
|
panel: {
|
||||||
@@ -183,24 +191,18 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
value = file.type;
|
value = file.type;
|
||||||
}
|
}
|
||||||
const color =
|
const color =
|
||||||
value === "added"
|
value === "added" ? "success" : value === "deleted" ? "danger" : "info";
|
||||||
? "is-success"
|
|
||||||
: value === "deleted"
|
|
||||||
? "is-danger"
|
|
||||||
: "is-info";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<Tag
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"tag",
|
|
||||||
"is-rounded",
|
"is-rounded",
|
||||||
"has-text-weight-normal",
|
"has-text-weight-normal",
|
||||||
color,
|
|
||||||
classes.changeType
|
classes.changeType
|
||||||
)}
|
)}
|
||||||
>
|
color={color}
|
||||||
{value}
|
label={value}
|
||||||
</span>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ type Props = {
|
|||||||
class ChangesetTag extends React.Component<Props> {
|
class ChangesetTag extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { tag } = this.props;
|
const { tag } = this.props;
|
||||||
return <ChangesetTagBase icon={"fa-tag"} label={tag.name} />;
|
return <ChangesetTagBase icon="tag" label={tag.name} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,19 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import injectSheet from "react-jss";
|
import Tag from "../../Tag";
|
||||||
import classNames from "classnames";
|
|
||||||
|
|
||||||
const styles = {
|
|
||||||
spacing: {
|
|
||||||
marginRight: ".25rem"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
icon: string,
|
icon: string,
|
||||||
label: string,
|
label: string
|
||||||
|
|
||||||
// context props
|
|
||||||
classes: Object
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChangesetTagBase extends React.Component<Props> {
|
class ChangesetTagBase extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { icon, label, classes } = this.props;
|
const { icon, label } = this.props;
|
||||||
return (
|
return (
|
||||||
<span className={classNames("tag", "is-info")}>
|
<Tag color="info" icon={icon} label={label} />
|
||||||
<span className={classNames("fa", icon, classes.spacing)} /> {label}
|
|
||||||
</span>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default injectSheet(styles)(ChangesetTagBase);
|
export default ChangesetTagBase;
|
||||||
|
|||||||
@@ -1,24 +1,27 @@
|
|||||||
//@flow
|
//@flow
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import type { Tag } from "@scm-manager/ui-types";
|
|
||||||
import ChangesetTagBase from "./ChangesetTagBase";
|
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
|
import type { Tag } from "@scm-manager/ui-types";
|
||||||
import Tooltip from "../../Tooltip";
|
import Tooltip from "../../Tooltip";
|
||||||
|
import ChangesetTagBase from "./ChangesetTagBase";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
tags: Tag[],
|
tags: Tag[],
|
||||||
|
|
||||||
// context props
|
// context props
|
||||||
t: (string) => string
|
t: string => string
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChangesetTagsCollapsed extends React.Component<Props> {
|
class ChangesetTagsCollapsed extends React.Component<Props> {
|
||||||
render() {
|
render() {
|
||||||
const { tags, t } = this.props;
|
const { tags, t } = this.props;
|
||||||
const message = tags.map((tag) => tag.name).join(", ");
|
const message = tags.map(tag => tag.name).join(", ");
|
||||||
return (
|
return (
|
||||||
<Tooltip location="top" message={message}>
|
<Tooltip location="top" message={message}>
|
||||||
<ChangesetTagBase icon={"fa-tags"} label={ tags.length + " " + t("changeset.tags") } />
|
<ChangesetTagBase
|
||||||
|
icon="tags"
|
||||||
|
label={tags.length + " " + t("changeset.tags")}
|
||||||
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user