From 5a3e7e884f28fe82b5b94aa2befc75155ef88151 Mon Sep 17 00:00:00 2001 From: Michael Schramm Date: Thu, 11 Jun 2020 17:16:15 +0200 Subject: [PATCH] add ability to hide omf badge --- CHANGELOG.md | 2 +- components/omf.tsx | 8 ++++++++ graphql/query/settings.query.ts | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90e604a..8e74f40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - mobile improvements for lists and home page - markdown support for page paragraphs and field description -- omf badge +- hideable omf badge - login notes ### Changed diff --git a/components/omf.tsx b/components/omf.tsx index 66321cd..99fb861 100644 --- a/components/omf.tsx +++ b/components/omf.tsx @@ -1,7 +1,15 @@ +import { useQuery } from '@apollo/react-hooks' import React from 'react' +import { SETTINGS_QUERY, SettingsQueryData } from '../graphql/query/settings.query' import scss from './omf.module.scss' export const Omf: React.FC = () => { + const { data, loading } = useQuery(SETTINGS_QUERY) + + if (loading || data.hideContrib.value) { + return null + } + return ( OhMyForm diff --git a/graphql/query/settings.query.ts b/graphql/query/settings.query.ts index 6c98540..aed2603 100644 --- a/graphql/query/settings.query.ts +++ b/graphql/query/settings.query.ts @@ -7,6 +7,9 @@ export interface SettingsQueryData { loginNote: { value: string } + hideContrib: { + value: string + } } export const SETTINGS_QUERY = gql` @@ -17,5 +20,8 @@ export const SETTINGS_QUERY = gql` loginNote: getSetting(key: "LOGIN_NOTE") { value } + hideContrib: getSetting(key: "HIDE_CONTRIB") { + value: isTrue + } } `