Browse Source

add partition key icon in schema page

Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
shanghaikid 2 years ago
parent
commit
6ecd68c82e
3 changed files with 29 additions and 1 deletions
  1. 5 0
      client/src/http/Field.ts
  2. 23 1
      client/src/pages/schema/Schema.tsx
  3. 1 0
      client/src/pages/schema/Types.ts

+ 5 - 0
client/src/http/Field.ts

@@ -7,6 +7,7 @@ export class FieldHttp extends BaseModel implements FieldData {
   fieldID!: string;
   type_params!: { key: string; value: string }[];
   is_primary_key!: true;
+  is_partition_key!: false;
   name!: string;
   description!: string;
   autoID!: boolean;
@@ -35,6 +36,10 @@ export class FieldHttp extends BaseModel implements FieldData {
     return this.is_primary_key;
   }
 
+  get _isPartitionKey() {
+    return this.is_partition_key;
+  }
+
   get _isAutoId() {
     return this.autoID;
   }

+ 23 - 1
client/src/pages/schema/Schema.tsx

@@ -19,6 +19,12 @@ const useStyles = makeStyles((theme: Theme) => ({
     fontSize: '20px',
     marginLeft: theme.spacing(0.5),
   },
+  iconTitle: {
+    fontSize: '8px',
+    position: 'relative',
+    top: '3px',
+    color: 'grey',
+  },
   nameWrapper: {
     display: 'flex',
     alignItems: 'center',
@@ -98,6 +104,7 @@ const Schema: FC<{
   const fetchFields = useCallback(
     async (collectionName: string) => {
       const KeyIcon = icons.key;
+      const PartitionIcon = icons.filter;
 
       try {
         const list = await fetchSchemaListWithIndex(collectionName);
@@ -106,7 +113,22 @@ const Schema: FC<{
             _fieldNameElement: (
               <div className={classes.nameWrapper}>
                 {f._fieldName}
-                {f._isPrimaryKey && <KeyIcon classes={{ root: 'key' }} />}
+                {f._isPrimaryKey && (
+                  <div
+                    className={classes.iconTitle}
+                    title={collectionTrans('idFieldName')}
+                  >
+                    <KeyIcon classes={{ root: 'key' }} />
+                  </div>
+                )}
+                {f.is_partition_key && (
+                  <div
+                    className={classes.iconTitle}
+                    title={collectionTrans('partitionKey')}
+                  >
+                    <PartitionIcon classes={{ root: 'key' }} />
+                  </div>
+                )}
               </div>
             ),
             _indexParamElement: (

+ 1 - 0
client/src/pages/schema/Types.ts

@@ -30,6 +30,7 @@ export interface Field {
 export interface FieldData {
   _fieldId: string;
   _isPrimaryKey: boolean;
+  is_partition_key: boolean;
   _isAutoId: boolean;
   _fieldName: string;
   _fieldNameElement?: ReactElement;