Skip to content

Commit 1e46020

Browse files
committed
fix: members access
1 parent 1e0f8c5 commit 1e46020

File tree

4 files changed

+87
-58
lines changed

4 files changed

+87
-58
lines changed

src/layouts/SettingsLayout/index.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { useTranslation } from "react-i18next";
22

3-
import SidebarLayout from "@/layouts/SidebarLayout";
43
import SidebarMenu from "@/components/SidebarMenu";
54
import type { Location } from "@/hooks/useLocation";
5+
import SidebarLayout from "@/layouts/SidebarLayout";
66
import type { SidebarMenuItem } from "@/mocks/sidebarMenu";
7+
import CurrentUserStore from "@/stores/CurrentUserStore";
8+
import { Roles } from "@/types/team";
79

10+
import AlertsIcon from "@/assets/alert-logs.svg";
811
import DataSourceIcon from "@/assets/data-source.svg";
9-
import SQLAPIIcon from "@/assets/sql-api.svg";
1012
import MembersIcon from "@/assets/members.svg";
11-
import RolesAndAccessIcon from "@/assets/roles-and-access.svg";
1213
import PersonalInfoIcon from "@/assets/personal-info.svg";
13-
import AlertsIcon from "@/assets/alert-logs.svg";
1414
import ReportsIcon from "@/assets/report-logs.svg";
15-
import QueryIcon from "@/assets/query-logs.svg";
16-
import TeamsIcon from "@/assets/team.svg";
15+
import RolesAndAccessIcon from "@/assets/roles-and-access.svg";
1716
import Icon from "@/assets/settings-active.svg";
17+
import SQLAPIIcon from "@/assets/sql-api.svg";
18+
import TeamsIcon from "@/assets/team.svg";
1819

1920
import type { ReactNode } from "react";
2021

