Merge pull request #229 from mirumee/add/readonly-mode
Add readonly mode
This commit is contained in:
commit
5131c50d45
5 changed files with 30 additions and 5 deletions
|
@ -45,3 +45,4 @@ All notable, unreleased changes to this project will be documented in this file.
|
||||||
- Fix ui improvements - #226 by @benekex2
|
- Fix ui improvements - #226 by @benekex2
|
||||||
- Fix attribute errors - #216 by @dominik-zeglen
|
- Fix attribute errors - #216 by @dominik-zeglen
|
||||||
- Fix column picker - #228 by @dominik-zeglen
|
- Fix column picker - #228 by @dominik-zeglen
|
||||||
|
- Add readonly mode - #229 by @dominik-zeglen
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"POT-Creation-Date: 2019-10-21T14:54:01.519Z\n"
|
"POT-Creation-Date: 2019-10-24T12:11:32.946Z\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
@ -6775,6 +6775,14 @@ msgctxt "description"
|
||||||
msgid "Saleor ran into an unexpected problem"
|
msgid "Saleor ran into an unexpected problem"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: build/locale/src/intl.json
|
||||||
|
#. [src.readOnly]
|
||||||
|
#. defaultMessage is:
|
||||||
|
#. Saleor runs in read-only mode. Changes not saved.
|
||||||
|
msgctxt "description"
|
||||||
|
msgid "Saleor runs in read-only mode. Changes not saved."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: build/locale/src/intl.json
|
#: build/locale/src/intl.json
|
||||||
#. [src.sales] - sales section name
|
#. [src.sales] - sales section name
|
||||||
#. defaultMessage is:
|
#. defaultMessage is:
|
||||||
|
|
|
@ -47,6 +47,9 @@ export const commonMessages = defineMessages({
|
||||||
properties: {
|
properties: {
|
||||||
defaultMessage: "Properties"
|
defaultMessage: "Properties"
|
||||||
},
|
},
|
||||||
|
readOnly: {
|
||||||
|
defaultMessage: "Saleor runs in read-only mode. Changes not saved."
|
||||||
|
},
|
||||||
requiredField: {
|
requiredField: {
|
||||||
defaultMessage: "This field is required"
|
defaultMessage: "This field is required"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import useNotifier from "./hooks/useNotifier";
|
import useNotifier from "./hooks/useNotifier";
|
||||||
import { commonMessages } from "./intl";
|
import { commonMessages } from "./intl";
|
||||||
|
import { maybe } from "./misc";
|
||||||
|
|
||||||
export interface TypedMutationInnerProps<TData, TVariables> {
|
export interface TypedMutationInnerProps<TData, TVariables> {
|
||||||
children: (
|
children: (
|
||||||
|
@ -32,9 +33,21 @@ export function TypedMutation<TData, TVariables>(
|
||||||
mutation={mutation}
|
mutation={mutation}
|
||||||
onCompleted={onCompleted}
|
onCompleted={onCompleted}
|
||||||
onError={(err: ApolloError) => {
|
onError={(err: ApolloError) => {
|
||||||
notify({
|
if (
|
||||||
text: intl.formatMessage(commonMessages.somethingWentWrong)
|
maybe(
|
||||||
});
|
() =>
|
||||||
|
err.graphQLErrors[0].extensions.exception.code ===
|
||||||
|
"ReadOnlyException"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
notify({
|
||||||
|
text: intl.formatMessage(commonMessages.readOnly)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
notify({
|
||||||
|
text: intl.formatMessage(commonMessages.somethingWentWrong)
|
||||||
|
});
|
||||||
|
}
|
||||||
if (onError) {
|
if (onError) {
|
||||||
onError(err);
|
onError(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ export function TypedQuery<TData, TVariables>(
|
||||||
skip={skip}
|
skip={skip}
|
||||||
context={{ useBatching: true }}
|
context={{ useBatching: true }}
|
||||||
>
|
>
|
||||||
{queryData => {
|
{(queryData: QueryResult<TData, TVariables>) => {
|
||||||
if (queryData.error) {
|
if (queryData.error) {
|
||||||
pushMessage({
|
pushMessage({
|
||||||
text: intl.formatMessage(commonMessages.somethingWentWrong)
|
text: intl.formatMessage(commonMessages.somethingWentWrong)
|
||||||
|
|
Loading…
Reference in a new issue