Skip to content

Commit

Permalink
remove user_id in workspace.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sanglevinh committed Jul 28, 2023
1 parent 6d73d31 commit 0bec77a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 38 deletions.
33 changes: 15 additions & 18 deletions frontend/src/components/Database/DatabaseCells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,26 @@ const columns = (handleOpenDialog: (value: string[]) => void) => [
width: 160,
filterable: false,
sortable: false,
renderCell: (params: { row: DatabaseType }) => (
<Box
sx={{
cursor: 'pointer',
display: 'flex',
}}
onClick={() =>
params.row?.cell_image_url &&
handleOpenDialog([params.row.cell_image_url])
}
>
{params.row?.cell_image_url && (
renderCell: (params: { row: DatabaseType }) => {
const { cell_image_url } = params.row
if (!cell_image_url) return null
return (
<Box
sx={{
cursor: 'pointer',
display: 'flex',
}}
onClick={() => handleOpenDialog([cell_image_url])}
>
<img
src={params.row?.cell_image_url}
alt={''}
width={'100%'}
height={'100%'}
/>
)}
</Box>
),
</Box>
)
},
},
]

Expand Down Expand Up @@ -184,16 +183,14 @@ const DatabaseCells = ({ user }: CellProps) => {
)

const handleFilter = (model: GridFilterModel) => {
let filter: string
let filter = ''
if (!!model.items[0]?.value) {
filter = model.items
.filter((item) => item.value)
.map((item: any) => {
return `${item.field}=${item?.value}`
})
.join('&')
} else {
filter = ''
}
const { sort } = dataParams
setParams(
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/components/Database/DatabaseExperiments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,15 @@ const DatabaseExperiments = ({ user, cellPath }: DatabaseProps) => {
[pagiFilter, getParamsData],
)

const handleFilter = (
model: GridFilterModel,
) => {
let filter: string
const handleFilter = (model: GridFilterModel) => {
let filter = ''
if (!!model.items[0]?.value) {
filter = model.items
.filter((item) => item.value)
.map((item: any) => {
return `${item.field}=${item?.value}`
})
.join('&')
} else {
filter = ''
}
const { sort } = dataParams
setParams(
Expand Down
21 changes: 8 additions & 13 deletions frontend/src/pages/Workspace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const columns = (
filterable: false, // todo enable when finish api
sortable: false, // todo enable when finish api
renderCell: (params: GridRenderCellParams<string>) => {
const { row, value } = params
return (
<Box
sx={{
Expand All @@ -95,14 +96,12 @@ const columns = (
textOverflow: 'ellipsis',
}}
>
{params.row.name}
{value}
</span>
{params.row.user_id === user?.id ? (
<IconButton onClick={() => onEdit?.(params.row.id)}>
{row.user?.id === user?.id && (
<IconButton onClick={() => onEdit?.(row.id)}>
<EditIcon style={{ fontSize: 18 }} />
</IconButton>
) : (
''
)}
</Box>
)
Expand Down Expand Up @@ -149,7 +148,7 @@ const columns = (
minWidth: 130,
filterable: false, // todo enable when finish api
sortable: false, // todo enable when finish api
renderCell: (params: GridRenderCellParams<string>) => (
renderCell: (_params: GridRenderCellParams<string>) => (
<LinkCustom to={'#'}>Result</LinkCustom>
),
},
Expand All @@ -172,12 +171,10 @@ const columns = (
filterable: false, // todo enable when finish api
sortable: false, // todo enable when finish api
renderCell: (params: GridRenderCellParams<string>) =>
params.row?.user_id === user?.id ? (
params.row?.user?.id === user?.id && (
<ButtonCustom onClick={handleOpenPopupShare}>
<PeopleOutlineIcon />
</ButtonCustom>
) : (
''
),
},
{
Expand All @@ -187,12 +184,10 @@ const columns = (
filterable: false, // todo enable when finish api
sortable: false, // todo enable when finish api
renderCell: (params: GridRenderCellParams<string>) =>
params.row?.user_id === user?.id ? (
params.row?.user_id === user?.id && (
<ButtonCustom onClick={() => handleOpenPopupDel(params.row.id)}>
Del
</ButtonCustom>
) : (
''
),
},
]
Expand Down Expand Up @@ -444,7 +439,7 @@ const Workspaces = () => {
(page?: number) => {
return `limit=${data.limit}&offset=${page ? page - 1 : data.offset}`
},
[data.limit, data.offset],
[data?.limit, data?.offset],
)

const handlePage = (e: ChangeEvent<unknown>, page: number) => {
Expand Down
1 change: 0 additions & 1 deletion studio/app/common/schemas/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class Workspace(BaseModel):
id: Optional[int]
name: str
user_id: Optional[int]
user: Optional[UserInfo]
created_at: Optional[datetime]
updated_at: Optional[datetime]
Expand Down

0 comments on commit 0bec77a

Please sign in to comment.