How to use the @codesandbox/notifications.NotificationStatus.ERROR function in @codesandbox/notifications

To help you get started, we’ve selected a few @codesandbox/notifications examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github codesandbox / codesandbox-client / packages / app / src / embed / components / Content / Monaco / define-theme.js View on Github external
try {
      monaco.editor.defineTheme('CodeSandbox', {
        base: getBase(transformedTheme.type),
        inherit: true,
        colors: transformedTheme.colors,
        rules: transformedTheme.rules,
      });

      monaco.editor.setTheme('CodeSandbox');
    } catch (e) {
      console.error(e);

      notificationState.addNotification({
        message: `Problem initializing template in editor: ${e.message}`,
        status: NotificationStatus.ERROR,
      });
    }
  }
};
github codesandbox / codesandbox-client / packages / app / src / app / pages / Sandbox / Editor / utils / get-vscode-theme.js View on Github external
.then(text => {
      let theme;
      try {
        theme = parseTheme(text);
      } catch (e) {
        console.error(e);

        notificationState.addNotification({
          message: 'We had trouble loading the theme, error: \n' + e.message,
          status: NotificationStatus.ERROR,
        });
      }
      return theme;
    });
}
github codesandbox / codesandbox-client / packages / app / src / app / pages / Sandbox / Editor / utils / get-vscode-theme.js View on Github external
const findTheme = async (themeName, customTheme) => {
  if (customTheme) {
    try {
      return parseTheme(customTheme);
    } catch (e) {
      console.error(e);

      notificationState.addNotification({
        message:
          'We had trouble parsing your custom VSCode Theme, error: \n' +
          e.message,
        status: NotificationStatus.ERROR,
      });
    }
  }

  const foundTheme = themes.find(t => t.name === themeName);

  const fetchedTheme = await fetchTheme(foundTheme);

  return {
    ...fetchedTheme,
    type: (foundTheme && foundTheme.type) || fetchedTheme.type,
  };
};
github codesandbox / codesandbox-client / packages / app / src / app / pages / index.tsx View on Github external
path="/"
        render={({ location }) => {
          if (process.env.NODE_ENV === 'production') {
            routeDebugger(
              `Sending '${location.pathname + location.search}' to analytics.`
            );
            if (!DNT) {
              trackPageview();
            }
          }
          return null;
        }}
      />
      
      
        <content>
          </content>
github codesandbox / codesandbox-client / packages / app / src / app / overmind / internalActions.ts View on Github external
},
    });
  } else if (
    error.message.startsWith(
      'You reached the limit of server sandboxes, we will increase the limit in the future. Please contact hello@codesandbox.io for more server sandboxes.'
    )
  ) {
    effects.analytics.track('Patron Server Sandbox Limit Reached', {
      errorMessage: error.message,
    });
  }

  effects.notificationToast.add({
    title: message,
    message: error.message,
    status: NotificationStatus.ERROR,
    ...(notificationActions.primary.length
      ? { actions: notificationActions }
      : {}),
  });
};
github codesandbox / codesandbox-client / packages / app / src / app / graphql / client.ts View on Github external
const errorHandler = onError(({ graphQLErrors, networkError }) => {
  if (graphQLErrors) {
    graphQLErrors.forEach(({ message }) => {
      notificationState.addNotification({
        message,
        status: NotificationStatus.ERROR,
      });
    });
  }

  if (networkError) {
    notificationState.addNotification({
      message: `Network Error: ${networkError}`,
      status: NotificationStatus.ERROR,
    });
  }
});
github codesandbox / codesandbox-client / packages / common / src / utils / notifications.ts View on Github external
export function convertTypeToStatus(
  type: NotificationType
): NotificationStatus {
  switch (type) {
    case 'notice':
      return NotificationStatus.NOTICE;
    case 'warning':
      return NotificationStatus.WARNING;
    case 'error':
      return NotificationStatus.ERROR;
    case 'success':
      return NotificationStatus.SUCCESS;
    default:
      return NotificationStatus.NOTICE;
  }
}
github codesandbox / codesandbox-client / packages / app / src / app / store / providers / Api.js View on Github external
primary: [
          {
            label: 'Sign in',
            run: () => {
              controller.getSignal('signInClicked')({});
            },
          },
        ],
      },
    });
  } else if (errorMessage.startsWith('You reached the maximum of')) {
    track('Non-Patron Sandbox Limit Reached', { errorMessage });

    notificationState.addNotification({
      title: errorMessage,
      status: NotificationStatus.ERROR,
      actions: {
        primary: [
          {
            label: 'Open Patron Page',
            run: () => {
              window.open(patronUrl(), '_blank');
            },
          },
        ],
      },
    });
  } else if (
    errorMessage.startsWith(
      'You reached the limit of server sandboxes, you can create more server sandboxes as a patron.'
    )
  ) {
github codesandbox / codesandbox-client / packages / app / src / app / store / modules / server / actions.js View on Github external
export function showContainerError({ props }) {
  if (props.unrecoverable) {
    notificationState.addNotification({
      title: `Container Error`,
      message: props.error,
      status: NotificationStatus.ERROR,
    });
  } else {
    notificationState.addNotification({
      title: `Container Warning`,
      message: props.error,
      status: NotificationStatus.WARNING,
    });
  }
}