-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[dashboard] display warning for latest IDE versions #8783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
import { useState } from "react"; | ||
import { ReactComponent as Exclamation } from "../images/exclamation.svg"; | ||
import { ReactComponent as Exclamation2 } from "../images/exclamation2.svg"; | ||
import { ReactComponent as InfoSvg } from "../images/info.svg"; | ||
import { ReactComponent as XSvg } from "../images/x.svg"; | ||
|
||
export type AlertType = | ||
// Yellow | ||
| "warning" | ||
// Gray alert | ||
| "info" | ||
// Red | ||
| "error" | ||
// Blue | ||
| "message"; | ||
Comment on lines
+13
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: Thanks so much for adding the alert component, @mustard-mh! 🔝 FWIW, we also have #7613 to tackle this component separately and also a few similar components that we could deprecate in favor of this, see AlertBox and InfoBox. However deprecating those other component could be tackled separately. |
||
|
||
export interface AlertProps { | ||
className?: string; | ||
type?: AlertType; | ||
// Without background color, default false | ||
light?: boolean; | ||
closable?: boolean; | ||
showIcon?: boolean; | ||
icon?: React.ReactNode; | ||
children?: React.ReactNode; | ||
} | ||
|
||
interface AlertInfo { | ||
bgCls: string; | ||
txtCls: string; | ||
icon: React.ReactNode; | ||
iconColor?: string; | ||
} | ||
|
||
const infoMap: Record<AlertType, AlertInfo> = { | ||
warning: { | ||
bgCls: "bg-yellow-100 dark:bg-yellow-700", | ||
txtCls: "text-yellow-600 dark:text-yellow-50", | ||
icon: <Exclamation2 className="w-4 h-4"></Exclamation2>, | ||
iconColor: "text-yellow-400 dark:text-yellow-900", | ||
}, | ||
info: { | ||
bgCls: "bg-gray-100 dark:bg-gray-700", | ||
txtCls: "text-gray-500 dark:text-gray-300", | ||
icon: <InfoSvg className="w-4 h-4"></InfoSvg>, | ||
iconColor: "text-gray-400", | ||
}, | ||
message: { | ||
bgCls: "bg-blue-50 dark:bg-blue-700", | ||
txtCls: "text-blue-800 dark:text-blue-100", | ||
icon: <InfoSvg className="w-4 h-4"></InfoSvg>, | ||
iconColor: "text-blue-400", | ||
}, | ||
error: { | ||
bgCls: "bg-red-50 dark:bg-red-800 dark:bg-opacity-50", | ||
txtCls: "text-red-600 dark:text-red-200", | ||
icon: <Exclamation className="w-4 h-4"></Exclamation>, | ||
iconColor: "text-red-400", | ||
}, | ||
}; | ||
|
||
export default function Alert(props: AlertProps) { | ||
const [visible, setVisible] = useState(true); | ||
if (!visible) { | ||
return null; | ||
} | ||
const type: AlertType = props.type ?? "info"; | ||
const info = infoMap[type]; | ||
const showIcon = props.showIcon ?? true; | ||
gtsiolis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const light = props.light ?? false; | ||
return ( | ||
<div className={`flex relative rounded p-4 ${info.txtCls} ${props.className || ""} ${light ? "" : info.bgCls}`}> | ||
{showIcon && <span className={`mt-1 mr-4 h-4 w-4 ${info.iconColor}`}>{props.icon ?? info.icon}</span>} | ||
<span className="flex-1 text-left">{props.children}</span> | ||
{props.closable && ( | ||
mustard-mh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<XSvg onClick={() => setVisible(false)} className="mt-1 ml-4 w-3 h-3 cursor-pointer"></XSvg> | ||
)} | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
export interface SelectableCardSolidProps { | ||
title: string; | ||
selected: boolean; | ||
className?: string; | ||
onClick: () => void; | ||
children?: React.ReactNode; | ||
} | ||
|
||
function SelectableCardSolid(props: SelectableCardSolidProps) { | ||
return ( | ||
<div | ||
className={`rounded-xl px-3 py-3 flex flex-col cursor-pointer group transition ease-in-out ${ | ||
props.selected | ||
? "bg-gray-800 dark:bg-gray-100" | ||
: "bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700" | ||
} ${props.className || ""}`} | ||
onClick={props.onClick} | ||
> | ||
<div className="flex items-center"> | ||
<p | ||
className={`w-full pl-1 text-base font-semibold truncate ${ | ||
props.selected ? "text-gray-100 dark:text-gray-600" : "text-gray-600 dark:text-gray-500" | ||
}`} | ||
title={props.title} | ||
> | ||
{props.title} | ||
</p> | ||
<input className="opacity-0" type="radio" checked={props.selected} /> | ||
</div> | ||
{props.children} | ||
</div> | ||
); | ||
} | ||
|
||
export default SelectableCardSolid; |
Uh oh!
There was an error while loading. Please reload this page.