diff --git a/components/dashboard/src/projects/NewProject.tsx b/components/dashboard/src/projects/NewProject.tsx index 25deb4d39df51b..fa6eb74f59e37a 100644 --- a/components/dashboard/src/projects/NewProject.tsx +++ b/components/dashboard/src/projects/NewProject.tsx @@ -14,7 +14,6 @@ import ContextMenu, { ContextMenuEntry } from "../components/ContextMenu"; import CaretDown from "../icons/CaretDown.svg"; import Plus from "../icons/Plus.svg"; import Switch from "../icons/Switch.svg"; -import NoAccess from "../icons/NoAccess.svg"; import search from "../icons/search.svg"; import moment from "moment"; import { UserContext } from "../user-context"; @@ -30,7 +29,6 @@ export default function NewProject() { const [reposInAccounts, setReposInAccounts] = useState([]); const [repoSearchFilter, setRepoSearchFilter] = useState(""); const [selectedAccount, setSelectedAccount] = useState(undefined); - const [noOrgs, setNoOrgs] = useState(false); const [showGitProviders, setShowGitProviders] = useState(false); const [selectedRepo, setSelectedRepo] = useState(undefined); const [selectedTeamOrUser, setSelectedTeamOrUser] = useState(undefined); @@ -147,7 +145,6 @@ export default function NewProject() { return; } (async () => { - updateOrgsState(); await updateReposInAccounts(); })(); }, [selectedProviderHost]); @@ -183,20 +180,6 @@ export default function NewProject() { return []; } - const getToken = async (host: string) => { - return getGitpodService().server.getToken({ host }); - } - - const updateOrgsState = async () => { - if (selectedProviderHost && isGitHub()) { - try { - const ghToken = await getToken(selectedProviderHost); - setNoOrgs(ghToken?.scopes.includes("read:org") !== true); - } catch { - } - } - } - const reconfigure = () => { openReconfigureWindow({ account: selectedAccount, @@ -210,21 +193,6 @@ export default function NewProject() { }); } - const grantReadOrgPermissions = async () => { - try { - await openAuthorizeWindow({ - host: "github.com", - scopes: ["read:org"], - onSuccess: () => { - updateReposInAccounts(); - updateOrgsState(); - } - }) - } catch (error) { - console.log(error); - } - } - const createProject = async (teamOrUser: Team | User, repo: ProviderRepository) => { if (!selectedProviderHost || isBitbucket()) { return; @@ -266,7 +234,15 @@ export default function NewProject() { {label} ) const result: ContextMenuEntry[] = []; - for (const [ account, props ] of accounts.entries()) { + + if (!selectedAccount && user && user.name && user.avatarUrl) { + result.push({ + title: "user", + customContent: renderItemContent(user?.name, user?.avatarUrl), + separator: true, + }) + } + for (const [account, props] of accounts.entries()) { result.push({ title: account, customContent: renderItemContent(account, props.avatarUrl, "font-semibold"), @@ -300,15 +276,24 @@ export default function NewProject() { const showSearchInput = !!repoSearchFilter || filteredRepos.length > 0; const renderRepos = () => (<> - {!isBitbucket() &&

Select a Git repository on {selectedProviderHost}. ( setShowGitProviders(true)}>change)

} -
-
+

Projects allow you to manage prebuilds and workspaces for your repository. Learn more

+

Select account on {selectedProviderHost} ( setShowGitProviders(true)}>change)

+
+
+ {!selectedAccount && ( + <> + + + + )} {icon && ( - + <> + + + )} -
@@ -348,49 +333,35 @@ export default function NewProject() { )} {loaded && noReposAvailable && isGitHub() && (
- -

- No Access -

- Authorize GitHub (github.com) or select a different account. + Additional authorization is required to allow access to your repositories and trigger prebuilds for every new push to any of your branches.
- +
)}
- {isGitHub() && ( - - )} -

- Teams & Projects are currently in Beta. Send feedback or open a New Workspace with an example repository. +

+ Teams & Projects are currently in Beta. Send feedback

); - const renderLoadingState = () => (
-
-
-
-

- Loading ... -

+ const renderLoadingState = () => ( +
+

Projects allow you to manage prebuilds and workspaces for your repository. Learn more

+
+
+
+

+ Loading ... +

+
-
-
) +
) const onGitProviderSeleted = async (host: string, updateUser?: boolean) => { if (updateUser) { @@ -464,7 +435,7 @@ export default function NewProject() {

Bitbucket support for projects is not available yet. Follow #5980 for updates.

-
); +
); } const onNewWorkspace = async () => {