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

1. Added Constants for the OS type in the whole App 2. Added a regex filter for the AIX OS. 3. Added constants for the STORYBOOK_MODE 4. Removed unecessary closing of with or '||' operator #6640

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mortale2004
Copy link

@mortale2004 mortale2004 commented Apr 10, 2024

Description

In this Pull Request I have done following changes:

  1. Added Constant for the types of OS used in the App. This Object is created for Constant OS Types in the "next.constants.mjs" file by object name as "OS".
  2. Added constants for the STORYBOOK_MODE_THEME. The constants will prevent from typos and we can change the value of it from single place.
  3. Removed unecessary closing of
    with or '||' operator. This can give error in the css styling and unecessary use of or '||' operator.
  4. Added AIX OS in the regex for searching it in the userAgent of the browser. This os was missing in the given regex for finding the current os of the user. This regex will help to find out the current os by using switch case.

Validation

I have tested all issues testing it in the UI also I have tested in the debugger for the validation.

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npx turbo format to ensure the code follows the style guide.
  • I have run npx turbo test to check if all tests are passing.
  • I have run npx turbo build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

@mortale2004 mortale2004 requested a review from a team as a code owner April 10, 2024 14:14
Copy link

vercel bot commented Apr 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Apr 10, 2024 2:16pm

@mortale2004 mortale2004 changed the title Added Constants for the OS type in the whole App 1. Added Constants for the OS type in the whole App 2. Added a regex filter for the AIX OS. 3. Added constants for the STORYBOOK_MODE 4. Removed unecessary closing of with or '||' operator Apr 10, 2024
@@ -1,21 +1,27 @@
// This is a constant object which is used throughout the app for changing the theme type of the storybook
// This object is read only due to the Object.freez so we can go with it because we are not changing its value anymore
export const STORYBOOK_MODE_THEME = Object.freeze({
Copy link
Member

Choose a reason for hiding this comment

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

No need to use Object.freeze, you can use TypeScript as const

@@ -5,9 +5,11 @@ import { useTranslations } from 'next-intl';
import { useTheme } from 'next-themes';
import { useEffect, useState } from 'react';

import { STORYBOOK_MODE_THEME } from '@/.storybook/constants';
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be mixing Storybook constants with Application constants. Make a new set of constants :)

/**
* This are the different types of OS types that are used in the app.
*/
export const OS = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
export const OS = {
export const USER_OS = {

switch (osMatch && osMatch[1]) {
case 'Win':
return 'WIN';
return OS.WIN as UserOS;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing as UserOS here, you can cast the constant to be a Record<UserOS, UserOS> or simply do as const which should be enough,

@@ -13,19 +14,19 @@ export enum OperatingSystem {
export const operatingSystemItems = [
{
label: OperatingSystem.WIN,
value: 'WIN' as UserOS,
value: OS.WIN as UserOS,
Copy link
Member

Choose a reason for hiding this comment

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

No need of as UserOS if the original constant has a type casting

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.

None yet

3 participants