mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 11:59:11 +00:00
chore: move src/common/utils to @roleypoly/misc-utils
This commit is contained in:
parent
a374030438
commit
65a8760e86
36 changed files with 38 additions and 465 deletions
|
@ -6,6 +6,7 @@
|
||||||
"start": "yarn workspace @roleypoly/worker-emulator start --basePath `pwd`"
|
"start": "yarn workspace @roleypoly/worker-emulator start --basePath `pwd`"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@roleypoly/misc-utils": "*",
|
||||||
"@roleypoly/types": "*",
|
"@roleypoly/types": "*",
|
||||||
"@roleypoly/worker-emulator": "*",
|
"@roleypoly/worker-emulator": "*",
|
||||||
"ksuid": "^2.0.0",
|
"ksuid": "^2.0.0",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { SessionData, UserGuildPermissions } from '@roleypoly/types';
|
|
||||||
import {
|
import {
|
||||||
evaluatePermission,
|
evaluatePermission,
|
||||||
permissions as Permissions,
|
permissions as Permissions,
|
||||||
} from '../../../src/common/utils/hasPermission';
|
} from '@roleypoly/misc-utils/hasPermission';
|
||||||
|
import { SessionData, UserGuildPermissions } from '@roleypoly/types';
|
||||||
import { Handler } from '../router';
|
import { Handler } from '../router';
|
||||||
import { rootUsers, uiPublicURI } from './config';
|
import { rootUsers, uiPublicURI } from './config';
|
||||||
import { Sessions, WrappedKVNamespace } from './kv';
|
import { Sessions, WrappedKVNamespace } from './kv';
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { evaluatePermission, permissions } from '@roleypoly/misc-utils/hasPermission';
|
||||||
import {
|
import {
|
||||||
Features,
|
Features,
|
||||||
Guild,
|
Guild,
|
||||||
|
@ -6,7 +7,6 @@ import {
|
||||||
Role,
|
Role,
|
||||||
RoleSafety,
|
RoleSafety,
|
||||||
} from '@roleypoly/types';
|
} from '@roleypoly/types';
|
||||||
import { evaluatePermission, permissions } from '../../../src/common/utils/hasPermission';
|
|
||||||
import { AuthType, cacheLayer, discordFetch } from './api-tools';
|
import { AuthType, cacheLayer, discordFetch } from './api-tools';
|
||||||
import { botClientID, botToken } from './config';
|
import { botClientID, botToken } from './config';
|
||||||
import { GuildData, Guilds } from './kv';
|
import { GuildData, Guilds } from './kv';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { withContext } from '@roleypoly/misc-utils/withContext';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { withContext } from '../../../../src/common/utils/withContext';
|
|
||||||
|
|
||||||
export type ScreenSize = {
|
export type ScreenSize = {
|
||||||
onSmallScreen: boolean;
|
onSmallScreen: boolean;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { FeatureFlagDecorator } from '@roleypoly/misc-utils/featureFlags/react/storyDecorator';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FeatureFlagDecorator } from '../../../../src/common/utils/featureFlags/react/storyDecorator';
|
|
||||||
import { FeatureGate } from './FeatureGate';
|
import { FeatureGate } from './FeatureGate';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import * as React from 'react';
|
|
||||||
import {
|
import {
|
||||||
FeatureFlag,
|
FeatureFlag,
|
||||||
FeatureFlagsContext,
|
FeatureFlagsContext,
|
||||||
} from '../../../../src/common/utils/featureFlags/react';
|
} from '@roleypoly/misc-utils/featureFlags/react';
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
export type FeatureGateProps = {
|
export type FeatureGateProps = {
|
||||||
featureFlag: FeatureFlag;
|
featureFlag: FeatureFlag;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { numberToChroma } from '@roleypoly/design-system/atoms/colors';
|
import { numberToChroma } from '@roleypoly/design-system/atoms/colors';
|
||||||
|
import { evaluatePermission, permissions } from '@roleypoly/misc-utils/hasPermission';
|
||||||
import { Role as RPCRole, RoleSafety } from '@roleypoly/types';
|
import { Role as RPCRole, RoleSafety } from '@roleypoly/types';
|
||||||
import chroma from 'chroma-js';
|
import chroma from 'chroma-js';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FaCheck, FaTimes } from 'react-icons/fa';
|
import { FaCheck, FaTimes } from 'react-icons/fa';
|
||||||
import {
|
|
||||||
evaluatePermission,
|
|
||||||
permissions,
|
|
||||||
} from '../../../../src/common/utils/hasPermission';
|
|
||||||
import * as styled from './Role.styled';
|
import * as styled from './Role.styled';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { NavSlug } from '@roleypoly/design-system/molecules/nav-slug';
|
import { NavSlug } from '@roleypoly/design-system/molecules/nav-slug';
|
||||||
|
import { sortBy } from '@roleypoly/misc-utils/sortBy';
|
||||||
import { GuildSlug, UserGuildPermissions } from '@roleypoly/types';
|
import { GuildSlug, UserGuildPermissions } from '@roleypoly/types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import Scrollbars from 'react-custom-scrollbars';
|
import Scrollbars from 'react-custom-scrollbars';
|
||||||
import { GoStar, GoZap } from 'react-icons/go';
|
import { GoStar, GoZap } from 'react-icons/go';
|
||||||
import ReactTooltip from 'react-tooltip';
|
import ReactTooltip from 'react-tooltip';
|
||||||
import { sortBy } from '../../../../src/common/utils/sortBy';
|
|
||||||
import { GuildNavItem } from './GuildNav.styled';
|
import { GuildNavItem } from './GuildNav.styled';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Role } from '@roleypoly/design-system/atoms/role';
|
import { Role } from '@roleypoly/design-system/atoms/role';
|
||||||
import { AmbientLarge, LargeText } from '@roleypoly/design-system/atoms/typography';
|
import { AmbientLarge, LargeText } from '@roleypoly/design-system/atoms/typography';
|
||||||
|
import { sortBy } from '@roleypoly/misc-utils/sortBy';
|
||||||
import { Category as RPCCategory, Role as RPCRole, RoleSafety } from '@roleypoly/types';
|
import { Category as RPCCategory, Role as RPCRole, RoleSafety } from '@roleypoly/types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import ReactTooltip from 'react-tooltip';
|
import ReactTooltip from 'react-tooltip';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { sortBy } from '../../../../src/common/utils/sortBy';
|
|
||||||
import { Head, HeadSub, HeadTitle } from './PickerCategory.styled';
|
import { Head, HeadSub, HeadTitle } from './PickerCategory.styled';
|
||||||
|
|
||||||
export type CategoryProps = {
|
export type CategoryProps = {
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { Link } from '@roleypoly/design-system/atoms/typography';
|
||||||
import { PickerCategory } from '@roleypoly/design-system/molecules/picker-category';
|
import { PickerCategory } from '@roleypoly/design-system/molecules/picker-category';
|
||||||
import { ResetSubmit } from '@roleypoly/design-system/molecules/reset-submit';
|
import { ResetSubmit } from '@roleypoly/design-system/molecules/reset-submit';
|
||||||
import { ServerMasthead } from '@roleypoly/design-system/molecules/server-masthead';
|
import { ServerMasthead } from '@roleypoly/design-system/molecules/server-masthead';
|
||||||
|
import { ReactifyNewlines } from '@roleypoly/misc-utils/ReactifyNewlines';
|
||||||
|
import { sortBy } from '@roleypoly/misc-utils/sortBy';
|
||||||
import {
|
import {
|
||||||
Category,
|
Category,
|
||||||
CategoryType,
|
CategoryType,
|
||||||
|
@ -15,8 +17,6 @@ import {
|
||||||
import { isEqual, xor } from 'lodash';
|
import { isEqual, xor } from 'lodash';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { GoInfo } from 'react-icons/go';
|
import { GoInfo } from 'react-icons/go';
|
||||||
import { ReactifyNewlines } from '../../../../src/common/utils/ReactifyNewlines';
|
|
||||||
import { sortBy } from '../../../../src/common/utils/sortBy';
|
|
||||||
import {
|
import {
|
||||||
CategoryContainer,
|
CategoryContainer,
|
||||||
Container,
|
Container,
|
||||||
|
|
|
@ -3,11 +3,11 @@ import { Button } from '@roleypoly/design-system/atoms/button';
|
||||||
import { DotOverlay } from '@roleypoly/design-system/atoms/dot-overlay';
|
import { DotOverlay } from '@roleypoly/design-system/atoms/dot-overlay';
|
||||||
import { Hero } from '@roleypoly/design-system/atoms/hero';
|
import { Hero } from '@roleypoly/design-system/atoms/hero';
|
||||||
import { AccentTitle, SmallTitle } from '@roleypoly/design-system/atoms/typography';
|
import { AccentTitle, SmallTitle } from '@roleypoly/design-system/atoms/typography';
|
||||||
|
import { evaluatePermission } from '@roleypoly/misc-utils/hasPermission';
|
||||||
import { GuildSlug, UserGuildPermissions } from '@roleypoly/types';
|
import { GuildSlug, UserGuildPermissions } from '@roleypoly/types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { FaDiscord } from 'react-icons/fa';
|
import { FaDiscord } from 'react-icons/fa';
|
||||||
import { GoArrowLeft } from 'react-icons/go';
|
import { GoArrowLeft } from 'react-icons/go';
|
||||||
import { evaluatePermission } from '../../../../src/common/utils/hasPermission';
|
|
||||||
import { FlexLine, FlexWrap } from './ServerSetup.styled';
|
import { FlexLine, FlexWrap } from './ServerSetup.styled';
|
||||||
|
|
||||||
export type ServerSetupProps = {
|
export type ServerSetupProps = {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { CompletelyStylelessLink } from '@roleypoly/design-system/atoms/typography';
|
import { CompletelyStylelessLink } from '@roleypoly/design-system/atoms/typography';
|
||||||
import { ServerListingCard } from '@roleypoly/design-system/molecules/server-listing-card';
|
import { ServerListingCard } from '@roleypoly/design-system/molecules/server-listing-card';
|
||||||
|
import { sortBy } from '@roleypoly/misc-utils/sortBy';
|
||||||
import { GuildSlug } from '@roleypoly/types';
|
import { GuildSlug } from '@roleypoly/types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { sortBy } from '../../../../src/common/utils/sortBy';
|
|
||||||
import { CardContainer, ContentContainer } from './ServersListing.styled';
|
import { CardContainer, ContentContainer } from './ServersListing.styled';
|
||||||
|
|
||||||
type ServersListingProps = {
|
type ServersListingProps = {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { roleCategory } from '@roleypoly/design-system/fixtures/storyData';
|
import { roleCategory } from '@roleypoly/design-system/fixtures/storyData';
|
||||||
import { Role } from 'roleypoly/common/types';
|
import { Role } from '@roleypoly/types';
|
||||||
import { hasPermission, hasPermissionOrAdmin } from './hasPermission';
|
import { hasPermission, hasPermissionOrAdmin } from './hasPermission';
|
||||||
|
|
||||||
export const permissions = {
|
export const permissions = {
|
|
@ -1,4 +1,4 @@
|
||||||
import { Role } from '../types';
|
import { Role } from '@roleypoly/types';
|
||||||
|
|
||||||
export const evaluatePermission = <T extends number | bigint>(
|
export const evaluatePermission = <T extends number | bigint>(
|
||||||
haystack: T,
|
haystack: T,
|
11
packages/misc-utils/package.json
Normal file
11
packages/misc-utils/package.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"name": "@roleypoly/misc-utils",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"dependencies": {
|
||||||
|
"@roleypoly/types": "*"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"enzyme": "3.x",
|
||||||
|
"react": "*"
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@reach/router": "^1.3.4",
|
"@reach/router": "^1.3.4",
|
||||||
"@roleypoly/design-system": "*",
|
"@roleypoly/design-system": "*",
|
||||||
|
"@roleypoly/misc-utils": "*",
|
||||||
"@roleypoly/types": "*",
|
"@roleypoly/types": "*",
|
||||||
"@testing-library/jest-dom": "^5.11.9",
|
"@testing-library/jest-dom": "^5.11.9",
|
||||||
"@testing-library/react": "^11.2.5",
|
"@testing-library/react": "^11.2.5",
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
export enum CategoryType {
|
|
||||||
Single = 0,
|
|
||||||
Multi,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Category = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
roles: string[];
|
|
||||||
hidden: boolean;
|
|
||||||
type: CategoryType;
|
|
||||||
position: number;
|
|
||||||
};
|
|
|
@ -1,47 +0,0 @@
|
||||||
import { Category } from './Category';
|
|
||||||
import { Role } from './Role';
|
|
||||||
import { Member } from './User';
|
|
||||||
|
|
||||||
export type Guild = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
icon: string;
|
|
||||||
roles: Role[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export enum Features {
|
|
||||||
None,
|
|
||||||
Preview = None,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type GuildData = {
|
|
||||||
id: string;
|
|
||||||
message: string;
|
|
||||||
categories: Category[];
|
|
||||||
features: Features;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type PresentableGuild = {
|
|
||||||
id: string;
|
|
||||||
guild: GuildSlug;
|
|
||||||
member: Member;
|
|
||||||
data: GuildData;
|
|
||||||
roles: Role[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type GuildEnumeration = {
|
|
||||||
guilds: PresentableGuild[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export enum UserGuildPermissions {
|
|
||||||
User,
|
|
||||||
Manager = 1 << 1,
|
|
||||||
Admin = 1 << 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type GuildSlug = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
icon: string;
|
|
||||||
permissionLevel: UserGuildPermissions;
|
|
||||||
};
|
|
|
@ -1,37 +0,0 @@
|
||||||
export enum RoleSafety {
|
|
||||||
Safe = 0,
|
|
||||||
HigherThanBot = 1 << 1,
|
|
||||||
DangerousPermissions = 1 << 2,
|
|
||||||
ManagedRole = 1 << 3,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Role = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
color: number;
|
|
||||||
managed: boolean;
|
|
||||||
position: number;
|
|
||||||
safety: RoleSafety;
|
|
||||||
/** Permissions is should be used as a BigInt, NOT a number. */
|
|
||||||
permissions: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type OwnRoleInfo = {
|
|
||||||
highestRolePosition: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export enum TransactionType {
|
|
||||||
None = 0,
|
|
||||||
Remove = 1 << 1,
|
|
||||||
Add = 1 << 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
export type RoleTransaction = {
|
|
||||||
id: string;
|
|
||||||
action: TransactionType;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RoleUpdate = {
|
|
||||||
knownState: Role['id'][];
|
|
||||||
transactions: RoleTransaction[];
|
|
||||||
};
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { GuildSlug } from './Guild';
|
|
||||||
import { DiscordUser } from './User';
|
|
||||||
|
|
||||||
export type AuthTokenResponse = {
|
|
||||||
access_token: string;
|
|
||||||
token_type: 'Bearer';
|
|
||||||
expires_in: number;
|
|
||||||
refresh_token: string;
|
|
||||||
scope: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type SessionData = {
|
|
||||||
/** sessionID is a KSUID */
|
|
||||||
sessionID: string;
|
|
||||||
tokens: AuthTokenResponse;
|
|
||||||
user: DiscordUser;
|
|
||||||
guilds: GuildSlug[];
|
|
||||||
};
|
|
|
@ -1,18 +0,0 @@
|
||||||
export type DiscordUser = {
|
|
||||||
id: string;
|
|
||||||
username: string;
|
|
||||||
discriminator: string;
|
|
||||||
avatar: string;
|
|
||||||
bot: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Member = {
|
|
||||||
guildid?: string;
|
|
||||||
roles: string[];
|
|
||||||
nick?: string;
|
|
||||||
user?: DiscordUser;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type RoleypolyUser = {
|
|
||||||
discorduser: DiscordUser;
|
|
||||||
};
|
|
|
@ -1,58 +0,0 @@
|
||||||
import { Role } from '.';
|
|
||||||
|
|
||||||
export const demoData: Role[] = [
|
|
||||||
{
|
|
||||||
id: '557812805546541066',
|
|
||||||
name: 'a cute role ♡',
|
|
||||||
color: 0xd19494,
|
|
||||||
permissions: '0',
|
|
||||||
safety: 0,
|
|
||||||
managed: false,
|
|
||||||
position: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '557812901717737472',
|
|
||||||
name: 'a vanity role ♡',
|
|
||||||
color: 0xd1d194,
|
|
||||||
permissions: '0',
|
|
||||||
safety: 0,
|
|
||||||
managed: false,
|
|
||||||
position: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '557812915386843170',
|
|
||||||
name: 'a brave role ♡',
|
|
||||||
color: 0x94d194,
|
|
||||||
permissions: '0',
|
|
||||||
safety: 0,
|
|
||||||
managed: false,
|
|
||||||
position: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '557824893241131029',
|
|
||||||
name: 'a proud role ♡',
|
|
||||||
color: 0x94d1d1,
|
|
||||||
permissions: '0',
|
|
||||||
safety: 0,
|
|
||||||
managed: false,
|
|
||||||
position: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '557824994269200384',
|
|
||||||
name: 'a wonderful role ♡',
|
|
||||||
color: 0x9494d1,
|
|
||||||
permissions: '0',
|
|
||||||
safety: 0,
|
|
||||||
managed: false,
|
|
||||||
position: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '557825026406088717',
|
|
||||||
name: 'a 日本語 role ♡',
|
|
||||||
color: 0xd194d1,
|
|
||||||
permissions: '0',
|
|
||||||
safety: 0,
|
|
||||||
managed: false,
|
|
||||||
position: 0,
|
|
||||||
},
|
|
||||||
];
|
|
|
@ -1,5 +0,0 @@
|
||||||
export * from './Category';
|
|
||||||
export * from './Guild';
|
|
||||||
export * from './Role';
|
|
||||||
export * from './Session';
|
|
||||||
export * from './User';
|
|
|
@ -1,241 +0,0 @@
|
||||||
import {
|
|
||||||
Category,
|
|
||||||
CategoryType,
|
|
||||||
DiscordUser,
|
|
||||||
Features,
|
|
||||||
Guild,
|
|
||||||
GuildData,
|
|
||||||
GuildEnumeration,
|
|
||||||
GuildSlug,
|
|
||||||
Member,
|
|
||||||
Role,
|
|
||||||
RoleSafety,
|
|
||||||
RoleypolyUser,
|
|
||||||
} from '.';
|
|
||||||
|
|
||||||
export const roleCategory: Role[] = [
|
|
||||||
{
|
|
||||||
id: 'aaa',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'She/Her',
|
|
||||||
color: 0xffc0cb,
|
|
||||||
position: 1,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'bbb',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'He/Him',
|
|
||||||
color: 0xc0ebff,
|
|
||||||
position: 2,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'ccc',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'They/Them',
|
|
||||||
color: 0xc0ffd5,
|
|
||||||
position: 3,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'ddd',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'Reee',
|
|
||||||
color: 0xff0000,
|
|
||||||
position: 4,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'eee',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'black but actually bravely default',
|
|
||||||
color: 0x000000,
|
|
||||||
position: 5,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'fff',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'b̻͌̆̽ͣ̃ͭ̊l͚̥͙̔ͨ̊aͥć͕k͎̟͍͕ͥ̋ͯ̓̈̉̋i͛̄̔͂̚̚҉̳͈͔̖̼̮ṣ̤̗̝͊̌͆h͈̭̰͔̥̯ͅ',
|
|
||||||
color: 0x1,
|
|
||||||
position: 6,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'unsafe1',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'too high',
|
|
||||||
color: 0xff0088,
|
|
||||||
position: 7,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.HigherThanBot,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'unsafe2',
|
|
||||||
permissions: String(0x00000008 | 0x10000000),
|
|
||||||
name: 'too strong',
|
|
||||||
color: 0x00ff88,
|
|
||||||
position: 8,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.DangerousPermissions,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const mockCategory: Category = {
|
|
||||||
id: 'aaa',
|
|
||||||
name: 'Mock',
|
|
||||||
roles: roleCategory.map((x) => x.id),
|
|
||||||
hidden: false,
|
|
||||||
type: CategoryType.Multi,
|
|
||||||
position: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const roleCategory2: Role[] = [
|
|
||||||
{
|
|
||||||
id: 'ddd2',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'red',
|
|
||||||
color: 0xff0000,
|
|
||||||
position: 9,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'eee2',
|
|
||||||
permissions: '0',
|
|
||||||
name: 'green',
|
|
||||||
color: 0x00ff00,
|
|
||||||
position: 10,
|
|
||||||
managed: false,
|
|
||||||
safety: RoleSafety.Safe,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const mockCategorySingle: Category = {
|
|
||||||
id: 'bbb',
|
|
||||||
name: 'Mock Single 岡野',
|
|
||||||
roles: roleCategory2.map((x) => x.id),
|
|
||||||
hidden: false,
|
|
||||||
type: CategoryType.Single,
|
|
||||||
position: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const roleWikiData = {
|
|
||||||
aaa: 'Typically used by feminine-identifying people',
|
|
||||||
bbb: 'Typically used by masculine-identifying people',
|
|
||||||
ccc: 'Typically used to refer to all people as a singular neutral.',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const guild: Guild = {
|
|
||||||
name: 'emoji megaporium',
|
|
||||||
id: '421896162539470888',
|
|
||||||
icon: '3372fd895ed913b55616c5e49cd50e60',
|
|
||||||
roles: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
export const roleypolyGuild: GuildSlug = {
|
|
||||||
name: 'Roleypoly',
|
|
||||||
id: '386659935687147521',
|
|
||||||
permissionLevel: 0,
|
|
||||||
icon: 'ffee638c73ff9c972554f64ca34d67ee',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const guildMap: { [x: string]: GuildSlug } = {
|
|
||||||
'emoji megaporium': {
|
|
||||||
name: guild.name,
|
|
||||||
id: guild.id,
|
|
||||||
permissionLevel: 0,
|
|
||||||
icon: guild.icon,
|
|
||||||
},
|
|
||||||
Roleypoly: roleypolyGuild,
|
|
||||||
'chamber of secrets': {
|
|
||||||
name: 'chamber of secrets',
|
|
||||||
id: 'aaa',
|
|
||||||
permissionLevel: 0,
|
|
||||||
icon: '',
|
|
||||||
},
|
|
||||||
Eclipse: {
|
|
||||||
name: 'Eclipse',
|
|
||||||
id: '408821059161423873',
|
|
||||||
permissionLevel: 0,
|
|
||||||
icon: '49dfdd8b2456e2977e80a8b577b19c0d',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const guildData: GuildData = {
|
|
||||||
id: 'aaa',
|
|
||||||
message: 'henlo worl!!',
|
|
||||||
categories: [mockCategory, mockCategorySingle],
|
|
||||||
features: Features.None,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const user: DiscordUser = {
|
|
||||||
id: '62601275618889728',
|
|
||||||
username: 'okano',
|
|
||||||
discriminator: '0001',
|
|
||||||
avatar: 'ca2028bab0fe30e1af4392f3fa3576e2',
|
|
||||||
bot: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const member: Member = {
|
|
||||||
guildid: 'aaa',
|
|
||||||
roles: ['aaa', 'eee', 'unsafe2', 'ddd2'],
|
|
||||||
nick: 'okano cat',
|
|
||||||
user: user,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const rpUser: RoleypolyUser = {
|
|
||||||
discorduser: user,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const guildEnum: GuildEnumeration = {
|
|
||||||
guilds: [
|
|
||||||
{
|
|
||||||
id: 'aaa',
|
|
||||||
guild: guildMap['emoji megaporium'],
|
|
||||||
member,
|
|
||||||
data: guildData,
|
|
||||||
roles: [...roleCategory, ...roleCategory2],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'bbb',
|
|
||||||
guild: guildMap['Roleypoly'],
|
|
||||||
member: {
|
|
||||||
...member,
|
|
||||||
roles: ['unsafe2'],
|
|
||||||
},
|
|
||||||
data: guildData,
|
|
||||||
roles: [...roleCategory, ...roleCategory2],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'ccc',
|
|
||||||
guild: guildMap['chamber of secrets'],
|
|
||||||
member,
|
|
||||||
data: guildData,
|
|
||||||
roles: [...roleCategory, ...roleCategory2],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'ddd',
|
|
||||||
guild: guildMap['Eclipse'],
|
|
||||||
member,
|
|
||||||
data: guildData,
|
|
||||||
roles: [...roleCategory, ...roleCategory2],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export const mastheadSlugs: GuildSlug[] = guildEnum.guilds.map<GuildSlug>(
|
|
||||||
(guild, idx) => ({
|
|
||||||
id: guild.guild.id,
|
|
||||||
name: guild.guild.name,
|
|
||||||
icon: guild.guild.icon,
|
|
||||||
permissionLevel: 1 << idx % 3,
|
|
||||||
})
|
|
||||||
);
|
|
18
yarn.lock
18
yarn.lock
|
@ -6650,7 +6650,7 @@ enzyme-to-json@^3.3.0:
|
||||||
lodash "^4.17.15"
|
lodash "^4.17.15"
|
||||||
react-is "^16.12.0"
|
react-is "^16.12.0"
|
||||||
|
|
||||||
enzyme@^3.11.0:
|
enzyme@3.x, enzyme@^3.11.0:
|
||||||
version "3.11.0"
|
version "3.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.11.0.tgz#71d680c580fe9349f6f5ac6c775bc3e6b7a79c28"
|
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.11.0.tgz#71d680c580fe9349f6f5ac6c775bc3e6b7a79c28"
|
||||||
integrity sha512-Dw8/Gs4vRjxY6/6i9wU0V+utmQO9kvh9XLnz3LIudviOnVYDEe2ec+0k+NQoMamn1VrjKgCUOWj5jG/5M5M0Qw==
|
integrity sha512-Dw8/Gs4vRjxY6/6i9wU0V+utmQO9kvh9XLnz3LIudviOnVYDEe2ec+0k+NQoMamn1VrjKgCUOWj5jG/5M5M0Qw==
|
||||||
|
@ -13481,6 +13481,14 @@ react-tooltip@^4.2.15:
|
||||||
prop-types "^15.7.2"
|
prop-types "^15.7.2"
|
||||||
uuid "^7.0.3"
|
uuid "^7.0.3"
|
||||||
|
|
||||||
|
react@*, react@^17.0.1:
|
||||||
|
version "17.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127"
|
||||||
|
integrity sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w==
|
||||||
|
dependencies:
|
||||||
|
loose-envify "^1.1.0"
|
||||||
|
object-assign "^4.1.1"
|
||||||
|
|
||||||
react@^16.8.0:
|
react@^16.8.0:
|
||||||
version "16.14.0"
|
version "16.14.0"
|
||||||
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
|
resolved "https://registry.yarnpkg.com/react/-/react-16.14.0.tgz#94d776ddd0aaa37da3eda8fc5b6b18a4c9a3114d"
|
||||||
|
@ -13490,14 +13498,6 @@ react@^16.8.0:
|
||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
prop-types "^15.6.2"
|
prop-types "^15.6.2"
|
||||||
|
|
||||||
react@^17.0.1:
|
|
||||||
version "17.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/react/-/react-17.0.1.tgz#6e0600416bd57574e3f86d92edba3d9008726127"
|
|
||||||
integrity sha512-lG9c9UuMHdcAexXtigOZLX8exLWkW0Ku29qPRU8uhF2R9BN96dLCt0psvzPLlHc5OWkgymP3qwTRgbnw5BKx3w==
|
|
||||||
dependencies:
|
|
||||||
loose-envify "^1.1.0"
|
|
||||||
object-assign "^4.1.1"
|
|
||||||
|
|
||||||
reactcss@^1.2.0:
|
reactcss@^1.2.0:
|
||||||
version "1.2.3"
|
version "1.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/reactcss/-/reactcss-1.2.3.tgz#c00013875e557b1cf0dfd9a368a1c3dab3b548dd"
|
resolved "https://registry.yarnpkg.com/reactcss/-/reactcss-1.2.3.tgz#c00013875e557b1cf0dfd9a368a1c3dab3b548dd"
|
||||||
|
|
Loading…
Add table
Reference in a new issue