You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/11/17 08:28:53 UTC
[GitHub] [incubator-devlake] mintsweet opened a new pull request, #3750: feat(config-ui): github repo choose to support miller-columns component
mintsweet opened a new pull request, #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750
### Summary
1. miss depends on the **miller-columns** component.
2. support to show column count on the **miller-columns** component.
3. support to flat data on the **miller-columns** component.
4. add some test for the **miller-columns** component.
5. support to scroll load data on the **GitLab** **miller-columns** component.
6. **GitHub** repo choose to support **miller-columns** component.
### Related Issues
#3670
### Screenshots
Nothing.
### Other Information
Nothing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750#discussion_r1024906285
##########
config-ui/src/components/github/miller-columns/use-github-miller-columns.ts:
##########
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { useState, useEffect, useMemo, useCallback } from 'react'
+
+import type { MillerColumnsItem, ItemType } from '@/components/miller-columns'
+import { ItemTypeEnum, ItemStatusEnum } from '@/components/miller-columns'
+import request from '@/components/utils/request'
+
+import { getGitHubProxyApiPrefix } from '../config'
+
+export interface UseGitHubMillerColumnsProps {
+ connectionId: string
+}
+
+export const useGitHubMillerColumns = ({
+ connectionId
+}: UseGitHubMillerColumnsProps) => {
+ const [items, setItems] = useState<Array<MillerColumnsItem>>([])
+
+ const prefix = useMemo(
+ () => getGitHubProxyApiPrefix(connectionId),
+ [connectionId]
+ )
+
+ useEffect(() => {
+ ;(async () => {
+ const user = await request(`${prefix}/user`)
+ const [repos, orgs] = await Promise.all([
+ request(user.repos_url),
+ request(user.organizations_url)
+ ])
+
+ setItems([
+ ...orgs.map((it: any) => ({
+ parentId: null,
+ id: it.id,
+ title: it.login,
+ type: ItemTypeEnum.BRANCH,
+ status: ItemStatusEnum.PENDING
+ })),
+ {
+ parentId: null,
+ id: 'owner',
Review Comment:
show user's login instead of 'owner'? I think it looks more naturally
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750#discussion_r1025113006
##########
config-ui/src/components/github/miller-columns/index.tsx:
##########
@@ -56,13 +56,17 @@ export const GitHubMillerColumns = ({ connectionId, onChangeItems }: Props) => {
return (
<MillerColumns
- height={300}
+ height={50}
Review Comment:
why 30?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] mintsweet commented on a diff in pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
mintsweet commented on code in PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750#discussion_r1025102264
##########
config-ui/src/components/miller-columns/hooks/use-miller-columns.ts:
##########
@@ -62,14 +64,14 @@ export const useMillerColumns = ({
const collectAddParentIds = (item: ItemType) => {
let result: Array<ItemType['id']> = []
- const parentItem = itemMap.getItemParent(item.id)
+ const parentItem = itemMap[item.parentId ?? '']
if (parentItem) {
- const childSelectedIds = parentItem.items
+ const childSelectedIds = (parentItem.items ?? [])
Review Comment:
You're right~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750#discussion_r1024913971
##########
config-ui/src/components/gitlab/miller-columns/index.tsx:
##########
@@ -40,21 +38,14 @@ export const GitLabMillerColumns = ({
}: Props) => {
const [seletedIds, setSelectedIds] = useState<Array<ItemType['id']>>([])
- const { items, itemTree, onExpandItem } = useGitLabMillerColumns<{
- nameWithNameSpace?: string
- }>({
+ const { items, onExpandItem, hasMore, onScroll } = useGitLabMillerColumns({
connectionId
})
- useEffect(() => {
- const curItems = seletedIds
- .filter((id) => itemTree[id].type === ItemTypeEnum.LEAF)
- .map((id) => ({
- id,
- title: itemTree[id].nameWithNameSpace ?? '',
- shortTitle: itemTree[id].title
- }))
+ console.log(items)
Review Comment:
delete debug log
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh merged pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
likyh merged PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750#discussion_r1024938189
##########
config-ui/src/components/miller-columns/hooks/use-miller-columns.ts:
##########
@@ -62,14 +64,14 @@ export const useMillerColumns = ({
const collectAddParentIds = (item: ItemType) => {
let result: Array<ItemType['id']> = []
- const parentItem = itemMap.getItemParent(item.id)
+ const parentItem = itemMap[item.parentId ?? '']
if (parentItem) {
- const childSelectedIds = parentItem.items
+ const childSelectedIds = (parentItem.items ?? [])
Review Comment:
when will `parentItem.items` be empty?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] likyh commented on a diff in pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750#discussion_r1024900131
##########
config-ui/src/components/github/miller-columns/index.tsx:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import React, { useState, useEffect } from 'react'
+
+import type { ItemType } from '@/components/miller-columns'
+import { MillerColumns } from '@/components/miller-columns'
+
+import {
+ useGitHubMillerColumns,
+ UseGitHubMillerColumnsProps
+} from './use-github-miller-columns'
+
+interface Props extends UseGitHubMillerColumnsProps {
+ onChangeItems: (items: Array<Pick<ItemType, 'id' | 'title'>>) => void
+}
+
+export const GitHubMillerColumns = ({ connectionId, onChangeItems }: Props) => {
+ const [seletedIds, setSelectedIds] = useState<Array<ItemType['id']>>([])
+
+ const { items, onExpandItem } = useGitHubMillerColumns({
+ connectionId
+ })
+
+ useEffect(() => {
+ onChangeItems(
+ items
+ .filter((it) => seletedIds.includes(it.id))
+ .map((it) => ({
+ id: it.id,
+ title: it.title
+ }))
+ )
+ }, [seletedIds])
+
+ console.log(items)
Review Comment:
delete debug log
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-devlake] mintsweet commented on a diff in pull request #3750: feat(config-ui): github repo choose to support miller-columns component
Posted by GitBox <gi...@apache.org>.
mintsweet commented on code in PR #3750:
URL: https://github.com/apache/incubator-devlake/pull/3750#discussion_r1025100701
##########
config-ui/src/components/github/miller-columns/use-github-miller-columns.ts:
##########
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { useState, useEffect, useMemo, useCallback } from 'react'
+
+import type { MillerColumnsItem, ItemType } from '@/components/miller-columns'
+import { ItemTypeEnum, ItemStatusEnum } from '@/components/miller-columns'
+import request from '@/components/utils/request'
+
+import { getGitHubProxyApiPrefix } from '../config'
+
+export interface UseGitHubMillerColumnsProps {
+ connectionId: string
+}
+
+export const useGitHubMillerColumns = ({
+ connectionId
+}: UseGitHubMillerColumnsProps) => {
+ const [items, setItems] = useState<Array<MillerColumnsItem>>([])
+
+ const prefix = useMemo(
+ () => getGitHubProxyApiPrefix(connectionId),
+ [connectionId]
+ )
+
+ useEffect(() => {
+ ;(async () => {
+ const user = await request(`${prefix}/user`)
+ const [repos, orgs] = await Promise.all([
+ request(user.repos_url),
+ request(user.organizations_url)
+ ])
+
+ setItems([
+ ...orgs.map((it: any) => ({
+ parentId: null,
+ id: it.id,
+ title: it.login,
+ type: ItemTypeEnum.BRANCH,
+ status: ItemStatusEnum.PENDING
+ })),
+ {
+ parentId: null,
+ id: 'owner',
Review Comment:
Good idea
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org