Skip to content

Commit

Permalink
Merge pull request #3 from vtex-apps/feature/remove-users-list-route
Browse files Browse the repository at this point in the history
[PERMISSIONS-13] Changed default route to roles/list
  • Loading branch information
wender authored Oct 26, 2021
2 parents 7fb2596 + 9f94096 commit f74f063
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 43 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion admin/navigation.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 4 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -102,6 +101,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` |
2 changes: 1 addition & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
38 changes: 2 additions & 36 deletions react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +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<InjectedIntlProps> = (props) => {
const { navigate, route } = useRuntime()
const [activeTab, setActiveTab] = useState(route.id)

const [state, setState] = useState<any>({
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({
Expand All @@ -32,13 +23,6 @@ const AdminB2bWaffle: FC<InjectedIntlProps> = (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')
}

return (
<Layout
Expand All @@ -53,24 +37,6 @@ const AdminB2bWaffle: FC<InjectedIntlProps> = (props) => {
>
<PageBlock>
<>
<Tabs fullWidth>
<Tab
label={
<FormattedMessage id="admin/storefront-permissions.tab.users" />
}
active={isActive('users')}
onClick={setActiveSection('users')}
disabled={loading}
></Tab>
<Tab
label={
<FormattedMessage id="admin/storefront-permissions.tab.roles" />
}
active={isActive('roles')}
onClick={setActiveSection('roles')}
disabled={loading}
></Tab>
</Tabs>
{props.children}
</>
</PageBlock>
Expand Down

0 comments on commit f74f063

Please sign in to comment.