More protobufjs migration
This commit is contained in:
parent
cf06e6638e
commit
ddbbe3a6b1
70 changed files with 3967 additions and 3369 deletions
|
@ -8,6 +8,7 @@ import { storiesOf } from '@storybook/react';
|
|||
import { setup as setupI18n } from '../../../js/modules/i18n';
|
||||
import enMessages from '../../../_locales/en/messages.json';
|
||||
import { GroupV2ChangeType } from '../../groups';
|
||||
import { SignalService as Proto } from '../../protobuf';
|
||||
import { SmartContactRendererType } from '../../groupChange';
|
||||
import { GroupV2Change } from './GroupV2Change';
|
||||
|
||||
|
@ -20,25 +21,8 @@ const CONTACT_C = 'CONTACT_C';
|
|||
const ADMIN_A = 'ADMIN_A';
|
||||
const INVITEE_A = 'INVITEE_A';
|
||||
|
||||
class AccessControlEnum {
|
||||
static UNKNOWN = 0;
|
||||
|
||||
static ANY = 1;
|
||||
|
||||
static MEMBER = 2;
|
||||
|
||||
static ADMINISTRATOR = 3;
|
||||
|
||||
static UNSATISFIABLE = 4;
|
||||
}
|
||||
|
||||
class RoleEnum {
|
||||
static UNKNOWN = 0;
|
||||
|
||||
static ADMINISTRATOR = 1;
|
||||
|
||||
static DEFAULT = 2;
|
||||
}
|
||||
const AccessControlEnum = Proto.AccessControl.AccessRequired;
|
||||
const RoleEnum = Proto.Member.Role;
|
||||
|
||||
const renderContact: SmartContactRendererType = (conversationId: string) => (
|
||||
<React.Fragment key={conversationId}>
|
||||
|
@ -48,13 +32,11 @@ const renderContact: SmartContactRendererType = (conversationId: string) => (
|
|||
|
||||
const renderChange = (change: GroupV2ChangeType, groupName?: string) => (
|
||||
<GroupV2Change
|
||||
AccessControlEnum={AccessControlEnum}
|
||||
change={change}
|
||||
groupName={groupName}
|
||||
i18n={i18n}
|
||||
ourConversationId={OUR_ID}
|
||||
renderContact={renderContact}
|
||||
RoleEnum={RoleEnum}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
|
@ -14,14 +14,10 @@ import { GroupV2ChangeType, GroupV2DescriptionChangeType } from '../../groups';
|
|||
import { renderChange, SmartContactRendererType } from '../../groupChange';
|
||||
import { Modal } from '../Modal';
|
||||
|
||||
import { AccessControlClass, MemberClass } from '../../textsecure.d';
|
||||
|
||||
export type PropsDataType = {
|
||||
groupName?: string;
|
||||
ourConversationId: string;
|
||||
change: GroupV2ChangeType;
|
||||
AccessControlEnum: typeof AccessControlClass.AccessRequired;
|
||||
RoleEnum: typeof MemberClass.Role;
|
||||
};
|
||||
|
||||
export type PropsHousekeepingType = {
|
||||
|
@ -40,15 +36,7 @@ function renderStringToIntl(
|
|||
}
|
||||
|
||||
export function GroupV2Change(props: PropsType): ReactElement {
|
||||
const {
|
||||
AccessControlEnum,
|
||||
change,
|
||||
groupName,
|
||||
i18n,
|
||||
ourConversationId,
|
||||
renderContact,
|
||||
RoleEnum,
|
||||
} = props;
|
||||
const { change, groupName, i18n, ourConversationId, renderContact } = props;
|
||||
|
||||
const [
|
||||
isGroupDescriptionDialogOpen,
|
||||
|
@ -64,12 +52,10 @@ export function GroupV2Change(props: PropsType): ReactElement {
|
|||
<div className="module-group-v2-change">
|
||||
<div className="module-group-v2-change--icon" />
|
||||
{renderChange(change, {
|
||||
AccessControlEnum,
|
||||
i18n,
|
||||
ourConversationId,
|
||||
renderContact,
|
||||
renderString: renderStringToIntl,
|
||||
RoleEnum,
|
||||
}).map((item: FullJSXType, index: number) => (
|
||||
// Difficult to find a unique key for this type
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
|
|
|
@ -9,6 +9,7 @@ import { action } from '@storybook/addon-actions';
|
|||
import { setup as setupI18n } from '../../../../js/modules/i18n';
|
||||
import enMessages from '../../../../_locales/en/messages.json';
|
||||
import { GroupLinkManagement, PropsType } from './GroupLinkManagement';
|
||||
import { SignalService as Proto } from '../../../protobuf';
|
||||
import { ConversationType } from '../../../state/ducks/conversations';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
|
||||
|
@ -19,17 +20,7 @@ const story = storiesOf(
|
|||
module
|
||||
);
|
||||
|
||||
class AccessEnum {
|
||||
static ANY = 0;
|
||||
|
||||
static UNKNOWN = 1;
|
||||
|
||||
static MEMBER = 2;
|
||||
|
||||
static ADMINISTRATOR = 3;
|
||||
|
||||
static UNSATISFIABLE = 4;
|
||||
}
|
||||
const AccessControlEnum = Proto.AccessControl.AccessRequired;
|
||||
|
||||
function getConversation(
|
||||
groupLink?: string,
|
||||
|
@ -47,7 +38,7 @@ function getConversation(
|
|||
accessControlAddFromInviteLink:
|
||||
accessControlAddFromInviteLink !== undefined
|
||||
? accessControlAddFromInviteLink
|
||||
: AccessEnum.UNSATISFIABLE,
|
||||
: AccessControlEnum.UNSATISFIABLE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -55,7 +46,6 @@ const createProps = (
|
|||
conversation?: ConversationType,
|
||||
isAdmin = false
|
||||
): PropsType => ({
|
||||
accessEnum: AccessEnum,
|
||||
changeHasGroupLink: action('changeHasGroupLink'),
|
||||
conversation: conversation || getConversation(),
|
||||
copyGroupLink: action('copyGroupLink'),
|
||||
|
@ -75,7 +65,7 @@ story.add('Off (Admin)', () => {
|
|||
|
||||
story.add('On (Admin)', () => {
|
||||
const props = createProps(
|
||||
getConversation('https://signal.group/1', AccessEnum.ANY),
|
||||
getConversation('https://signal.group/1', AccessControlEnum.ANY),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -84,7 +74,7 @@ story.add('On (Admin)', () => {
|
|||
|
||||
story.add('On (Admin + Admin Approval Needed)', () => {
|
||||
const props = createProps(
|
||||
getConversation('https://signal.group/1', AccessEnum.ADMINISTRATOR),
|
||||
getConversation('https://signal.group/1', AccessControlEnum.ADMINISTRATOR),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -93,7 +83,7 @@ story.add('On (Admin + Admin Approval Needed)', () => {
|
|||
|
||||
story.add('On (Non-admin)', () => {
|
||||
const props = createProps(
|
||||
getConversation('https://signal.group/1', AccessEnum.ANY)
|
||||
getConversation('https://signal.group/1', AccessControlEnum.ANY)
|
||||
);
|
||||
|
||||
return <GroupLinkManagement {...props} />;
|
||||
|
|
|
@ -4,15 +4,16 @@
|
|||
import React from 'react';
|
||||
|
||||
import { ConversationDetailsIcon } from './ConversationDetailsIcon';
|
||||
import { SignalService as Proto } from '../../../protobuf';
|
||||
import { ConversationType } from '../../../state/ducks/conversations';
|
||||
import { LocalizerType } from '../../../types/Util';
|
||||
import { PanelRow } from './PanelRow';
|
||||
import { PanelSection } from './PanelSection';
|
||||
import { AccessControlClass } from '../../../textsecure.d';
|
||||
import { Select } from '../../Select';
|
||||
|
||||
const AccessControlEnum = Proto.AccessControl.AccessRequired;
|
||||
|
||||
export type PropsType = {
|
||||
accessEnum: typeof AccessControlClass.AccessRequired;
|
||||
changeHasGroupLink: (value: boolean) => void;
|
||||
conversation?: ConversationType;
|
||||
copyGroupLink: (groupLink: string) => void;
|
||||
|
@ -23,7 +24,6 @@ export type PropsType = {
|
|||
};
|
||||
|
||||
export const GroupLinkManagement: React.ComponentType<PropsType> = ({
|
||||
accessEnum,
|
||||
changeHasGroupLink,
|
||||
conversation,
|
||||
copyGroupLink,
|
||||
|
@ -43,11 +43,13 @@ export const GroupLinkManagement: React.ComponentType<PropsType> = ({
|
|||
};
|
||||
|
||||
const membersNeedAdminApproval =
|
||||
conversation.accessControlAddFromInviteLink === accessEnum.ADMINISTRATOR;
|
||||
conversation.accessControlAddFromInviteLink ===
|
||||
AccessControlEnum.ADMINISTRATOR;
|
||||
|
||||
const hasGroupLink =
|
||||
conversation.groupLink &&
|
||||
conversation.accessControlAddFromInviteLink !== accessEnum.UNSATISFIABLE;
|
||||
conversation.accessControlAddFromInviteLink !==
|
||||
AccessControlEnum.UNSATISFIABLE;
|
||||
const groupLinkInfo = hasGroupLink ? conversation.groupLink : '';
|
||||
|
||||
return (
|
||||
|
|
|
@ -29,20 +29,7 @@ const conversation: ConversationType = getDefaultConversation({
|
|||
sharedGroupNames: [],
|
||||
});
|
||||
|
||||
class AccessEnum {
|
||||
static ANY = 0;
|
||||
|
||||
static UNKNOWN = 1;
|
||||
|
||||
static MEMBER = 2;
|
||||
|
||||
static ADMINISTRATOR = 3;
|
||||
|
||||
static UNSATISFIABLE = 4;
|
||||
}
|
||||
|
||||
const createProps = (): PropsType => ({
|
||||
accessEnum: AccessEnum,
|
||||
conversation,
|
||||
i18n,
|
||||
setAccessControlAttributesSetting: action(
|
||||
|
|
|
@ -6,14 +6,12 @@ import React from 'react';
|
|||
import { ConversationType } from '../../../state/ducks/conversations';
|
||||
import { LocalizerType } from '../../../types/Util';
|
||||
import { getAccessControlOptions } from '../../../util/getAccessControlOptions';
|
||||
import { AccessControlClass } from '../../../textsecure.d';
|
||||
|
||||
import { PanelRow } from './PanelRow';
|
||||
import { PanelSection } from './PanelSection';
|
||||
import { Select } from '../../Select';
|
||||
|
||||
export type PropsType = {
|
||||
accessEnum: typeof AccessControlClass.AccessRequired;
|
||||
conversation?: ConversationType;
|
||||
i18n: LocalizerType;
|
||||
setAccessControlAttributesSetting: (value: number) => void;
|
||||
|
@ -21,7 +19,6 @@ export type PropsType = {
|
|||
};
|
||||
|
||||
export const GroupV2Permissions: React.ComponentType<PropsType> = ({
|
||||
accessEnum,
|
||||
conversation,
|
||||
i18n,
|
||||
setAccessControlAttributesSetting,
|
||||
|
@ -37,7 +34,7 @@ export const GroupV2Permissions: React.ComponentType<PropsType> = ({
|
|||
const updateAccessControlMembers = (value: string) => {
|
||||
setAccessControlMembersSetting(Number(value));
|
||||
};
|
||||
const accessControlOptions = getAccessControlOptions(accessEnum, i18n);
|
||||
const accessControlOptions = getAccessControlOptions(i18n);
|
||||
|
||||
return (
|
||||
<PanelSection>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue