Skip to content

Commit

Permalink
[#1665] improve(web): modified favicon and define custom toast (#1800)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Modify favicon and define custom toast.

![image](https://github.com/datastrato/gravitino/assets/17310559/3b7ee6b4-fe54-4bf8-be65-f7584aba1ef0)

![image](https://github.com/datastrato/gravitino/assets/17310559/6c4d9944-0574-4fee-a961-b13b6f638f9b)


### Why are the changes needed?

Fix: #1665

### Does this PR introduce _any_ user-facing change?

N/A

### How was this patch tested?

N/A
  • Loading branch information
ch3yne authored Jan 31, 2024
1 parent 7e2fa2a commit f4b9d1c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
9 changes: 6 additions & 3 deletions web/app/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ import Layout from '@/lib/layout/Layout'

import Loading from '@/lib/layout/Loading'

import { Toaster } from 'react-hot-toast'
import StyledToast from '../components/StyledToast'

export const metadata = {
title: 'Gravitino',
description: 'A high-performance, geo-distributed and federated metadata lake.'
description: 'A high-performance, geo-distributed and federated metadata lake.',
icons: {
icon: '/icons/gravitino.svg'
}
}

const RootLayout = props => {
Expand All @@ -33,7 +36,7 @@ const RootLayout = props => {
<Layout>{children}</Layout>
</Suspense>
</Provider>
<Toaster position='top-right' />
<StyledToast />
</body>
</html>
)
Expand Down
47 changes: 47 additions & 0 deletions web/components/StyledToast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/

'use client'

import { toast, ToastBar, Toaster } from 'react-hot-toast'

export default function StyledToast() {
return (
<div>
<Toaster
reverseOrder={false}
position='top-right'
toastOptions={{
duration: Infinity,
style: {
borderRadius: '8px',
maxWidth: 500
}
}}
>
{t => (
<ToastBar toast={t}>
{({ icon, message }) => (
<>
{icon}
<div className='twc-flex twc-w-full twc-break-all [&>div]:twc-justify-start'>{message}</div>
<div className='twc-flex twc-h-full'>
{t.type !== 'loading' && (
<button
className='twc-border-0 twc-text-[#666] twc-w-6 twc-h-6 twc-justify-start twc-rounded-full twc-ring-primary-400 twc-transition hover:twc-bg-[#f8f8f8] focus:twc-outline-none focus-visible:twc-ring'
onClick={() => toast.dismiss(t.id)}
>
x
</button>
)}
</div>
</>
)}
</ToastBar>
)}
</Toaster>
</div>
)
}
7 changes: 7 additions & 0 deletions web/lib/utils/axios/checkStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ export function checkStatus(status: number, msg: string, errorMessageMode: Error
if (errorMessageMode === 'modal') {
console.log({ title: 'Error Tip', text: errMessage, icon: 'error' })
} else if (errorMessageMode === 'message') {
const keyword = 'reason'
const idx = errMessage.indexOf(keyword)

if (idx !== -1) {
errMessage = 'reason ' + errMessage.substring(idx + keyword.length + 1)
}

toast.error(errMessage, { id: `global_error_message_status_${status}` })
}
}
Expand Down

0 comments on commit f4b9d1c

Please sign in to comment.