From c3afe67e8fb0678dfc30cad3246001ec5ce87ca1 Mon Sep 17 00:00:00 2001 From: purple Date: Fri, 29 Dec 2023 00:59:12 +0100 Subject: [PATCH] feat(core, react): add BeforeNavigation and AfterNavigation for testing --- blueprint.sh | 41 +++++++++++-------- .../NavigationBar/AdditionalItems.tsx} | 0 .../NavigationBar/AfterNavigation.tsx | 10 +++++ .../NavigationBar/BeforeNavigation.tsx | 10 +++++ .../scripts/components/NavigationBar.tsx | 9 +++- 5 files changed, 52 insertions(+), 18 deletions(-) rename resources/scripts/blueprint/components/{NavigationBar/Items.tsx => Navigation/NavigationBar/AdditionalItems.tsx} (100%) create mode 100644 resources/scripts/blueprint/components/Navigation/NavigationBar/AfterNavigation.tsx create mode 100644 resources/scripts/blueprint/components/Navigation/NavigationBar/BeforeNavigation.tsx diff --git a/blueprint.sh b/blueprint.sh index dac8f2b..d9a8ab6 100644 --- a/blueprint.sh +++ b/blueprint.sh @@ -586,29 +586,38 @@ if [[ ( $2 == "-i" ) || ( $2 == "-install" ) ]]; then VCMD="y" log_bright "[INFO] Placing components directory contents.." cp -R ".blueprint/tmp/$n/$dashboard_components/"* ".blueprint/extensions/$identifier/components/" 2>> $BLUEPRINT__DEBUG - if [[ -f ".blueprint/tmp/$n/$dashboard_components/components.yml" ]]; then + if [[ -f ".blueprint/tmp/$n/$dashboard_components/Components.yml" ]]; then # fetch component config - eval "$(parse_yaml .blueprint/tmp/"$n"/"$dashboard_components"/components.yml comp_)" + eval "$(parse_yaml .blueprint/tmp/"$n"/"$dashboard_components"/Components.yml Components_)" + + # define static variables to make stuff a bit easier + im="\/\* blueprint\/import \*\/"; re="{/\* blueprint\/react \*/}"; co="resources/scripts/blueprint/components" + s="import ${identifier^}Component from '"; e="';" + + PLACE_REACT() { + if [[ ! $1 == "@/blueprint/extensions/${identifier}/" ]]; then + # remove components + sed -i "s~""${s}$1${e}""~~g" "$co"/"$2" + sed -i "s~""<${identifier^}Component />""~~g" "$co"/"$2" + # add components + sed -i "s~""$im""~""${im}${s}$1${e}""~g" "$co"/"$2" + sed -i "s~""$re""~""${re}\<${identifier^}Component /\>""~g" "$co"/"$2" + fi + } + # assign variables to component items - extendNavigationBarItems="@/blueprint/extensions/${identifier}/${comp_extendNavigationBarItems}" + __Navigation_NavigationBar_BeforeNavigation="@/blueprint/extensions/${identifier}/${Components_Navigation_NavigationBar_BeforeNavigation}" + __Navigation_NavigationBar_AdditionalItems="@/blueprint/extensions/${identifier}/${Components_Navigation_NavigationBar_AdditionalItems}" + __Navigation_NavigationBar_AfterNavigation="@/blueprint/extensions/${identifier}/${Components_Navigation_NavigationBar_AfterNavigation}" - im="\/\* blueprint\/import \*\/" - re="{/\* blueprint\/react \*/}" - co="resources/scripts/blueprint/components" - - s="import ${identifier^}Component from '" - e="';" - - sed -i "s~""${s}$extendNavigationBarItems${e}""~~g" $co/NavigationBar/Items.tsx - sed -i "s~""<${identifier^}Component />""~~g" $co/NavigationBar/Items.tsx - - sed -i "s~""$im""~""${im}${s}$extendNavigationBarItems${e}""~g" $co/NavigationBar/Items.tsx - sed -i "s~""$re""~""${re}\<${identifier^}Component /\>""~g" $co/NavigationBar/Items.tsx + PLACE_REACT "$__Navigation_NavigationBar_BeforeNavigation" "Navigation/NavigationBar/BeforeNavigation.tsx" + PLACE_REACT "$__Navigation_NavigationBar_AdditionalItems" "Navigation/NavigationBar/AdditionalItems.tsx" + PLACE_REACT "$__Navigation_NavigationBar_AfterNavigation" "Navigation/NavigationBar/AfterNavigation.tsx" else # warn about missing components.yml file - log_yellow "[WARNING] Could not find '$dashboard_components/components.yml', React component extendability might be limited." + log_yellow "[WARNING] Could not find '$dashboard_components/Components.yml', React component extendability might be limited." fi fi diff --git a/resources/scripts/blueprint/components/NavigationBar/Items.tsx b/resources/scripts/blueprint/components/Navigation/NavigationBar/AdditionalItems.tsx similarity index 100% rename from resources/scripts/blueprint/components/NavigationBar/Items.tsx rename to resources/scripts/blueprint/components/Navigation/NavigationBar/AdditionalItems.tsx diff --git a/resources/scripts/blueprint/components/Navigation/NavigationBar/AfterNavigation.tsx b/resources/scripts/blueprint/components/Navigation/NavigationBar/AfterNavigation.tsx new file mode 100644 index 0000000..5c85b6c --- /dev/null +++ b/resources/scripts/blueprint/components/Navigation/NavigationBar/AfterNavigation.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +/* blueprint/import */ + +export default () => { + return ( + <> + {/* blueprint/react */} + + ); +}; diff --git a/resources/scripts/blueprint/components/Navigation/NavigationBar/BeforeNavigation.tsx b/resources/scripts/blueprint/components/Navigation/NavigationBar/BeforeNavigation.tsx new file mode 100644 index 0000000..5c85b6c --- /dev/null +++ b/resources/scripts/blueprint/components/Navigation/NavigationBar/BeforeNavigation.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +/* blueprint/import */ + +export default () => { + return ( + <> + {/* blueprint/react */} + + ); +}; diff --git a/resources/scripts/components/NavigationBar.tsx b/resources/scripts/components/NavigationBar.tsx index 01e78b4..2be49b4 100644 --- a/resources/scripts/components/NavigationBar.tsx +++ b/resources/scripts/components/NavigationBar.tsx @@ -12,7 +12,10 @@ import http from '@/api/http'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import Tooltip from '@/components/elements/tooltip/Tooltip'; import Avatar from '@/components/Avatar'; -import BlueprintNavigationItems from '@/blueprint/components/NavigationBar/Items'; + +import BeforeNavigation from '@/blueprint/components/Navigation/NavigationBar/BeforeNavigation'; +import AdditionalItems from '@/blueprint/components/Navigation/NavigationBar/AdditionalItems'; +import AfterNavigation from '@/blueprint/components/Navigation/NavigationBar/AfterNavigation'; const RightNavigation = styled.div` & > a, @@ -47,6 +50,7 @@ export default () => { }; return ( +
@@ -74,7 +78,7 @@ export default () => { )} - + @@ -90,5 +94,6 @@ export default () => {
+ ); };