mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merge branch 'dev' of https://github.com/umami-software/umami into dev
# Conflicts: # components/messages.js
This commit is contained in:
commit
f84e41e198
15 changed files with 84 additions and 53 deletions
|
|
@ -14,7 +14,7 @@ export const labels = defineMessages({
|
|||
password: { id: 'label.password', defaultMessage: 'Password' },
|
||||
role: { id: 'label.role', defaultMessage: 'Role' },
|
||||
user: { id: 'label.user', defaultMessage: 'User' },
|
||||
admin: { id: 'label.administrator', defaultMessage: 'Administrator' },
|
||||
admin: { id: 'label.admin', defaultMessage: 'Administrator' },
|
||||
confirm: { id: 'label.confirm', defaultMessage: 'Confirm' },
|
||||
details: { id: 'label.details', defaultMessage: 'Details' },
|
||||
websites: { id: 'label.websites', defaultMessage: 'Websites' },
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Button, Dropdown, Form, FormButtons, FormRow, Item, SubmitButton } from
|
|||
import WebsiteTags from './WebsiteTags';
|
||||
import useMessages from 'hooks/useMessages';
|
||||
|
||||
export default function WebsiteAddTeamForm({ teamId, onSave, onClose }) {
|
||||
export default function TeamAddWebsiteForm({ teamId, onSave, onClose }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { get, post, useQuery, useMutation } = useApi();
|
||||
const { mutate, error } = useMutation(data => post(`/teams/${teamId}/websites`, data));
|
||||
|
|
@ -2,18 +2,21 @@ import { Button, Form, FormButtons, SubmitButton } from 'react-basics';
|
|||
import useApi from 'hooks/useApi';
|
||||
import useMessages from 'hooks/useMessages';
|
||||
|
||||
export default function TeamLeaveForm({ teamUserId, teamName, onSave, onClose }) {
|
||||
export default function TeamLeaveForm({ teamId, userId, teamName, onSave, onClose }) {
|
||||
const { formatMessage, labels, messages, FormattedMessage } = useMessages();
|
||||
const { del, useMutation } = useApi();
|
||||
const { mutate, error, isLoading } = useMutation(data => del(`/teamUsers/${teamUserId}`, data));
|
||||
const { mutate, error, isLoading } = useMutation(() => del(`/team/${teamId}/users/${userId}`));
|
||||
|
||||
const handleSubmit = async data => {
|
||||
mutate(data, {
|
||||
onSuccess: async () => {
|
||||
onSave();
|
||||
onClose();
|
||||
const handleSubmit = async () => {
|
||||
mutate(
|
||||
{},
|
||||
{
|
||||
onSuccess: async () => {
|
||||
onSave();
|
||||
onClose();
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ import useApi from 'hooks/useApi';
|
|||
import useMessages from 'hooks/useMessages';
|
||||
import { Icon, Icons, LoadingButton, Text } from 'react-basics';
|
||||
|
||||
export default function TeamMemberRemoveButton({ teamUserId, disabled, onSave }) {
|
||||
export default function TeamMemberRemoveButton({ teamId, userId, disabled, onSave }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { del, useMutation } = useApi();
|
||||
const { mutate, isLoading } = useMutation(() => del(`/teamUsers/${teamUserId}`));
|
||||
const { mutate, isLoading } = useMutation(() => del(`/team/${teamId}/users/${userId}`));
|
||||
|
||||
const handleRemoveTeamMember = () => {
|
||||
mutate(
|
||||
{ teamUserId },
|
||||
{},
|
||||
{
|
||||
onSuccess: () => {
|
||||
onSave();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ export default function TeamMembersTable({ data = [], onSave, readOnly }) {
|
|||
action: !readOnly && (
|
||||
<Flexbox flex={1} justifyContent="end">
|
||||
<TeamMemberRemoveButton
|
||||
teamUserId={row.id}
|
||||
teamId={row.teamId}
|
||||
userId={row.userId}
|
||||
disabled={user.id === row?.user?.id || row.role === ROLES.teamOwner}
|
||||
onSave={onSave}
|
||||
></TeamMemberRemoveButton>
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@ import useApi from 'hooks/useApi';
|
|||
import useMessages from 'hooks/useMessages';
|
||||
import { Icon, Icons, LoadingButton, Text } from 'react-basics';
|
||||
|
||||
export default function TeamWebsiteRemoveButton({ teamWebsiteId, onSave }) {
|
||||
export default function TeamWebsiteRemoveButton({ teamId, websiteId, onSave }) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { del, useMutation } = useApi();
|
||||
const { mutate, isLoading } = useMutation(() => del(`/teamWebsites/${teamWebsiteId}`));
|
||||
const { mutate, isLoading } = useMutation(() => del(`/teams/${teamId}/websites/${websiteId}`));
|
||||
|
||||
const handleRemoveTeamMember = () => {
|
||||
mutate(
|
||||
{ teamWebsiteId },
|
||||
{},
|
||||
{
|
||||
onSuccess: () => {
|
||||
onSave();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from 'react-basics';
|
||||
import EmptyPlaceholder from 'components/common/EmptyPlaceholder';
|
||||
import TeamWebsitesTable from 'components/pages/settings/teams/TeamWebsitesTable';
|
||||
import WebsiteAddTeamForm from 'components/pages/settings/teams/WebsiteAddTeamForm';
|
||||
import TeamAddWebsiteForm from 'components/pages/settings/teams/TeamAddWebsiteForm';
|
||||
import useApi from 'hooks/useApi';
|
||||
import useMessages from 'hooks/useMessages';
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ export default function TeamWebsites({ teamId }) {
|
|||
<Text>{formatMessage(labels.addWebsite)}</Text>
|
||||
</Button>
|
||||
<Modal title={formatMessage(labels.addWebsite)}>
|
||||
{close => <WebsiteAddTeamForm teamId={teamId} onSave={handleSave} onClose={close} />}
|
||||
{close => <TeamAddWebsiteForm teamId={teamId} onSave={handleSave} onClose={close} />}
|
||||
</Modal>
|
||||
</ModalTrigger>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export default function TeamWebsitesTable({ data = [], onSave }) {
|
|||
</TableHeader>
|
||||
<TableBody>
|
||||
{(row, keys, rowIndex) => {
|
||||
const { id: teamWebsiteId } = row;
|
||||
const { teamId } = row;
|
||||
const { id: websiteId, name, domain, userId } = row.website;
|
||||
const { teamUser } = row.team;
|
||||
const owner = teamUser[0];
|
||||
|
|
@ -59,7 +59,8 @@ export default function TeamWebsitesTable({ data = [], onSave }) {
|
|||
</Link>
|
||||
{canRemove && (
|
||||
<TeamWebsiteRemoveButton
|
||||
teamWebsiteId={teamWebsiteId}
|
||||
teamId={teamId}
|
||||
websiteId={websiteId}
|
||||
onSave={onSave}
|
||||
></TeamWebsiteRemoveButton>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,8 @@ export default function TeamsTable({ data = [], onDelete }) {
|
|||
<Modal title={formatMessage(labels.leaveTeam)}>
|
||||
{close => (
|
||||
<TeamLeaveForm
|
||||
teamUserId={teamUserId}
|
||||
teamId={id}
|
||||
userId={user.id}
|
||||
teamName={row.name}
|
||||
onSave={onDelete}
|
||||
onClose={close}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue