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

[full-ci] Move language selection to the account page and kill settings app #8294

Merged
merged 6 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Move language selection to user account page

The language selection has been moved from the settings app to the personal account page.
The settings app has been removed from the default configs because we don't need it currently.

https://github.com/owncloud/web/pull/8294
6 changes: 0 additions & 6 deletions config/config.json.sample-ocis
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
"external",
"admin-settings"
],
"external_apps": [
{
"id": "settings",
"path": "https://localhost:9200/settings.js"
}
],
"options" : {
"previewFileMimeTypes" : [
"image/gif",
Expand Down
4 changes: 0 additions & 4 deletions config/vite_ocis/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
"config": {
"mimeTypes": ["image/tiff","image/bmp","image/x-ms-bmp"]
}
},
{
"id": "settings",
"path": "/settings.js"
}
]
}
4 changes: 0 additions & 4 deletions dev/docker/ocis.web.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
"mimeTypes": ["image/tiff","image/bmp","image/x-ms-bmp"]
}
},
{
"id": "settings",
"path": "/settings.js"
},
{
"id": "draw-io",
"path": "web-app-draw-io",
Expand Down
96 changes: 93 additions & 3 deletions packages/web-runtime/src/pages/account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,26 +75,116 @@
>
</dd>
</div>
<div class="account-page-info-language oc-mb oc-width-1-2@s">
<dt v-translate class="oc-text-normal oc-text-muted">Language</dt>
<dd data-testid="language">
<oc-select
v-if="languageOptions"
:model-value="selectedLanguageOption"
:clearable="false"
:options="languageOptions"
@update:modelValue="updateSelectedLanguage"
/>
</dd>
</div>
</dl>
</main>
</template>

<script lang="ts">
import { mapActions, mapGetters } from 'vuex'
import EditPasswordModal from '../components/EditPasswordModal.vue'
import { defineComponent } from 'vue'
import { useGraphClient } from 'web-pkg/src/composables'
import { computed, defineComponent, onMounted, unref } from 'vue'
import { useAccessToken, useGraphClient, useStore } from 'web-pkg/src/composables'
import { urlJoin } from 'web-client/src/utils'
import { configurationManager } from 'web-pkg/src/configuration'
import { useTask } from 'vue-concurrency'
import axios from 'axios'
import { v4 as uuidV4 } from 'uuid'

export default defineComponent({
name: 'Personal',
components: {
EditPasswordModal
},
setup() {
const store = useStore()
const accessToken = useAccessToken({ store })
const loadLanguagesTask = useTask(function* () {
try {
const {
data: { bundles }
} = yield axios.post(
'/api/v0/settings/bundles-list',
{},
{
headers: {
authorization: `Bearer ${unref(accessToken)}`,
'X-Request-ID': uuidV4()
}
}
)

const accountBundle = bundles.find((b) => b.extension === 'ocis-accounts')
return accountBundle.settings.find((s) => s.name === 'language')?.singleChoiceValue.options
} catch (e) {
console.error(e)
return []
}
}).restartable()

const accountSettingIdentifier = {
extension: 'ocis-accounts',
bundle: 'profile',
setting: 'language'
}
const languageSetting = computed(() => {
return store.getters.getSettingsValue(accountSettingIdentifier)
})
const languageOptions = computed(() => {
return loadLanguagesTask.last?.value?.map((l) => ({
label: l.displayValue,
value: l.value.stringValue
}))
})
const selectedLanguageOption = computed(() => {
const current = unref(languageSetting).listValue.values[0].stringValue
return unref(languageOptions).find((o) => o.value === current)
})
const updateSelectedLanguage = (option) => {
axios.post(
'/api/v0/settings/values-save',
{
value: {
...unref(languageSetting),
listValue: { values: [{ stringValue: option.value }] },
accountUuid: 'me'
}
},
{
headers: {
authorization: `Bearer ${unref(accessToken)}`,
'X-Request-ID': uuidV4()
}
}
)

store.commit('SET_SETTINGS_VALUE', {
identifier: accountSettingIdentifier,
value: {
...unref(languageSetting),
listValue: { values: [{ stringValue: option.value }] }
}
})
}
onMounted(() => {
loadLanguagesTask.perform()
})
return {
...useGraphClient()
...useGraphClient(),
languageOptions,
selectedLanguageOption,
updateSelectedLanguage
}
},
data() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ exports[`account page account information displays basic user information 1`] =
<span data-current-language="en" data-msgid="You are not part of any group">You are not part of any group</span>
</dd>
</div>
<div class="account-page-info-language oc-mb oc-width-1-2@s">
<dt class="oc-text-normal oc-text-muted" data-current-language="en" data-msgid="Language">Language</dt>
<dd>
<!--v-if-->
</dd>
</div>
</dl>
`;

Expand Down