Drop authorization keys section (#913)

* Drop authorization keys section

* Update translations

* Update snapshots

Co-authored-by: dominik-zeglen <flesz3@o2.pl>
This commit is contained in:
Marcin Gębala 2020-12-21 13:50:04 +01:00 committed by GitHub
parent 0ad9d6f487
commit 71b4b329d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 46658 additions and 20844 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5686,45 +5686,6 @@
"src_dot_siteSettings_dot_components_dot_SiteSettingsDetails_dot_529433178": {
"string": "Store description is shown on taskbar after your store name"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeyDialog_dot_1238948746": {
"context": "dialog header",
"string": "Add New Authorization Key"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeyDialog_dot_2237029987": {
"string": "Password"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeyDialog_dot_2446088470": {
"context": "authentication provider API key",
"string": "Key"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeyDialog_dot_3039841202": {
"context": "authentication provider name",
"string": "Authentication type"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeyDialog_dot_50561933": {
"context": "button",
"string": "Add authentication"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeys_dot_1114030884": {
"context": "button",
"string": "Add key"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeys_dot_1270286507": {
"context": "authentication provider name",
"string": "Authentication Type"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeys_dot_226491688": {
"context": "section header",
"string": "Authentication Keys"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeys_dot_2446088470": {
"context": "authentication provider API key",
"string": "Key"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsKeys_dot_3981699144": {
"context": "no authentication provider API keys",
"string": "No keys"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsMailing_dot_1124962330": {
"string": "Mailing email address"
},
@ -5754,9 +5715,6 @@
"src_dot_siteSettings_dot_components_dot_SiteSettingsPage_dot_1004240342": {
"string": "This adress will be used to generate invoices and calculate shipping rates."
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsPage_dot_1214877701": {
"string": "Authentication method defines additional ways that customers can log in to your ecommerce."
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsPage_dot_229184360": {
"context": "section header",
"string": "Store Information"
@ -5775,10 +5733,6 @@
"src_dot_siteSettings_dot_components_dot_SiteSettingsPage_dot_3799756739": {
"string": "These are general information about your store. They define what is the URL of your store and what is shown in browsers taskbar."
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsPage_dot_4088830385": {
"context": "section header",
"string": "Authentication Methods"
},
"src_dot_siteSettings_dot_components_dot_SiteSettingsPage_dot_866304242": {
"string": "This where you will find all of the settings determining your stores e-mails. You can determine main email address and some of the contents of your emails."
},

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -633,35 +633,6 @@ type AttributeValueUpdate {
attributeValue: AttributeValue
}
type AuthorizationKey {
name: AuthorizationKeyType!
key: String!
}
type AuthorizationKeyAdd {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
authorizationKey: AuthorizationKey
shop: Shop
shopErrors: [ShopError!]!
}
type AuthorizationKeyDelete {
errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
authorizationKey: AuthorizationKey
shop: Shop
shopErrors: [ShopError!]!
}
input AuthorizationKeyInput {
key: String!
password: String!
}
enum AuthorizationKeyType {
FACEBOOK
GOOGLE_OAUTH2
}
input BulkAttributeValueInput {
id: ID
values: [String]!
@ -806,6 +777,7 @@ type Channel implements Node {
isActive: Boolean!
slug: String!
currencyCode: String!
hasOrders: Boolean!
}
type ChannelActivate {
@ -858,6 +830,7 @@ enum ChannelErrorCode {
UNIQUE
CHANNEL_TARGET_ID_MUST_BE_DIFFERENT
CHANNELS_CURRENCY_MUST_BE_THE_SAME
CHANNEL_WITH_ORDERS
}
type ChannelUpdate {
@ -2567,8 +2540,6 @@ type Mutation {
deleteWarehouse(id: ID!): WarehouseDelete
assignWarehouseShippingZone(id: ID!, shippingZoneIds: [ID!]!): WarehouseShippingZoneAssign
unassignWarehouseShippingZone(id: ID!, shippingZoneIds: [ID!]!): WarehouseShippingZoneUnassign
authorizationKeyAdd(input: AuthorizationKeyInput!, keyType: AuthorizationKeyType!): AuthorizationKeyAdd
authorizationKeyDelete(keyType: AuthorizationKeyType!): AuthorizationKeyDelete
staffNotificationRecipientCreate(input: StaffNotificationRecipientInput!): StaffNotificationRecipientCreate
staffNotificationRecipientUpdate(id: ID!, input: StaffNotificationRecipientInput!): StaffNotificationRecipientUpdate
staffNotificationRecipientDelete(id: ID!): StaffNotificationRecipientDelete
@ -2742,7 +2713,7 @@ type Mutation {
checkoutShippingMethodUpdate(checkoutId: ID, shippingMethodId: ID!): CheckoutShippingMethodUpdate
channelCreate(input: ChannelCreateInput!): ChannelCreate
channelUpdate(id: ID!, input: ChannelUpdateInput!): ChannelUpdate
channelDelete(id: ID!, input: ChannelDeleteInput!): ChannelDelete
channelDelete(id: ID!, input: ChannelDeleteInput): ChannelDelete
channelActivate(id: ID!): ChannelActivate
channelDeactivate(id: ID!): ChannelDeactivate
attributeCreate(input: AttributeCreateInput!): AttributeCreate
@ -4422,7 +4393,7 @@ type Query {
channel(id: ID): Channel
channels: [Channel!]
attributes(filter: AttributeFilterInput, sortBy: AttributeSortingInput, before: String, after: String, first: Int, last: Int): AttributeCountableConnection
attribute(id: ID!): Attribute
attribute(id: ID, slug: String): Attribute
appsInstallations: [AppInstallation!]!
apps(filter: AppFilterInput, sortBy: AppSortingInput, before: String, after: String, first: Int, last: Int): AppCountableConnection
app(id: ID!): App
@ -4867,7 +4838,6 @@ type Shop {
availablePaymentGateways(currency: String): [PaymentGateway!]!
availableShippingMethods(channel: String!, address: AddressInput): [ShippingMethod]
geolocalization: Geolocalization
authorizationKeys: [AuthorizationKey]!
countries(languageCode: LanguageCodeEnum): [CountryDisplay!]!
defaultCountry: CountryDisplay
defaultMailSenderName: String

View file

@ -5,10 +5,6 @@ import { fragmentAddress } from "./address";
export const shopFragment = gql`
${fragmentAddress}
fragment ShopFragment on Shop {
authorizationKeys {
key
name
}
companyAddress {
...AddressFragment
}

View file

@ -2,18 +2,10 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { AuthorizationKeyType } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: ShopFragment
// ====================================================
export interface ShopFragment_authorizationKeys {
__typename: "AuthorizationKey";
key: string;
name: AuthorizationKeyType;
}
export interface ShopFragment_companyAddress_country {
__typename: "CountryDisplay";
code: string;
@ -49,7 +41,6 @@ export interface ShopFragment_domain {
export interface ShopFragment {
__typename: "Shop";
authorizationKeys: (ShopFragment_authorizationKeys | null)[];
companyAddress: ShopFragment_companyAddress | null;
countries: ShopFragment_countries[];
customerSetPasswordUrl: string | null;

View file

@ -14,7 +14,6 @@ import {
} from "./types";
import {
AddressInput,
AuthorizationKeyType,
CountryCode,
OrderStatus,
PaymentChargeStatusEnum
@ -211,11 +210,6 @@ export const transformAddressToForm = (data: AddressType) => ({
streetAddress2: maybe(() => data.streetAddress2, "")
});
export const authorizationKeyTypes = {
[AuthorizationKeyType.FACEBOOK]: "Facebook",
[AuthorizationKeyType.GOOGLE_OAUTH2]: "Google OAuth2"
};
export function maybe<T>(exp: () => T): T | undefined;
export function maybe<T>(exp: () => T, d: T): T;
export function maybe(exp: any, d?: any) {

View file

@ -1,117 +0,0 @@
import Button from "@material-ui/core/Button";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import TextField from "@material-ui/core/TextField";
import Form from "@saleor/components/Form";
import { FormSpacer } from "@saleor/components/FormSpacer";
import SingleSelectField from "@saleor/components/SingleSelectField";
import { ShopErrorFragment } from "@saleor/fragments/types/ShopErrorFragment";
import { buttonMessages } from "@saleor/intl";
import { DialogProps } from "@saleor/types";
import { getFormErrors } from "@saleor/utils/errors";
import getShopErrorMessage from "@saleor/utils/errors/shop";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { authorizationKeyTypes } from "../../../misc";
import { AuthorizationKeyType } from "../../../types/globalTypes";
export interface SiteSettingsKeyDialogForm {
key: string;
password: string;
type: AuthorizationKeyType;
}
export interface SiteSettingsKeyDialogProps extends DialogProps {
errors: ShopErrorFragment[];
initial: SiteSettingsKeyDialogForm;
onSubmit: (data: SiteSettingsKeyDialogForm) => void;
}
const SiteSettingsKeyDialog: React.FC<SiteSettingsKeyDialogProps> = ({
errors,
initial,
open,
onClose,
onSubmit
}) => {
const intl = useIntl();
const formErrors = getFormErrors(["keyType", "key", "password"], errors);
return (
<Dialog onClose={onClose} maxWidth="xs" fullWidth open={open}>
<Form initial={initial} onSubmit={onSubmit}>
{({ change, data }) => (
<>
<DialogTitle>
<FormattedMessage
defaultMessage="Add New Authorization Key"
description="dialog header"
/>
</DialogTitle>
<DialogContent>
<SingleSelectField
choices={Object.keys(authorizationKeyTypes).map(key => ({
label: authorizationKeyTypes[key],
value: key
}))}
error={!!formErrors.keyType}
label={intl.formatMessage({
defaultMessage: "Authentication type",
description: "authentication provider name"
})}
hint={getShopErrorMessage(formErrors.keyType, intl)}
name="type"
onChange={change}
value={data.type}
/>
<FormSpacer />
<TextField
autoComplete="off"
error={!!formErrors.key}
fullWidth
label={intl.formatMessage({
defaultMessage: "Key",
description: "authentication provider API key"
})}
helperText={getShopErrorMessage(formErrors.key, intl)}
name="key"
onChange={change}
value={data.key}
/>
<FormSpacer />
<TextField
autoComplete="off"
error={!!formErrors.password}
fullWidth
label={intl.formatMessage({
defaultMessage: "Password"
})}
helperText={getShopErrorMessage(formErrors.password, intl)}
name="password"
onChange={change}
value={data.password}
/>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>
<FormattedMessage {...buttonMessages.back} />
</Button>
<Button color="primary" type="submit" variant="contained">
<FormattedMessage
defaultMessage="Add authentication"
description="button"
/>
</Button>
</DialogActions>
</>
)}
</Form>
</Dialog>
);
};
SiteSettingsKeyDialog.displayName = "SiteSettingsKeyDialog";
export default SiteSettingsKeyDialog;

View file

@ -1,2 +0,0 @@
export { default } from "./SiteSettingsKeyDialog";
export * from "./SiteSettingsKeyDialog";

View file

@ -1,120 +0,0 @@
import Button from "@material-ui/core/Button";
import Card from "@material-ui/core/Card";
import IconButton from "@material-ui/core/IconButton";
import { makeStyles } from "@material-ui/core/styles";
import TableBody from "@material-ui/core/TableBody";
import TableCell from "@material-ui/core/TableCell";
import TableHead from "@material-ui/core/TableHead";
import TableRow from "@material-ui/core/TableRow";
import DeleteIcon from "@material-ui/icons/Delete";
import CardTitle from "@saleor/components/CardTitle";
import ResponsiveTable from "@saleor/components/ResponsiveTable";
import Skeleton from "@saleor/components/Skeleton";
import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { authorizationKeyTypes, maybe, renderCollection } from "../../../misc";
import { ICONBUTTON_SIZE } from "../../../theme";
import { AuthorizationKeyType } from "../../../types/globalTypes";
import { SiteSettings_shop_authorizationKeys } from "../../types/SiteSettings";
const useStyles = makeStyles(
theme => ({
iconCell: {
"&:last-child": {
paddingRight: 0
},
width: ICONBUTTON_SIZE + theme.spacing(0.5)
}
}),
{ name: "SiteSettingsKeys" }
);
interface SiteSettingsKeysProps {
disabled: boolean;
keys: SiteSettings_shop_authorizationKeys[];
onAdd: () => void;
onRemove: (name: AuthorizationKeyType) => void;
}
const SiteSettingsKeys: React.FC<SiteSettingsKeysProps> = props => {
const { disabled, keys, onAdd, onRemove } = props;
const classes = useStyles(props);
const intl = useIntl();
return (
<Card>
<CardTitle
title={intl.formatMessage({
defaultMessage: "Authentication Keys",
description: "section header"
})}
toolbar={
<Button
color="primary"
disabled={disabled}
variant="text"
onClick={onAdd}
>
<FormattedMessage defaultMessage="Add key" description="button" />
</Button>
}
/>
<ResponsiveTable>
<TableHead>
<TableRow>
<TableCell>
<FormattedMessage
defaultMessage="Authentication Type"
description="authentication provider name"
/>
</TableCell>
<TableCell>
<FormattedMessage
defaultMessage="Key"
description="authentication provider API key"
/>
</TableCell>
<TableCell />
</TableRow>
</TableHead>
<TableBody>
{renderCollection(
keys,
key => (
<TableRow hover={!(disabled || !key)} key={maybe(() => key.name)}>
<TableCell>
{maybe<React.ReactNode>(
() => authorizationKeyTypes[key.name],
<Skeleton />
)}
</TableCell>
<TableCell>
{maybe<React.ReactNode>(() => key.key, <Skeleton />)}
</TableCell>
<TableCell className={classes.iconCell}>
<IconButton onClick={() => onRemove(key.name)}>
<DeleteIcon color="primary" />
</IconButton>
</TableCell>
</TableRow>
),
() => (
<TableRow>
<TableCell colSpan={3}>
<FormattedMessage
defaultMessage="No keys"
description="no authentication provider API keys"
/>
</TableCell>
</TableRow>
)
)}
</TableBody>
</ResponsiveTable>
</Card>
);
};
SiteSettingsKeys.displayName = "SiteSettingsKeys";
export default SiteSettingsKeys;

View file

@ -1,2 +0,0 @@
export { default } from "./SiteSettingsKeys";
export * from "./SiteSettingsKeys";

View file

@ -20,10 +20,8 @@ import React from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { maybe } from "../../../misc";
import { AuthorizationKeyType } from "../../../types/globalTypes";
import { SiteSettings_shop } from "../../types/SiteSettings";
import SiteSettingsDetails from "../SiteSettingsDetails/SiteSettingsDetails";
import SiteSettingsKeys from "../SiteSettingsKeys/SiteSettingsKeys";
import SiteSettingsMailing, {
SiteSettingsMailingFormData
} from "../SiteSettingsMailing";
@ -53,8 +51,6 @@ export interface SiteSettingsPageProps {
shop: SiteSettings_shop;
saveButtonBarState: ConfirmButtonTransitionState;
onBack: () => void;
onKeyAdd: () => void;
onKeyRemove: (keyType: AuthorizationKeyType) => void;
onSubmit: (data: SiteSettingsPageFormData) => SubmitPromise;
}
@ -93,8 +89,6 @@ const SiteSettingsPage: React.FC<SiteSettingsPageProps> = props => {
saveButtonBarState,
shop,
onBack,
onKeyAdd,
onKeyRemove,
onSubmit
} = props;
const classes = useStyles(props);
@ -214,24 +208,6 @@ const SiteSettingsPage: React.FC<SiteSettingsPageProps> = props => {
onChange={change}
onCountryChange={handleCountryChange}
/>
<Hr className={classes.hr} />
<div>
<Typography>
<FormattedMessage
defaultMessage="Authentication Methods"
description="section header"
/>
</Typography>
<Typography variant="body2">
<FormattedMessage defaultMessage="Authentication method defines additional ways that customers can log in to your ecommerce." />
</Typography>
</div>
<SiteSettingsKeys
disabled={disabled}
keys={maybe(() => shop.authorizationKeys)}
onAdd={onKeyAdd}
onRemove={onKeyRemove}
/>
</Grid>
<SaveButtonBar
state={saveButtonBarState}

View file

@ -1,15 +1,7 @@
import { AuthorizationKeyType } from "../types/globalTypes";
import { SiteSettings_shop } from "./types/SiteSettings";
export const shop: SiteSettings_shop = {
__typename: "Shop",
authorizationKeys: [
{
__typename: "AuthorizationKey",
key: "n1n62jkn2123:123n",
name: AuthorizationKeyType.FACEBOOK
}
],
companyAddress: {
__typename: "Address",
city: "Kenstad",

View file

@ -4,60 +4,11 @@ import { shopFragment } from "@saleor/fragments/shop";
import gql from "graphql-tag";
import { TypedMutation } from "../mutations";
import {
AuthorizationKeyAdd,
AuthorizationKeyAddVariables
} from "./types/AuthorizationKeyAdd";
import {
AuthorizationKeyDelete,
AuthorizationKeyDeleteVariables
} from "./types/AuthorizationKeyDelete";
import {
ShopSettingsUpdate,
ShopSettingsUpdateVariables
} from "./types/ShopSettingsUpdate";
const authorizationKeyAdd = gql`
${shopErrorFragment}
${shopFragment}
mutation AuthorizationKeyAdd(
$input: AuthorizationKeyInput!
$keyType: AuthorizationKeyType!
) {
authorizationKeyAdd(input: $input, keyType: $keyType) {
errors: shopErrors {
...ShopErrorFragment
}
shop {
...ShopFragment
}
}
}
`;
export const TypedAuthorizationKeyAdd = TypedMutation<
AuthorizationKeyAdd,
AuthorizationKeyAddVariables
>(authorizationKeyAdd);
const authorizationKeyDelete = gql`
${shopErrorFragment}
${shopFragment}
mutation AuthorizationKeyDelete($keyType: AuthorizationKeyType!) {
authorizationKeyDelete(keyType: $keyType) {
errors: shopErrors {
...ShopErrorFragment
}
shop {
...ShopFragment
}
}
}
`;
export const TypedAuthorizationKeyDelete = TypedMutation<
AuthorizationKeyDelete,
AuthorizationKeyDeleteVariables
>(authorizationKeyDelete);
const shopSettingsUpdate = gql`
${shopErrorFragment}
${shopFragment}

View file

@ -1,82 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { AuthorizationKeyInput, AuthorizationKeyType, ShopErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AuthorizationKeyAdd
// ====================================================
export interface AuthorizationKeyAdd_authorizationKeyAdd_errors {
__typename: "ShopError";
code: ShopErrorCode;
field: string | null;
}
export interface AuthorizationKeyAdd_authorizationKeyAdd_shop_authorizationKeys {
__typename: "AuthorizationKey";
key: string;
name: AuthorizationKeyType;
}
export interface AuthorizationKeyAdd_authorizationKeyAdd_shop_companyAddress_country {
__typename: "CountryDisplay";
code: string;
country: string;
}
export interface AuthorizationKeyAdd_authorizationKeyAdd_shop_companyAddress {
__typename: "Address";
city: string;
cityArea: string;
companyName: string;
country: AuthorizationKeyAdd_authorizationKeyAdd_shop_companyAddress_country;
countryArea: string;
firstName: string;
id: string;
lastName: string;
phone: string | null;
postalCode: string;
streetAddress1: string;
streetAddress2: string;
}
export interface AuthorizationKeyAdd_authorizationKeyAdd_shop_countries {
__typename: "CountryDisplay";
code: string;
country: string;
}
export interface AuthorizationKeyAdd_authorizationKeyAdd_shop_domain {
__typename: "Domain";
host: string;
}
export interface AuthorizationKeyAdd_authorizationKeyAdd_shop {
__typename: "Shop";
authorizationKeys: (AuthorizationKeyAdd_authorizationKeyAdd_shop_authorizationKeys | null)[];
companyAddress: AuthorizationKeyAdd_authorizationKeyAdd_shop_companyAddress | null;
countries: AuthorizationKeyAdd_authorizationKeyAdd_shop_countries[];
customerSetPasswordUrl: string | null;
defaultMailSenderAddress: string | null;
defaultMailSenderName: string | null;
description: string | null;
domain: AuthorizationKeyAdd_authorizationKeyAdd_shop_domain;
name: string;
}
export interface AuthorizationKeyAdd_authorizationKeyAdd {
__typename: "AuthorizationKeyAdd";
errors: AuthorizationKeyAdd_authorizationKeyAdd_errors[];
shop: AuthorizationKeyAdd_authorizationKeyAdd_shop | null;
}
export interface AuthorizationKeyAdd {
authorizationKeyAdd: AuthorizationKeyAdd_authorizationKeyAdd | null;
}
export interface AuthorizationKeyAddVariables {
input: AuthorizationKeyInput;
keyType: AuthorizationKeyType;
}

View file

@ -1,81 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { AuthorizationKeyType, ShopErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AuthorizationKeyDelete
// ====================================================
export interface AuthorizationKeyDelete_authorizationKeyDelete_errors {
__typename: "ShopError";
code: ShopErrorCode;
field: string | null;
}
export interface AuthorizationKeyDelete_authorizationKeyDelete_shop_authorizationKeys {
__typename: "AuthorizationKey";
key: string;
name: AuthorizationKeyType;
}
export interface AuthorizationKeyDelete_authorizationKeyDelete_shop_companyAddress_country {
__typename: "CountryDisplay";
code: string;
country: string;
}
export interface AuthorizationKeyDelete_authorizationKeyDelete_shop_companyAddress {
__typename: "Address";
city: string;
cityArea: string;
companyName: string;
country: AuthorizationKeyDelete_authorizationKeyDelete_shop_companyAddress_country;
countryArea: string;
firstName: string;
id: string;
lastName: string;
phone: string | null;
postalCode: string;
streetAddress1: string;
streetAddress2: string;
}
export interface AuthorizationKeyDelete_authorizationKeyDelete_shop_countries {
__typename: "CountryDisplay";
code: string;
country: string;
}
export interface AuthorizationKeyDelete_authorizationKeyDelete_shop_domain {
__typename: "Domain";
host: string;
}
export interface AuthorizationKeyDelete_authorizationKeyDelete_shop {
__typename: "Shop";
authorizationKeys: (AuthorizationKeyDelete_authorizationKeyDelete_shop_authorizationKeys | null)[];
companyAddress: AuthorizationKeyDelete_authorizationKeyDelete_shop_companyAddress | null;
countries: AuthorizationKeyDelete_authorizationKeyDelete_shop_countries[];
customerSetPasswordUrl: string | null;
defaultMailSenderAddress: string | null;
defaultMailSenderName: string | null;
description: string | null;
domain: AuthorizationKeyDelete_authorizationKeyDelete_shop_domain;
name: string;
}
export interface AuthorizationKeyDelete_authorizationKeyDelete {
__typename: "AuthorizationKeyDelete";
errors: AuthorizationKeyDelete_authorizationKeyDelete_errors[];
shop: AuthorizationKeyDelete_authorizationKeyDelete_shop | null;
}
export interface AuthorizationKeyDelete {
authorizationKeyDelete: AuthorizationKeyDelete_authorizationKeyDelete | null;
}
export interface AuthorizationKeyDeleteVariables {
keyType: AuthorizationKeyType;
}

View file

@ -2,7 +2,7 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { SiteDomainInput, ShopSettingsInput, AddressInput, ShopErrorCode, AuthorizationKeyType } from "./../../types/globalTypes";
import { SiteDomainInput, ShopSettingsInput, AddressInput, ShopErrorCode } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ShopSettingsUpdate
@ -14,12 +14,6 @@ export interface ShopSettingsUpdate_shopSettingsUpdate_errors {
field: string | null;
}
export interface ShopSettingsUpdate_shopSettingsUpdate_shop_authorizationKeys {
__typename: "AuthorizationKey";
key: string;
name: AuthorizationKeyType;
}
export interface ShopSettingsUpdate_shopSettingsUpdate_shop_companyAddress_country {
__typename: "CountryDisplay";
code: string;
@ -55,7 +49,6 @@ export interface ShopSettingsUpdate_shopSettingsUpdate_shop_domain {
export interface ShopSettingsUpdate_shopSettingsUpdate_shop {
__typename: "Shop";
authorizationKeys: (ShopSettingsUpdate_shopSettingsUpdate_shop_authorizationKeys | null)[];
companyAddress: ShopSettingsUpdate_shopSettingsUpdate_shop_companyAddress | null;
countries: ShopSettingsUpdate_shopSettingsUpdate_shop_countries[];
customerSetPasswordUrl: string | null;

View file

@ -2,18 +2,10 @@
/* eslint-disable */
// This file was automatically generated and should not be edited.
import { AuthorizationKeyType } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: SiteSettings
// ====================================================
export interface SiteSettings_shop_authorizationKeys {
__typename: "AuthorizationKey";
key: string;
name: AuthorizationKeyType;
}
export interface SiteSettings_shop_companyAddress_country {
__typename: "CountryDisplay";
code: string;
@ -49,7 +41,6 @@ export interface SiteSettings_shop_domain {
export interface SiteSettings_shop {
__typename: "Shop";
authorizationKeys: (SiteSettings_shop_authorizationKeys | null)[];
companyAddress: SiteSettings_shop_companyAddress | null;
countries: SiteSettings_shop_countries[];
customerSetPasswordUrl: string | null;

View file

@ -7,56 +7,25 @@ import { useIntl } from "react-intl";
import { configurationMenuUrl } from "../../configuration";
import { findInEnum } from "../../misc";
import { AuthorizationKeyType, CountryCode } from "../../types/globalTypes";
import SiteSettingsKeyDialog, {
SiteSettingsKeyDialogForm
} from "../components/SiteSettingsKeyDialog";
import { CountryCode } from "../../types/globalTypes";
import SiteSettingsPage, {
areAddressInputFieldsModified,
SiteSettingsPageFormData
} from "../components/SiteSettingsPage";
import {
TypedAuthorizationKeyAdd,
TypedAuthorizationKeyDelete,
TypedShopSettingsUpdate
} from "../mutations";
import { TypedShopSettingsUpdate } from "../mutations";
import { TypedSiteSettingsQuery } from "../queries";
import { AuthorizationKeyAdd } from "../types/AuthorizationKeyAdd";
import { AuthorizationKeyDelete } from "../types/AuthorizationKeyDelete";
import { ShopSettingsUpdate } from "../types/ShopSettingsUpdate";
import { siteSettingsUrl, SiteSettingsUrlQueryParams } from "../urls";
import { SiteSettingsUrlQueryParams } from "../urls";
export interface SiteSettingsProps {
params: SiteSettingsUrlQueryParams;
}
export const SiteSettings: React.FC<SiteSettingsProps> = ({ params }) => {
export const SiteSettings: React.FC<SiteSettingsProps> = () => {
const navigate = useNavigator();
const notify = useNotifier();
const intl = useIntl();
const handleAddKeySuccess = (data: AuthorizationKeyAdd) => {
if (data.authorizationKeyAdd.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
navigate(siteSettingsUrl());
}
};
const handleDeleteKeySuccess = (data: AuthorizationKeyDelete) => {
if (data.authorizationKeyDelete.errors.length === 0) {
notify({
status: "success",
text: intl.formatMessage(commonMessages.savedChanges)
});
} else {
notify({
status: "error",
text: intl.formatMessage(commonMessages.somethingWentWrong)
});
}
};
const handleSiteSettingsSuccess = (data: ShopSettingsUpdate) => {
if (
data.shopDomainUpdate.errors.length === 0 &&
@ -73,127 +42,73 @@ export const SiteSettings: React.FC<SiteSettingsProps> = ({ params }) => {
return (
<TypedSiteSettingsQuery displayLoader>
{siteSettings => (
<TypedAuthorizationKeyAdd onCompleted={handleAddKeySuccess}>
{(addAuthorizationKey, addAuthorizationKeyOpts) => (
<TypedAuthorizationKeyDelete onCompleted={handleDeleteKeySuccess}>
{(deleteAuthorizationKey, _) => (
<TypedShopSettingsUpdate
onCompleted={handleSiteSettingsSuccess}
>
{(updateShopSettings, updateShopSettingsOpts) => {
const errors = [
...(updateShopSettingsOpts.data?.shopDomainUpdate
.errors || []),
...(updateShopSettingsOpts.data?.shopSettingsUpdate
.errors || []),
...(updateShopSettingsOpts.data?.shopAddressUpdate
.errors || [])
];
const loading =
siteSettings.loading ||
addAuthorizationKeyOpts.loading ||
updateShopSettingsOpts.loading;
<TypedShopSettingsUpdate onCompleted={handleSiteSettingsSuccess}>
{(updateShopSettings, updateShopSettingsOpts) => {
const errors = [
...(updateShopSettingsOpts.data?.shopDomainUpdate.errors || []),
...(updateShopSettingsOpts.data?.shopSettingsUpdate.errors || []),
...(updateShopSettingsOpts.data?.shopAddressUpdate.errors || [])
];
const loading =
siteSettings.loading || updateShopSettingsOpts.loading;
const handleAuthenticationKeyAdd = (
data: SiteSettingsKeyDialogForm
) =>
addAuthorizationKey({
variables: {
input: {
key: data.key,
password: data.password
},
keyType: data.type
}
});
const handleUpdateShopSettings = async (
data: SiteSettingsPageFormData
) => {
const addressInput = areAddressInputFieldsModified(data)
? {
city: data.city,
companyName: data.companyName,
country: findInEnum(data.country, CountryCode),
countryArea: data.countryArea,
phone: data.phone,
postalCode: data.postalCode,
streetAddress1: data.streetAddress1,
streetAddress2: data.streetAddress2
}
: {
companyName: data.companyName
};
const result = await updateShopSettings({
variables: {
addressInput,
shopDomainInput: {
domain: data.domain,
name: data.name
},
shopSettingsInput: {
customerSetPasswordUrl: data.customerSetPasswordUrl,
defaultMailSenderAddress:
data.defaultMailSenderAddress,
defaultMailSenderName: data.defaultMailSenderName,
description: data.description
}
}
});
const handleUpdateShopSettings = async (
data: SiteSettingsPageFormData
) => {
const addressInput = areAddressInputFieldsModified(data)
? {
city: data.city,
companyName: data.companyName,
country: findInEnum(data.country, CountryCode),
countryArea: data.countryArea,
phone: data.phone,
postalCode: data.postalCode,
streetAddress1: data.streetAddress1,
streetAddress2: data.streetAddress2
}
: {
companyName: data.companyName
};
const result = await updateShopSettings({
variables: {
addressInput,
shopDomainInput: {
domain: data.domain,
name: data.name
},
shopSettingsInput: {
customerSetPasswordUrl: data.customerSetPasswordUrl,
defaultMailSenderAddress: data.defaultMailSenderAddress,
defaultMailSenderName: data.defaultMailSenderName,
description: data.description
}
}
});
return [
...result.data.shopAddressUpdate.errors,
...result.data.shopDomainUpdate.errors,
...result.data.shopSettingsUpdate.errors
];
};
return [
...result.data.shopAddressUpdate.errors,
...result.data.shopDomainUpdate.errors,
...result.data.shopSettingsUpdate.errors
];
};
return (
<>
<WindowTitle
title={intl.formatMessage(sectionNames.siteSettings)}
/>
<SiteSettingsPage
disabled={loading}
errors={errors}
shop={siteSettings.data?.shop}
onBack={() => navigate(configurationMenuUrl)}
onKeyAdd={() =>
navigate(
siteSettingsUrl({
action: "add-key"
})
)
}
onKeyRemove={keyType =>
deleteAuthorizationKey({
variables: { keyType }
})
}
onSubmit={handleUpdateShopSettings}
saveButtonBarState={updateShopSettingsOpts.status}
/>
<SiteSettingsKeyDialog
errors={
addAuthorizationKeyOpts.data?.authorizationKeyAdd
.errors || []
}
initial={{
key: "",
password: "",
type: AuthorizationKeyType.FACEBOOK
}}
open={params.action === "add-key"}
onClose={() => navigate(siteSettingsUrl())}
onSubmit={handleAuthenticationKeyAdd}
/>
</>
);
}}
</TypedShopSettingsUpdate>
)}
</TypedAuthorizationKeyDelete>
)}
</TypedAuthorizationKeyAdd>
return (
<>
<WindowTitle
title={intl.formatMessage(sectionNames.siteSettings)}
/>
<SiteSettingsPage
disabled={loading}
errors={errors}
shop={siteSettings.data?.shop}
onBack={() => navigate(configurationMenuUrl)}
onSubmit={handleUpdateShopSettings}
saveButtonBarState={updateShopSettingsOpts.status}
/>
</>
);
}}
</TypedShopSettingsUpdate>
)}
</TypedSiteSettingsQuery>
);

View file

@ -17876,18 +17876,6 @@ exports[`Storyshots Shipping / UnassignDialog default 1`] = `
/>
`;
exports[`Storyshots SiteSettings / Add key dialog default 1`] = `
<div
style="padding:24px"
/>
`;
exports[`Storyshots SiteSettings / Add key dialog form errors 1`] = `
<div
style="padding:24px"
/>
`;
exports[`Storyshots Views / Apps / Activate app default 1`] = `
<div
style="padding:24px"
@ -213911,130 +213899,6 @@ exports[`Storyshots Views / Site settings / Page default 1`] = `
</div>
</div>
</div>
<hr
class="Hr-root-id SiteSettingsPage-hr-id"
/>
<div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
Authentication Methods
</div>
<div
class="MuiTypography-root-id MuiTypography-body2-id"
>
Authentication method defines additional ways that customers can log in to your ecommerce.
</div>
</div>
<div
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
>
<div
class="CardTitle-root-id"
>
<span
class="MuiTypography-root-id CardTitle-title-id MuiTypography-h5-id"
>
Authentication Keys
</span>
<div
class="CardTitle-toolbar-id"
>
<button
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
tabindex="0"
type="button"
>
<span
class="MuiButton-label-id"
>
Add key
</span>
</button>
</div>
</div>
<div
class="CardTitle-children-id"
/>
<hr
class="CardTitle-hr-id"
/>
<div
class="ResponsiveTable-root-id"
>
<table
class="MuiTable-root-id"
>
<thead
class="MuiTableHead-root-id"
>
<tr
class="MuiTableRow-root-id MuiTableRow-head-id"
>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
Authentication Type
</th>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
Key
</th>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
/>
</tr>
</thead>
<tbody
class="MuiTableBody-root-id"
>
<tr
class="MuiTableRow-root-id MuiTableRow-hover-id"
>
<td
class="MuiTableCell-root-id MuiTableCell-body-id"
>
Facebook
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id"
>
n1n62jkn2123:123n
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id SiteSettingsKeys-iconCell-id"
>
<button
class="MuiButtonBase-root-id MuiIconButton-root-id"
tabindex="0"
type="button"
>
<span
class="MuiIconButton-label-id"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root-id MuiSvgIcon-colorPrimary-id"
focusable="false"
role="presentation"
viewBox="0 0 24 24"
>
<path
d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
/>
</svg>
</span>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>
@ -214787,130 +214651,6 @@ exports[`Storyshots Views / Site settings / Page form errors 1`] = `
</div>
</div>
</div>
<hr
class="Hr-root-id SiteSettingsPage-hr-id"
/>
<div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
Authentication Methods
</div>
<div
class="MuiTypography-root-id MuiTypography-body2-id"
>
Authentication method defines additional ways that customers can log in to your ecommerce.
</div>
</div>
<div
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
>
<div
class="CardTitle-root-id"
>
<span
class="MuiTypography-root-id CardTitle-title-id MuiTypography-h5-id"
>
Authentication Keys
</span>
<div
class="CardTitle-toolbar-id"
>
<button
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id"
tabindex="0"
type="button"
>
<span
class="MuiButton-label-id"
>
Add key
</span>
</button>
</div>
</div>
<div
class="CardTitle-children-id"
/>
<hr
class="CardTitle-hr-id"
/>
<div
class="ResponsiveTable-root-id"
>
<table
class="MuiTable-root-id"
>
<thead
class="MuiTableHead-root-id"
>
<tr
class="MuiTableRow-root-id MuiTableRow-head-id"
>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
Authentication Type
</th>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
Key
</th>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
/>
</tr>
</thead>
<tbody
class="MuiTableBody-root-id"
>
<tr
class="MuiTableRow-root-id MuiTableRow-hover-id"
>
<td
class="MuiTableCell-root-id MuiTableCell-body-id"
>
Facebook
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id"
>
n1n62jkn2123:123n
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id SiteSettingsKeys-iconCell-id"
>
<button
class="MuiButtonBase-root-id MuiIconButton-root-id"
tabindex="0"
type="button"
>
<span
class="MuiIconButton-label-id"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root-id MuiSvgIcon-colorPrimary-id"
focusable="false"
role="presentation"
viewBox="0 0 24 24"
>
<path
d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
/>
</svg>
</span>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>
@ -215669,139 +215409,6 @@ exports[`Storyshots Views / Site settings / Page loading 1`] = `
</div>
</div>
</div>
<hr
class="Hr-root-id SiteSettingsPage-hr-id"
/>
<div>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
Authentication Methods
</div>
<div
class="MuiTypography-root-id MuiTypography-body2-id"
>
Authentication method defines additional ways that customers can log in to your ecommerce.
</div>
</div>
<div
class="MuiPaper-root-id MuiPaper-elevation0-id MuiCard-root-id MuiPaper-rounded-id"
>
<div
class="CardTitle-root-id"
>
<span
class="MuiTypography-root-id CardTitle-title-id MuiTypography-h5-id"
>
Authentication Keys
</span>
<div
class="CardTitle-toolbar-id"
>
<button
class="MuiButtonBase-root-id MuiButton-root-id MuiButton-text-id MuiButton-textPrimary-id MuiButton-disabled-id MuiButtonBase-disabled-id"
disabled=""
tabindex="-1"
type="button"
>
<span
class="MuiButton-label-id"
>
Add key
</span>
</button>
</div>
</div>
<div
class="CardTitle-children-id"
/>
<hr
class="CardTitle-hr-id"
/>
<div
class="ResponsiveTable-root-id"
>
<table
class="MuiTable-root-id"
>
<thead
class="MuiTableHead-root-id"
>
<tr
class="MuiTableRow-root-id MuiTableRow-head-id"
>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
Authentication Type
</th>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
>
Key
</th>
<th
class="MuiTableCell-root-id MuiTableCell-head-id"
scope="col"
/>
</tr>
</thead>
<tbody
class="MuiTableBody-root-id"
>
<tr
class="MuiTableRow-root-id"
>
<td
class="MuiTableCell-root-id MuiTableCell-body-id"
>
<span
class="Skeleton-skeleton-id"
>
</span>
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id"
>
<span
class="Skeleton-skeleton-id"
>
</span>
</td>
<td
class="MuiTableCell-root-id MuiTableCell-body-id SiteSettingsKeys-iconCell-id"
>
<button
class="MuiButtonBase-root-id MuiIconButton-root-id"
tabindex="0"
type="button"
>
<span
class="MuiIconButton-label-id"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root-id MuiSvgIcon-colorPrimary-id"
focusable="false"
role="presentation"
viewBox="0 0 24 24"
>
<path
d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
/>
</svg>
</span>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</form>

View file

@ -146,7 +146,6 @@ function loadStories() {
require("./stories/shipping/ShippingZonesListPage");
// Site settings
require("./stories/siteSettings/SiteSettingsKeyDialog");
require("./stories/siteSettings/SiteSettingsPage");
// Taxes

View file

@ -1,37 +0,0 @@
import { storiesOf } from "@storybook/react";
import React from "react";
import SiteSettingsKeyDialog, {
SiteSettingsKeyDialogProps
} from "../../../siteSettings/components/SiteSettingsKeyDialog";
import {
AuthorizationKeyType,
ShopErrorCode
} from "../../../types/globalTypes";
import Decorator from "../../Decorator";
const props: SiteSettingsKeyDialogProps = {
errors: [],
initial: {
key: "912n3n123j9",
password: "090das9d86gad678adf7ad6f88asd8",
type: AuthorizationKeyType.FACEBOOK
},
onClose: () => undefined,
onSubmit: () => undefined,
open: true
};
storiesOf("SiteSettings / Add key dialog", module)
.addDecorator(Decorator)
.add("default", () => <SiteSettingsKeyDialog {...props} />)
.add("form errors", () => (
<SiteSettingsKeyDialog
{...props}
errors={["key", "password", "keyType"].map(field => ({
__typename: "ShopError",
code: ShopErrorCode.INVALID,
field
}))}
/>
));

View file

@ -13,8 +13,6 @@ const props: Omit<SiteSettingsPageProps, "classes"> = {
disabled: false,
errors: [],
onBack: () => undefined,
onKeyAdd: () => undefined,
onKeyRemove: () => undefined,
onSubmit: () => undefined,
saveButtonBarState: "default",
shop

View file

@ -102,11 +102,6 @@ export enum AttributeTypeEnum {
PRODUCT_TYPE = "PRODUCT_TYPE",
}
export enum AuthorizationKeyType {
FACEBOOK = "FACEBOOK",
GOOGLE_OAUTH2 = "GOOGLE_OAUTH2",
}
export enum CategorySortField {
NAME = "NAME",
PRODUCT_COUNT = "PRODUCT_COUNT",
@ -117,6 +112,7 @@ export enum ChannelErrorCode {
ALREADY_EXISTS = "ALREADY_EXISTS",
CHANNELS_CURRENCY_MUST_BE_THE_SAME = "CHANNELS_CURRENCY_MUST_BE_THE_SAME",
CHANNEL_TARGET_ID_MUST_BE_DIFFERENT = "CHANNEL_TARGET_ID_MUST_BE_DIFFERENT",
CHANNEL_WITH_ORDERS = "CHANNEL_WITH_ORDERS",
GRAPHQL_ERROR = "GRAPHQL_ERROR",
INVALID = "INVALID",
NOT_FOUND = "NOT_FOUND",
@ -1090,11 +1086,6 @@ export interface AttributeValueInput {
contentType?: string | null;
}
export interface AuthorizationKeyInput {
key: string;
password: string;
}
export interface BulkAttributeValueInput {
id?: string | null;
values: (string | null)[];