Skip to content

Commit

Permalink
feat: update index page
Browse files Browse the repository at this point in the history
mod: code review
  • Loading branch information
hetao92 committed Feb 28, 2022
1 parent 90bbe20 commit 5e92624
Show file tree
Hide file tree
Showing 29 changed files with 733 additions and 154 deletions.
8 changes: 7 additions & 1 deletion app/App.less → app/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
text-align: center;
border: none;
white-space: nowrap;
color: #465b7a;
color: @darkBlue;

&:not(.ant-radio-button-wrapper-checked) {
background: none;
Expand All @@ -70,6 +70,8 @@
.ant-btn.warning-btn {
color: @red;
border-color: @red;
display: inline-flex;
justify-content: center;

svg {
width: 20px;
Expand All @@ -85,6 +87,8 @@
.ant-btn.primary-btn {
color: @blue;
border-color: @blue;
display: inline-flex;
justify-content: center;

svg {
width: 20px;
Expand All @@ -100,6 +104,8 @@
.ant-btn.cancel-btn {
color: @darkGray;
border-color: @darkGray;
display: inline-flex;
justify-content: center;

svg {
width: 20px;
Expand Down
1 change: 1 addition & 0 deletions app/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
@blue: #2F80ED;
@lightGray: #E9EDEF;
@lightBlue: #F3F6F9;
@darkBlue: #465B7A;
3 changes: 2 additions & 1 deletion app/components/Breadcrumb/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '~@app/common.less';
.nebula-breadcrumb {
height: 60px;
background-color: #fff;
Expand Down Expand Up @@ -32,7 +33,7 @@
}
& > span:last-child {
a, span {
color: #465B7A;
color: @darkBlue;
font-weight: 600;
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/components/Instruction/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.icon-instruction {
margin: 0 2px;
color: rgba(140, 140, 140, 1);
}
19 changes: 19 additions & 0 deletions app/components/Instruction/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Tooltip } from 'antd';
import Icon from '@app/components/Icon';
import React from 'react';

import './index.less';

const Instruction = (props: { description: string; onClick?: () => void }) => {
return (
<Tooltip title={props.description} placement="right">
<Icon
type="icon-nav-help"
className="icon-instruction"
onClick={props.onClick}
/>
</Tooltip>
);
};

export default Instruction;
33 changes: 15 additions & 18 deletions app/config/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
"indexType": "Index Type",
"indexName": "Index Name",
"indexFields": "Indexed Properties",
"associateName": "Associated {type} name",
"dragSorting": "(Drag to Sort)",
"selectFields": "Choose Property",
"indexedLength": "Indexed length",
Expand All @@ -346,22 +347,8 @@
"backToEdgeList": "Back to Edge Type List",
"backToIndexList": "Back to Index List",
"leavePage": "Whether to leave the current page?",
"leavePagePrompt": "You have unsaved changes to the record on this tab. If you leave this tab without saving the changes, they will be lost. Are you sure that you want to leave?"
},
"menu": {
"use": "Use Manual",
"release": "New Version",
"forum": "Help Forum",
"nGql": "nGQL"
},
"link": {
"nGQLHref": "https://docs.nebula-graph.io/3.0.0/3.ngql-guide/1.nGQL-overview/1.overview/",
"mannualHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/about-studio/st-ug-what-is-graph-studio/",
"versionLogHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/about-studio/st-ug-release-note/",
"forumLink": "https://discuss.nebula-graph.io/"
},
"_schema": {
"spaceList": "Graph Space List",
"leavePagePrompt": "You have unsaved changes to the record on this tab. If you leave this tab without saving the changes, they will be lost. Are you sure that you want to leave?",
"rebuild": "Rebuild",
"createSpace": "Create Space",
"No": "No",
"spaceName": "Name",
Expand All @@ -374,12 +361,10 @@
"group": "Group",
"comment": "Comment",
"operations": "Operations",
"useSpaceErrTip": "Space not found. Trying to use a newly created graph space may fail because the creation is implemented asynchronously. To make sure the follow-up operations work as expected, Wait for two heartbeat cycles, i.e., 20 seconds.",
"spaceNameEnter": "Please enter the space name",
"propertyCount": "Property Num",
"configTypeList": "{space} {type} List",
"configTypeAction": "{action} {type}",
"defineFields": "Define Properties",
"timestampFormat": "Supported data inserting methods: <br />1. call function now() <br />2. call function timestamp(), for example: timestamp('2021-07-05T06:18:43.984000') <br />3. Input the timestamp directly, namely the number of seconds from 1970-01-01 00:00:00",
"dateFormat": "Supported data inserting methods: <br />Call function date(), for example: date('2021-03-17')",
"timeFormat": "Supported data inserting methods: <br />Call function time(), for example: time('17:53:59')",
Expand All @@ -390,5 +375,17 @@
"geography(polygon)Format": "Supported data inserting methods: <br /> Call function ST_GeogFromText('POLYGON()'), for example:ST_GeogFromText('POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2,2 3,3 3,3 2,2 2))')",
"durationFormat": "Supported data inserting methods: <br /> Call function duration(<map>), for example:duration({years: 1, seconds: 0})",
"setTTL": "Set TTL (Time To Live)"
},
"menu": {
"use": "Use Manual",
"release": "New Version",
"forum": "Help Forum",
"nGql": "nGQL"
},
"link": {
"nGQLHref": "https://docs.nebula-graph.io/3.0.0/3.ngql-guide/1.nGQL-overview/1.overview/",
"mannualHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/about-studio/st-ug-what-is-graph-studio/",
"versionLogHref": "https://docs.nebula-graph.io/3.0.0/nebula-studio/about-studio/st-ug-release-note/",
"forumLink": "https://discuss.nebula-graph.io/"
}
}
33 changes: 15 additions & 18 deletions app/config/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
"indexType": "索引类型",
"indexName": "索引名称",
"indexFields": "索引属性",
"associateName": "关联 {type} 名称",
"dragSorting": "(可拖拽排序)",
"selectFields": "选择关联的属性",
"indexedLength": "索引长度",
Expand All @@ -342,22 +343,8 @@
"backToEdgeList": "返回边类型列表",
"backToIndexList": "返回索引列表",
"leavePage": "是否离开当前页面",
"leavePagePrompt": "离开当前页面后,未保存的记录将丢失"
},
"menu": {
"use": "使用手册",
"release": "新发布",
"forum": "求助论坛",
"nGql": "nGQL"
},
"link": {
"nGQLHref": "https://docs.nebula-graph.com.cn/3.0.0/3.ngql-guide/1.nGQL-overview/1.overview/",
"mannualHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/about-studio/st-ug-what-is-graph-studio/",
"versionLogHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/about-studio/st-ug-release-note/",
"forumLink": "https://discuss.nebula-graph.com.cn/"
},
"_schema": {
"spaceList": "图空间列表",
"leavePagePrompt": "离开当前页面后,未保存的记录将丢失",
"rebuild": "重建索引",
"createSpace": "创建图空间",
"No": "序号",
"spaceName": "名称",
Expand All @@ -370,12 +357,10 @@
"group": "Group",
"comment": "Comment",
"operations": "操作",
"useSpaceErrTip": "图空间未找到。立刻尝试使用刚创建的图空间可能会失败,因为创建是异步实现的。为确保数据同步,后续操作能顺利进行,请等待 2 个心跳周期(20 秒)。",
"spaceNameEnter": "请输入图空间名称",
"propertyCount": "属性数量",
"configTypeList": "{space} {type}列表",
"configTypeAction": "{action}{type}",
"defineFields": "定义属性",
"timestampFormat": "时间类型支持插入方式: <br />1. 调用函数 now() <br />2. 调用函数 timestamp(),例如:timestamp('2021-07-05T06:18:43.984000') <br />3. 直接输入时间戳,即从 1970-01-01 00:00:00 开始的秒数",
"dateFormat": "日期类型支持插入方式: <br /> 调用函数 date(),例如:date('2021-03-17')",
"timeFormat": "时间类型支持插入方式: <br /> 调用函数 time(),例如time('17:53:59')",
Expand All @@ -386,5 +371,17 @@
"geography(polygon)Format": "geo(polygon) 类型支持插入方式: <br /> 调用函数 ST_GeogFromText('POLYGON()'),例如:ST_GeogFromText('POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2,2 3,3 3,3 2,2 2))')",
"durationFormat": "duration 类型支持插入方式: <br /> 调用函数 duration(<map>),例如:duration({years: 1, seconds: 0})",
"setTTL": "设置TTL(存活时间)"
},
"menu": {
"use": "使用手册",
"release": "新发布",
"forum": "求助论坛",
"nGql": "nGQL"
},
"link": {
"nGQLHref": "https://docs.nebula-graph.com.cn/3.0.0/3.ngql-guide/1.nGQL-overview/1.overview/",
"mannualHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/about-studio/st-ug-what-is-graph-studio/",
"versionLogHref": "https://docs.nebula-graph.com.cn/3.0.0/nebula-studio/about-studio/st-ug-release-note/",
"forumLink": "https://discuss.nebula-graph.com.cn/"
}
}
9 changes: 9 additions & 0 deletions app/interfaces/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ export interface IAlterForm {
action: AlterType;
config: IAlterConfig;
}

export enum IJobStatus {
queue = 'QUEUE',
running = 'RUNNING',
finished = 'FINISHED',
failed = 'FAILED',
stopped = 'STOPPED',
removed = 'REMOVED',
}
2 changes: 1 addition & 1 deletion app/pages/Import/TaskCreate/SchemaConfig/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
display: flex;
align-items: center;
font-size: 14px;
color: #465B7A;
color: @darkBlue;
}
.btn-preview {
font-weight: bold;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const PropertiesForm = (props: IProps) => {
<div className="form-item">
<Form.Item name="propertiesRequired" valuePropName="checked" initialValue={true}>
<Checkbox onChange={handleClearProperties}>
<span className="label">{intl.get('_schema.defineFields')}</span>
<span className="label">{intl.get('schema.defineFields')}</span>
</Checkbox>
</Form.Item>
<Form.Item noStyle={true} shouldUpdate={true}>
Expand Down Expand Up @@ -164,7 +164,7 @@ const PropertiesForm = (props: IProps) => {
<Popover
trigger="focus"
placement="right"
content={intl.getHTML(`_schema.${properties[index].type}Format`)}
content={intl.getHTML(`schema.${properties[index].type}Format`)}
>
<Form.Item {...restField} {...itemLayout} name={[name, 'value']}>
<Input />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const formRef = ((props: IProps) => {
<div className="form-item">
<Form.Item name="ttlRequired" valuePropName="checked" initialValue={false}>
<Checkbox onChange={handleClearTtl}>
<span className="label">{intl.get('_schema.setTTL')}</span>
<span className="label">{intl.get('schema.setTTL')}</span>
</Checkbox>
</Form.Item>
<Form.Item noStyle={true} shouldUpdate={true}>
Expand Down
88 changes: 88 additions & 0 deletions app/pages/Schema/SchemaConfig/Create/IndexCreate/DraggableTags.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { Tag } from 'antd';
import React, { Component } from 'react';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';

const reorder = (list: string[], startIndex: number, endIndex: number) => {
const result = Array.from(list);

const [removed] = result.splice(startIndex, 1);

result.splice(endIndex, 0, removed);
return result;
};

const getItemStyle = (_isDragging, draggableStyle) => ({
...draggableStyle,
});

interface IProps {
data: string[];
updateData: (data: string[]) => void;
removeData: (field: string) => void;
}

export default class DraggableTags extends Component<IProps> {
constructor(props) {
super(props);
this.onDragEnd = this.onDragEnd.bind(this);
}

onDragEnd(result) {
if (!result.destination) {
return;
}
// adjust tag order when drop the element
const items: string[] = reorder(
this.props.data,
result.source.index,
result.destination.index,
);
this.props.updateData(items);
}

render() {
const list = this.props.data.map(item => ({
id: `field-${item}`,
content: (
<Tag className="drag-item" closable={true} onClose={() => this.props.removeData(item)}>
{item}
</Tag>
),
}));
return (
<DragDropContext onDragEnd={this.onDragEnd}>
<Droppable droppableId="droppable" direction="horizontal">
{(provided, _snapshot) => (
<div
{...provided.droppableProps}
ref={provided.innerRef}
style={{
display: 'flex',
overflow: 'auto',
}}
>
{list.map((item, index) => (
<Draggable key={item.id} draggableId={item.id} index={index}>
{(provided, snapshot) => (
<div
ref={provided.innerRef}
{...provided.draggableProps}
{...provided.dragHandleProps}
style={getItemStyle(
snapshot.isDragging,
provided.draggableProps.style,
)}
>
{item.content}
</div>
)}
</Draggable>
))}
{provided.placeholder}
</div>
)}
</Droppable>
</DragDropContext>
);
}
}
Loading

0 comments on commit 5e92624

Please sign in to comment.