Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline menus #656

Merged
merged 7 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions accounts/pkg/assets/embed.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion accounts/ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const navItems = [
route: {
name: 'accounts',
path: `/${appInfo.id}/`
}
},
menu: 'user'
}
]

Expand Down
8 changes: 7 additions & 1 deletion accounts/ui/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
</div>
</oc-grid>
</template>
<template v-else-if="hasFailed">
<oc-alert variation="warning" no-close class="oc-m">
<oc-icon name="warning" variation="warning" class="uk-float-left oc-mr-s" />
<translate>You don't have permissions to manage accounts.</translate>
</oc-alert>
</template>
<oc-loader v-else />
</div>
</div>
Expand All @@ -31,7 +37,7 @@ export default {
name: 'App',
components: { AccountsBatchActions, AccountsList, AccountsCreate },
computed: {
...mapGetters('Accounts', ['isInitialized', 'getAccountsSorted', 'isAnyAccountSelected']),
...mapGetters('Accounts', ['isInitialized', 'hasFailed', 'getAccountsSorted', 'isAnyAccountSelected']),
...mapState('Accounts', ['selectedAccounts']),

accounts () {
Expand Down
10 changes: 5 additions & 5 deletions accounts/ui/components/accounts/AccountsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<oc-table-row class="fix-table-header">
<oc-table-cell shrink type="head" class="uk-text-center">
<oc-checkbox
class="oc-ml-s"
:value="areAllAccountsSelected"
@input="toggleSelectionAll"
:label="$gettext('Select all users')"
hide-label
class="oc-ml-s"
:value="areAllAccountsSelected"
@input="toggleSelectionAll"
:label="$gettext('Select all users')"
hide-label
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fixing incorrect indentation here.

/>
</oc-table-cell>
<oc-table-cell shrink type="head" />
Expand Down
75 changes: 39 additions & 36 deletions accounts/ui/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { injectAuthToken } from '../helpers/auth'
const state = {
config: null,
initialized: false,
failed: false,
accounts: {},
roles: null,
selectedAccounts: []
Expand All @@ -20,6 +21,7 @@ const state = {
const getters = {
config: state => state.config,
isInitialized: state => state.initialized,
hasFailed: state => state.failed,
getAccountsSorted: state => {
return Object.values(state.accounts).sort((a1, a2) => {
if (a1.onPremisesSamAccountName === a2.onPremisesSamAccountName) {
Expand All @@ -39,6 +41,9 @@ const mutations = {
SET_INITIALIZED (state, value) {
state.initialized = value
},
SET_FAILED (state, value) {
state.failed = value
},
SET_ACCOUNTS (state, accounts) {
state.accounts = accounts
},
Expand All @@ -47,7 +52,6 @@ const mutations = {
},
TOGGLE_SELECTION_ACCOUNT (state, account) {
const accountIndex = state.selectedAccounts.indexOf(account)

accountIndex > -1 ? state.selectedAccounts.splice(accountIndex, 1) : state.selectedAccounts.push(account)
},
SET_SELECTED_ACCOUNTS (state, accounts) {
Expand Down Expand Up @@ -80,49 +84,48 @@ const actions = {
commit('LOAD_CONFIG', config)
},

async initialize ({ commit, dispatch }) {
await dispatch('fetchAccounts')
await dispatch('fetchRoles')
commit('SET_INITIALIZED', true)
async initialize ({ commit, dispatch, getters }) {
await Promise.all([
dispatch('fetchAccounts'),
dispatch('fetchRoles')
])
if (!getters.hasFailed) {
commit('SET_INITIALIZED', true)
}
},

async fetchAccounts ({ commit, dispatch, rootGetters }) {
async fetchAccounts ({ commit, rootGetters }) {
injectAuthToken(rootGetters.user.token)
const response = await AccountsService_ListAccounts({
$domain: rootGetters.configuration.server,
body: {}
})
if (response.status === 201) {
const accounts = response.data.accounts
commit('SET_ACCOUNTS', accounts || [])
} else {
dispatch('showMessage', {
title: 'Failed to fetch accounts.',
desc: response.statusText,
status: 'danger'
}, { root: true })
try {
const response = await AccountsService_ListAccounts({
$domain: rootGetters.configuration.server,
body: {}
})
if (response.status === 201) {
const accounts = response.data.accounts
commit('SET_ACCOUNTS', accounts || [])
return
}
} catch (e) {
}
commit('SET_FAILED', true)
},

async fetchRoles ({ commit, dispatch, rootGetters }) {
async fetchRoles ({ commit, rootGetters }) {
injectAuthToken(rootGetters.user.token)

const response = await RoleService_ListRoles({
$domain: rootGetters.configuration.server,
body: {}
})

if (response.status === 201) {
const roles = response.data.bundles

commit('SET_ROLES', roles || [])
} else {
dispatch('showMessage', {
title: 'Failed to fetch roles.',
desc: response.statusText,
status: 'danger'
}, { root: true })
try {
const response = await RoleService_ListRoles({
$domain: rootGetters.configuration.server,
body: {}
})
if (response.status === 201) {
const roles = response.data.bundles
commit('SET_ROLES', roles || [])
return
}
} catch (e) {
}
commit('SET_FAILED', true)
},

toggleSelectionAll ({ commit, getters, state }) {
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/account-permissions-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Accounts UI shows message when no permissions

We improved the UX of the accounts UI by showing a message information the user about missing permissions when the accounts or roles fail to load. This was showing an indeterminate progress bar before.

https://github.com/owncloud/ocis/pull/656
5 changes: 5 additions & 0 deletions changelog/unreleased/user-menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Settings and accounts appear in the user menu

We moved settings and accounts to the user menu.

https://github.com/owncloud/ocis/pull/656
2 changes: 1 addition & 1 deletion ocis-phoenix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ NAME := ocis-phoenix
IMPORT := github.com/owncloud/ocis/$(NAME)
BIN := bin
DIST := dist
PHOENIX_ASSETS_VERSION = v0.18.0
PHOENIX_ASSETS_VERSION = v0.19.0

ifeq ($(OS), Windows_NT)
EXECUTABLE := $(NAME).exe
Expand Down
10 changes: 5 additions & 5 deletions ocis-phoenix/pkg/assets/embed.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions ocis-phoenix/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func (p Phoenix) getPayload() (payload []byte, err error) {

if p.config.Phoenix.Config.ExternalApps == nil {
p.config.Phoenix.Config.ExternalApps = []config.ExternalApp{
{
ID: "accounts",
Path: "/accounts.js",
},
{
ID: "settings",
Path: "/settings.js",
},
{
ID: "accounts",
Path: "/accounts.js",
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the order because it is the order in which the navItems are rendered in the respective menu. We want to settings navItem first after the Profile navItem.

}
}

Expand Down
6 changes: 3 additions & 3 deletions settings/pkg/assets/embed.go

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion settings/ui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const navItems = [
route: {
name: 'settings',
path: `/${appInfo.id}/`
}
},
menu: 'user'
}
]

Expand Down