mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
use reflow to migrate from flow to typescript
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
//@flow
|
||||
import React from "react";
|
||||
import type { User } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
import { Checkbox, MailLink, DateFromNow } from "@scm-manager/ui-components";
|
||||
import React from 'react';
|
||||
import { User } from '@scm-manager/ui-types';
|
||||
import { translate } from 'react-i18next';
|
||||
import { Checkbox, MailLink, DateFromNow } from '@scm-manager/ui-components';
|
||||
|
||||
type Props = {
|
||||
user: User,
|
||||
t: string => string
|
||||
user: User;
|
||||
t: (p: string) => string;
|
||||
};
|
||||
|
||||
class Details extends React.Component<Props> {
|
||||
@@ -16,37 +15,37 @@ class Details extends React.Component<Props> {
|
||||
<table className="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{t("user.name")}</th>
|
||||
<th>{t('user.name')}</th>
|
||||
<td>{user.name}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t("user.displayName")}</th>
|
||||
<th>{t('user.displayName')}</th>
|
||||
<td>{user.displayName}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t("user.mail")}</th>
|
||||
<th>{t('user.mail')}</th>
|
||||
<td>
|
||||
<MailLink address={user.mail} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t("user.active")}</th>
|
||||
<th>{t('user.active')}</th>
|
||||
<td>
|
||||
<Checkbox checked={user.active} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t("user.type")}</th>
|
||||
<th>{t('user.type')}</th>
|
||||
<td>{user.type}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t("user.creationDate")}</th>
|
||||
<th>{t('user.creationDate')}</th>
|
||||
<td>
|
||||
<DateFromNow date={user.creationDate} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t("user.lastModified")}</th>
|
||||
<th>{t('user.lastModified')}</th>
|
||||
<td>
|
||||
<DateFromNow date={user.lastModified} />
|
||||
</td>
|
||||
@@ -57,4 +56,4 @@ class Details extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("users")(Details);
|
||||
export default translate('users')(Details);
|
||||
@@ -1,43 +0,0 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Link } from "react-router-dom";
|
||||
import type { User } from "@scm-manager/ui-types";
|
||||
import { Icon } from "@scm-manager/ui-components";
|
||||
|
||||
type Props = {
|
||||
user: User,
|
||||
|
||||
// context props
|
||||
t: string => string
|
||||
};
|
||||
|
||||
class UserRow extends React.Component<Props> {
|
||||
renderLink(to: string, label: string) {
|
||||
return <Link to={to}>{label}</Link>;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { user, t } = this.props;
|
||||
const to = `/user/${user.name}`;
|
||||
const iconType = user.active ? (
|
||||
<Icon title={t("user.active")} name="user" />
|
||||
) : (
|
||||
<Icon title={t("user.inactive")} name="user-slash" />
|
||||
);
|
||||
|
||||
return (
|
||||
<tr className={user.active ? "border-is-green" : "border-is-yellow"}>
|
||||
<td>{iconType} {this.renderLink(to, user.name)}</td>
|
||||
<td className="is-hidden-mobile">
|
||||
{this.renderLink(to, user.displayName)}
|
||||
</td>
|
||||
<td>
|
||||
<a href={`mailto:${user.mail}`}>{user.mail}</a>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("users")(UserRow);
|
||||
44
scm-ui/ui-webapp/src/users/components/table/UserRow.tsx
Normal file
44
scm-ui/ui-webapp/src/users/components/table/UserRow.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import { translate } from 'react-i18next';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { User } from '@scm-manager/ui-types';
|
||||
import { Icon } from '@scm-manager/ui-components';
|
||||
|
||||
type Props = {
|
||||
user: User;
|
||||
|
||||
// context props
|
||||
t: (p: string) => string;
|
||||
};
|
||||
|
||||
class UserRow extends React.Component<Props> {
|
||||
renderLink(to: string, label: string) {
|
||||
return <Link to={to}>{label}</Link>;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { user, t } = this.props;
|
||||
const to = `/user/${user.name}`;
|
||||
const iconType = user.active ? (
|
||||
<Icon title={t('user.active')} name="user" />
|
||||
) : (
|
||||
<Icon title={t('user.inactive')} name="user-slash" />
|
||||
);
|
||||
|
||||
return (
|
||||
<tr className={user.active ? 'border-is-green' : 'border-is-yellow'}>
|
||||
<td>
|
||||
{iconType} {this.renderLink(to, user.name)}
|
||||
</td>
|
||||
<td className="is-hidden-mobile">
|
||||
{this.renderLink(to, user.displayName)}
|
||||
</td>
|
||||
<td>
|
||||
<a href={`mailto:${user.mail}`}>{user.mail}</a>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default translate('users')(UserRow);
|
||||
@@ -1,12 +1,11 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import UserRow from "./UserRow";
|
||||
import type { User } from "@scm-manager/ui-types";
|
||||
import React from 'react';
|
||||
import { translate } from 'react-i18next';
|
||||
import UserRow from './UserRow';
|
||||
import { User } from '@scm-manager/ui-types';
|
||||
|
||||
type Props = {
|
||||
t: string => string,
|
||||
users: User[]
|
||||
t: (p: string) => string;
|
||||
users: User[];
|
||||
};
|
||||
|
||||
class UserTable extends React.Component<Props> {
|
||||
@@ -16,9 +15,9 @@ class UserTable extends React.Component<Props> {
|
||||
<table className="card-table table is-hoverable is-fullwidth">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="is-hidden-mobile">{t("user.name")}</th>
|
||||
<th>{t("user.displayName")}</th>
|
||||
<th>{t("user.mail")}</th>
|
||||
<th className="is-hidden-mobile">{t('user.name')}</th>
|
||||
<th>{t('user.displayName')}</th>
|
||||
<th>{t('user.mail')}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -31,4 +30,4 @@ class UserTable extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("users")(UserTable);
|
||||
export default translate('users')(UserTable);
|
||||
@@ -1,3 +0,0 @@
|
||||
export { default as Details } from "./Details";
|
||||
export { default as UserRow } from "./UserRow";
|
||||
export { default as UserTable } from "./UserTable";
|
||||
3
scm-ui/ui-webapp/src/users/components/table/index.ts
Normal file
3
scm-ui/ui-webapp/src/users/components/table/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { default as Details } from './Details';
|
||||
export { default as UserRow } from './UserRow';
|
||||
export { default as UserTable } from './UserTable';
|
||||
Reference in New Issue
Block a user