@@ -31,6 +32,8 @@ const SettingsLayout: React.FC<SidebarLayoutProps> = ({
3132
}) => {
3233
const { t } = useTranslation(["pages"]);
3334
const splitedPath = (location?.pathname || "").split("/");
35+
const { currentTeam } = CurrentUserStore();
36+
const isMember = currentTeam?.role === Roles.member;
3437
const titleKey = splitedPath?.[2];
3538
const subKey = splitedPath?.[1];
3639

@@ -53,12 +56,13 @@ const SettingsLayout: React.FC<SidebarLayoutProps> = ({
5356
href: "/settings/members",
5457
icon: <MembersIcon />,
5558
},
56-
{
59+
(!isMember && {
5760
key: "roles",
5861
label: t("common:words.roles_and_access"),
5962
href: "/settings/roles",
6063
icon: <RolesAndAccessIcon />,
61-
},
64+
}) ||
65+
null,
6266
{
6367
key: "teams",
6468
label: t("common:words.teams"),
@@ -71,7 +75,7 @@ const SettingsLayout: React.FC<SidebarLayoutProps> = ({
7175
href: "/settings/info",
7276
icon: <PersonalInfoIcon />,
7377
},
74-
];
78+
].filter((item) => !!item?.key);
7579

7680
const singalsMenuItems: SidebarMenuItem[] = [
7781
{

src/pages/DataSources/index.tsx

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -88,42 +88,48 @@ export const DataSources = ({
8888
<Card
8989
title={dataSource.name}
9090
titleTooltip={dataSource.name}
91-
onTitleClick={() => dataSource.id && onEdit(dataSource.id)}
91+
onTitleClick={() =>
92+
!disableCreate && dataSource.id && onEdit(dataSource.id)
93+
}
9294
extra={
93-
<Dropdown
94-
className={styles.btn}
95-
trigger={["click"]}
96-
menu={{
97-
items: [
98-
{
99-
key: "edit",
100-
label: t("common:words.edit"),
101-
onClick: () => dataSource.id && onEdit(dataSource.id),
102-
},
103-
{
104-
key: "generate",
105-
label: t("common:words.generate_models"),
106-
onClick: () =>
107-
dataSource.id && onGenerateModel(dataSource.id),
108-
},
109-
{
110-
key: "delete",
111-
className: styles.deleteItem,
112-
label: (
113-
<ConfirmModal
114-
title={t("common:words.delete_datasource")}
115-
className={styles.deleteText}
116-
onConfirm={() => dataSource.id && onDelete(dataSource.id)}
117-
>
118-
{t("common:words.delete")}
119-
</ConfirmModal>
120-
),
121-
},
122-
],
123-
}}
124-
>
125-
<SettingOutlined key="setting" />
126-
</Dropdown>
95+
!disableCreate && (
96+
<Dropdown
97+
className={styles.btn}
98+
trigger={["click"]}
99+
menu={{
100+
items: [
101+
{
102+
key: "edit",
103+
label: t("common:words.edit"),
104+
onClick: () => dataSource.id && onEdit(dataSource.id),
105+
},
106+
{
107+
key: "generate",
108+
label: t("common:words.generate_models"),
109+
onClick: () =>
110+
dataSource.id && onGenerateModel(dataSource.id),
111+
},
112+
{
113+
key: "delete",
114+
className: styles.deleteItem,
115+
label: (
116+
<ConfirmModal
117+
title={t("common:words.delete_datasource")}
118+
className={styles.deleteText}
119+
onConfirm={() =>
120+
dataSource.id && onDelete(dataSource.id)
121+
}
122+
>
123+
{t("common:words.delete")}
124+
</ConfirmModal>
125+
),
126+
},
127+
],
128+
}}
129+
>
130+
<SettingOutlined key="setting" />
131+
</Dropdown>
132+
)
127133
}
128134
>
129135
<dl>

src/pages/Members/index.module.less

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,26 @@
77
}
88

99
.removeBtn {
10-
padding: 0;
11-
color: var(--color-primary);
10+
display: flex;
11+
gap: 10px;
12+
align-items: center;
13+
padding: 5px !important;
14+
color: rgba(0, 0, 0, 0.5);
15+
font-weight: 700;
16+
font-size: 9px;
17+
1218
span {
13-
font-size: 12px;
19+
font-weight: 700;
20+
font-size: 9px;
21+
}
22+
23+
&:hover {
24+
color: black;
25+
background: rgba(163, 27, 203, 0.1) !important;
26+
27+
path {
28+
stroke: rgba(163, 27, 203, 1);
29+
}
1430
}
1531
}
1632

src/pages/Members/index.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1+
import { useParams } from "@vitjs/runtime";
12
import { Col, Row, Select, Space, Spin, Tag, Typography, message } from "antd";
23
import { useTranslation } from "react-i18next";
3-
import { useParams } from "@vitjs/runtime";
44

5+
import Avatar from "@/components/Avatar";
6+
import Button from "@/components/Button";
7+
import Card from "@/components/Card";
8+
import ConfirmModal from "@/components/ConfirmModal";
59
import type { Invite } from "@/components/MembersForm";
610
import MembersForm from "@/components/MembersForm";
7-
import Card from "@/components/Card";
8-
import Avatar from "@/components/Avatar";
911
import Modal from "@/components/Modal";
10-
import PageHeader from "@/components/PageHeader";
11-
import ConfirmModal from "@/components/ConfirmModal";
1212
import NoMember from "@/components/NoMember";
13-
import Button from "@/components/Button";
14-
import formatTime from "@/utils/helpers/formatTime";
15-
import { createRoleOptions } from "@/utils/helpers/createRoleOptions";
16-
import { capitalize } from "@/utils/helpers/capitalize";
13+
import PageHeader from "@/components/PageHeader";
1714
import type {
1815
AllAccessListsQuery,
1916
Member_Roles_Set_Input,
@@ -26,12 +23,16 @@ import {
2623
useUpdateMemberRoleMutation,
2724
} from "@/graphql/generated";
2825
import useCheckResponse from "@/hooks/useCheckResponse";
26+
import useLocation from "@/hooks/useLocation";
2927
import CurrentUserStore from "@/stores/CurrentUserStore";
3028
import type { AccessList, Member } from "@/types/team";
3129
import { ChangeableRoles, Roles } from "@/types/team";
32-
import useLocation from "@/hooks/useLocation";
3330
import { MEMBERS } from "@/utils/constants/paths";
31+
import { capitalize } from "@/utils/helpers/capitalize";
32+
import { createRoleOptions } from "@/utils/helpers/createRoleOptions";
33+
import formatTime from "@/utils/helpers/formatTime";
3434

35+
import TrashColoredIcon from "@/assets/trash-colored.svg";
3536
import TrashIcon from "@/assets/trash.svg";
3637

3738
import styles from "./index.module.less";
@@ -109,7 +110,9 @@ export const Members: React.FC<MembersProps> = ({
109110
title={t("common:words.delete_member")}
110111
onConfirm={() => onRemove(member)}
111112
>
112-
<Button className={styles.removeBtn} ghost icon={<TrashIcon />} />
113+
<Button size="small" type="text" className={styles.removeBtn}>
114+
<TrashColoredIcon />
115+
</Button>
113116
</ConfirmModal>
114117
)
115118
}

0 commit comments

Comments
 (0)