Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: permission verification of some menu is invalid #21

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions web/config/router.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ export default [
name: "alerting",
icon: "alert",
authority: ["alerting"],
isPro: true,
routes: [
{
path: "/alerting/message/:message_id",
Expand Down Expand Up @@ -386,12 +385,17 @@ export default [
"system.credential:read",
"system.security:all",
"system.security:read",
"system.audit_logs:all",
"system.audit_logs:read",
"system.smtp_server:all",
"system.smtp_server:read"
],
routes: [
{
path: "/system/email_server",
name: "email_server",
name: "smtp_server",
component: "./System/Email/Server",
authority: ["system.smtp_server:all", "system.smtp_server:read"],
},
{
path: "/system/credential",
Expand Down
10 changes: 0 additions & 10 deletions web/src/components/SiderMenu/BaseMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { formatMessage } from 'umi/locale';
import pathToRegexp from 'path-to-regexp';
import { urlToList } from '../_utils/pathTools';
import styles from './index.less';
import Pro from '../Icons/Pro';

const { SubMenu } = Menu;

Expand Down Expand Up @@ -89,7 +88,6 @@ export default class BaseMenu extends PureComponent {
<span style={{ display: 'flex', alignItems: 'center'}}>
{getIcon(item.icon)}
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis'}}>{name}</span>
{this.renderProIcon(item)}
</span>
) : (
name
Expand Down Expand Up @@ -140,7 +138,6 @@ export default class BaseMenu extends PureComponent {
<span style={{ display: 'flex', alignItems: 'center'}}>
{icon}
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis'}}>{name}</span>
{this.renderProIcon(item)}
</span>
</Link>
);
Expand All @@ -163,13 +160,6 @@ export default class BaseMenu extends PureComponent {
return `/${path || ''}`.replace(/\/+/g, '/');
};

renderProIcon = (item) => {
if (this.props.collapsed || !item.isPro) return null
return (
<Icon style={{ fontSize: 32, marginLeft: 6 }} component={Pro}/>
)
}

render() {
const {
openKeys,
Expand Down
2 changes: 1 addition & 1 deletion web/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default {
"menu.system.reset_password": "RESET",

"menu.system.credential": "CREDENTIAL",
"menu.system.email_server": "SMTP SERVER",
"menu.system.smtp_server": "SMTP SERVER",

"menu.form": "Form",
"menu.form.basicform": "Basic Form",
Expand Down
4 changes: 2 additions & 2 deletions web/src/locales/en-US/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export default {
"settings.email.server.empty.label1": "You can add mail servers here",
"settings.email.server.empty.label1": "You can add email servers here",
"settings.email.server.empty.label2":
"The alart center can send a notification to the recipient through the designated mail server",
"settings.email.server.empty.button.new": "Add mail server",
"settings.email.server.empty.button.new": "Add email server",
};
2 changes: 1 addition & 1 deletion web/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export default {
"menu.system.reset_password": "重置密码",

"menu.system.credential": "凭据管理",
"menu.system.email_server": "邮件服务器",
"menu.system.smtp_server": "邮件服务器",

"menu.form": "表单页",
"menu.form.basicform": "基础表单",
Expand Down
10 changes: 7 additions & 3 deletions web/src/pages/DataManagement/Discover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import Layout from "./View/Layout";
import request from "@/utils/request";
import { cloneDeep } from "lodash";
import { getTimezone } from "@/utils/utils";
import { hasAuthority } from "@/utils/authority";

const SidebarMemoized = React.memo(DiscoverSidebar);

Expand Down Expand Up @@ -1553,10 +1554,13 @@ const DiscoverUI = (props) => {
The current cluster has no indices or views
</span>
}
image={Empty.PRESENTED_IMAGE_SIMPLE}
>
<Link to={"/data/index"}>
<Button type="primary">Create Now</Button>
</Link>
{hasAuthority("data.index:all") && (
<Link to={"/data/index"}>
<Button type="primary">Create Now</Button>
</Link>
)}
</Empty>
</Card>
)
Expand Down
6 changes: 2 additions & 4 deletions web/src/pages/DataManagement/IndexPatterns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import { ESPrefix } from "@/services/common";
import { formatMessage } from "umi/locale";
import { getAuthority, hasAuthority } from "@/utils/authority";
import EditLayout from "./View/EditLayout";
import { Card, Empty } from "antd";

const IndexPatterns = (props) => {
if (!props.selectedCluster?.id) {
return null;
return <Card ><Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /></Card>;
}
const history = useMemo(() => {
return new ScopedHistory(props.history, "/data/views");
Expand All @@ -45,9 +46,6 @@ const IndexPatterns = (props) => {
};
initFetch();
}, [props.selectedCluster]);
if (!props.selectedCluster?.id) {
return null;
}

return (
<Router history={history}>
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Platform/Overview/Indices/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import Table from "./Table";
import Overview from "@/components/Overview";

const facetLabels = {
"metadata.cluster_name": "cluster",
"metadata.index_name": "index",
"metadata.labels.health_status": "health",
"metadata.labels.state": "state",
};

const aggsParams = [
{ field: "metadata.cluster_name", params: { size: 500 } },
{ field: "metadata.index_name", params: { size: 500 } },
{ field: "metadata.labels.state", params: { size: 100 } },
{ field: "metadata.labels.health_status", params: { size: 150 } },
];
Expand Down
11 changes: 8 additions & 3 deletions web/src/pages/System/Email/Components/EmptyServer.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Empty, Button } from "antd";
import EmailServer from "@/components/Icons/EmailServer";
import { formatMessage } from "umi/locale";
import { hasAuthority } from "@/utils/authority";

export default ({ onAddClick }) => {
const onClick = () => {
Expand All @@ -23,9 +24,13 @@ export default ({ onAddClick }) => {
</div>
}
>
<Button type="primary" onClick={onClick}>
{formatMessage({ id: "settings.email.server.empty.button.new" })}
</Button>
{
hasAuthority("system.smtp_server:all") && (
<Button type="primary" onClick={onClick}>
{formatMessage({ id: "settings.email.server.empty.button.new" })}
</Button>
)
}
</Empty>
);
};
2 changes: 1 addition & 1 deletion web/src/pages/System/Role/Platform/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const menuData = [
key: "system",
children: [
{
key: "system.command",
key: "system.smtp_server",
},
{
key: "system.security",
Expand Down
Loading