Skip to content
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

Mismatch version modal and toast #120

Merged
merged 2 commits into from
Jan 23, 2023
Merged

Mismatch version modal and toast #120

merged 2 commits into from
Jan 23, 2023

Conversation

NicholasLin718
Copy link
Contributor

Issue 23

Added a useEffect such that when the dashboard loads, there will be a comparison between the core and dashboard versions. A major version difference will cause a modal to pop up, otherwise, a toast will pop up.

@netlify
Copy link

netlify bot commented Jan 22, 2023

Deploy Preview for lodestone-dashboard ready!

Name Link
🔨 Latest commit d10f268
🔍 Latest deploy log https://app.netlify.com/sites/lodestone-dashboard/deploys/63cdc786b38a4b000865ce70
😎 Deploy Preview https://deploy-preview-120--lodestone-dashboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Ynng Ynng linked an issue Jan 23, 2023 that may be closed by this pull request
@Ynng
Copy link
Member

Ynng commented Jan 23, 2023

Please manually link the issue using the side bar.
Auto linking using keyword (for example "closes") only works on pr to main https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

@NicholasLin718 NicholasLin718 merged commit 5cf03fa into 0.4.1 Jan 23, 2023
const [showMajorVersionModal, setShowMajorVersionModal] = useState(false);
const [dashboardVersion, setDashboardVersion] = useState(packageinfo.version);
const [coreVersion, setCoreVersion] = useState('');
const openMajorVersionModal = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this named "open..."
it's a little confusing between openMajorVersionModal and showMajorVersionModal
maybe just versionMismatchModal ?

);

useEffect(() => {
const endpoint = `http://localhost:${LODESTONE_PORT}/api/v1/info`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

axios has http://something: port/api/v1set as the base url already, so you only need the /info part
Also, consider using the useCoreInfo hook

axios.get(endpoint).then((result) => {
if (!result.data) return;
setCoreVersion(result.data.version);
const tempDashboardVersion = dashboardVersion.split('.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using a semver library to parse the version instead https://www.npmjs.com/package/semver

if (tempDashboardVersion[0] !== tempCoreVersion[0]) {
setShowMajorVersionModal(true);
} else {
toast.warn('There is a minor/patch version mismatch!');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe make the toast more specific. is it a minor or patch version?
what's the version of the dashboard, what's the version of the core.

@Ynng Ynng deleted the mismatchVersion branch January 24, 2023 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn about mismatched dashboard and core version
2 participants