From 3ce00447d72da533198657e3262b2c0587e263d7 Mon Sep 17 00:00:00 2001 From: Wender Lima Date: Tue, 26 Oct 2021 14:20:41 -0300 Subject: [PATCH 1/4] [PERMISSIONS-13] Changed default route to roles/list --- CHANGELOG.md | 6 ++++++ admin/navigation.json | 2 +- react/index.tsx | 27 ++++++--------------------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd4c058..b6bc882 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Changed +- Default route to `roles/list + +### Removed +- Tabs + ## [0.1.2] - 2021-09-07 ### Fixed diff --git a/admin/navigation.json b/admin/navigation.json index 2b87bc8..fda8d88 100644 --- a/admin/navigation.json +++ b/admin/navigation.json @@ -1,6 +1,6 @@ { "section": "accountSettings", - "path": "/admin/storefront-permissions", + "path": "/admin/app/storefront-permissions/roles/list", "icon": "extensions-ic", "titleId": "admin/storefront-permissions.navigation.label", "searchKeyWordsHelpers": "admin/storefront-permissions.navigation.keywords" diff --git a/react/index.tsx b/react/index.tsx index 722f535..a9ecef3 100644 --- a/react/index.tsx +++ b/react/index.tsx @@ -11,7 +11,9 @@ import GET_CONFIG from './queries/getAppSettings.gql' const AdminB2bWaffle: FC = (props) => { const { navigate, route } = useRuntime() - const [activeTab, setActiveTab] = useState(route.id) + + console.log('route', route) + const [activeTab, setActiveTab] = useState('admin.app.storefront-permissions.roles-list') const [state, setState] = useState({ missingConfig: true, }) @@ -34,10 +36,11 @@ const AdminB2bWaffle: FC = (props) => { const isActive = (currTab: string) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [_, current] = activeTab.split('admin.app.storefront-permissions') const [section] = current.replace('.', '').split('-') - - return currTab === (section || 'users') + console.log('isActive', currTab, currTab === (section || 'roles')) + return currTab === (section || 'roles') } return ( @@ -53,24 +56,6 @@ const AdminB2bWaffle: FC = (props) => { > <> - - - } - active={isActive('users')} - onClick={setActiveSection('users')} - disabled={loading} - > - - } - active={isActive('roles')} - onClick={setActiveSection('roles')} - disabled={loading} - > - {props.children} From 673cba68a91f3d816a7e7823becefdae4fcc9b67 Mon Sep 17 00:00:00 2001 From: Wender Lima Date: Tue, 26 Oct 2021 14:25:17 -0300 Subject: [PATCH 2/4] Updating doc --- docs/README.md | 6 +++--- messages/en.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index f0974cd..fde6a17 100644 --- a/docs/README.md +++ b/docs/README.md @@ -102,6 +102,6 @@ Only `check-permission` block has props: | Sales Admin | `sales-admin` | | Sales Manager | `sales-manager` | | Sales Representative | `sales-representative` | -| Admin | `customer-admin` | -| Approver | `customer-approver` | -| Buyer | `customer-buyer` | +| Organization Admin | `customer-admin` | +| Organization Approver | `customer-approver` | +| Organization Buyer | `customer-buyer` | diff --git a/messages/en.json b/messages/en.json index d71a5de..f1fe2ed 100644 --- a/messages/en.json +++ b/messages/en.json @@ -2,7 +2,7 @@ "admin/storefront-permissions.navigation.label": "Storefront Permissions", "admin/storefront-permissions.navigation.keywords": "b2b, Roles, Profiles", "admin/storefront-permissions.title": "Storefront Permissions", - "admin/storefront-permissions.description": "Roles and User management", + "admin/storefront-permissions.description": "Roles management", "admin/storefront-permissions.required": "Required", "admin/storefront-permissions.tab.new.button": "New", "admin/storefront-permissions.button.save": "Save", From 5958cc325f508ce675fd3caa68fb4080637641a5 Mon Sep 17 00:00:00 2001 From: Wender Lima Date: Tue, 26 Oct 2021 14:28:40 -0300 Subject: [PATCH 3/4] Removing unused code --- react/index.tsx | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/react/index.tsx b/react/index.tsx index a9ecef3..32152a4 100644 --- a/react/index.tsx +++ b/react/index.tsx @@ -4,27 +4,16 @@ import React, { useState } from 'react' import type { InjectedIntlProps } from 'react-intl' import { FormattedMessage, injectIntl } from 'react-intl' import { useQuery } from 'react-apollo' -import { useRuntime } from 'vtex.render-runtime' -import { Layout, PageBlock, PageHeader, Tabs, Tab } from 'vtex.styleguide' +import { Layout, PageBlock, PageHeader} from 'vtex.styleguide' import GET_CONFIG from './queries/getAppSettings.gql' const AdminB2bWaffle: FC = (props) => { - const { navigate, route } = useRuntime() - console.log('route', route) - const [activeTab, setActiveTab] = useState('admin.app.storefront-permissions.roles-list') const [state, setState] = useState({ missingConfig: true, }) - const setActiveSection = (section: string) => () => { - const path = `admin.app.storefront-permissions.${section}-list` - - setActiveTab(path) - navigate({ page: path }) - } - const { loading } = useQuery(GET_CONFIG, { onCompleted: (res: any) => { setState({ @@ -34,14 +23,6 @@ const AdminB2bWaffle: FC = (props) => { }, }) - const isActive = (currTab: string) => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - - const [_, current] = activeTab.split('admin.app.storefront-permissions') - const [section] = current.replace('.', '').split('-') - console.log('isActive', currTab, currTab === (section || 'roles')) - return currTab === (section || 'roles') - } return ( Date: Tue, 26 Oct 2021 14:29:46 -0300 Subject: [PATCH 4/4] Updating image from doc --- docs/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index fde6a17..b82d396 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,8 +8,7 @@ The **Storefront Permissions UI** is the interface for the APP [`vtex.storefront-permissions`](https://github.com/vtex-apps/storefront-permissions) -![image](https://user-images.githubusercontent.com/24723/129122444-16069c74-fc7d-4944-9f78-94cd72dbb8ab.png) - +![image](https://user-images.githubusercontent.com/24723/138930342-0b32937f-120b-49c9-9d3b-a20e350450a1.png) ## Functionalities