-
Notifications
You must be signed in to change notification settings - Fork 10
Add flow for existing users to accept new policies #1160
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,15 @@ export const getCurrentPolicies = async () => { | |
| const { data } = await axios.get('/v1/policies/current') | ||
| return data.items | ||
| } | ||
| export const getMissingPolicies = async () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const { data } = await axios.get('/v1/policies/missing') | ||
| return data.items | ||
| } | ||
| export const acceptPolicies = async (policyIds) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| await axios.put('/v1/policy_acceptances', { | ||
| policy_ids: policyIds, | ||
| }) | ||
| } | ||
|
|
||
| /* Wiki endpoints */ | ||
| export const countWikis = async () => (await axios.get('/wiki/count')).data.data // TODO This doesn't seem to exist and not used? | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <template> | ||
| <v-snackbar | ||
| :value="show" | ||
| color="error" | ||
| :timeout="timeout" | ||
| @input="hide" | ||
| > | ||
| {{ message }} | ||
| <template | ||
| v-if="dismissible" | ||
| v-slot:action="{ attrs }" | ||
| > | ||
| <v-btn | ||
| icon | ||
| v-bind="attrs" | ||
| @click="hide" | ||
| > | ||
| <v-icon>mdi-close</v-icon> | ||
| </v-btn> | ||
| </template> | ||
| </v-snackbar> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| computed: { | ||
| show: function () { | ||
| return this.$store.getters.hasLatestError | ||
| }, | ||
| dismissible: function () { | ||
| return this.$store.getters.latestErrorDismissible | ||
| }, | ||
| timeout: function () { | ||
| return this.dismissible ? 5000 : -1 | ||
| }, | ||
| message: function () { | ||
| return this.$store.getters.latestErrorMessage | ||
| }, | ||
| }, | ||
| methods: { | ||
| hide () { | ||
| this.$store.dispatch('clearLatestError') | ||
| }, | ||
| }, | ||
| } | ||
| </script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <template> | ||
| <div style="display: contents"> | ||
| <div | ||
| v-for="(policy, idx) in policies" | ||
| :key="policy.metadata.policy_id" | ||
| style="display: contents" | ||
| > | ||
| <span>{{ getPolicySeparator(idx) }}</span> | ||
| <v-tooltip v-if="clickable" bottom> | ||
| <template v-slot:activator="{ on }"> | ||
| <a | ||
| target="_blank" | ||
| :href="getPolicyUrl(policy)" | ||
| @click.stop | ||
| v-on="on" | ||
| >{{ getPolicyName(policy) }}</a> | ||
| </template> | ||
| Opens in new window | ||
| </v-tooltip> | ||
| <span v-else> | ||
| {{ getPolicyName(policy) }} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| export default { | ||
| props: { | ||
| policies: { | ||
| type: Array, | ||
| }, | ||
| article: { | ||
| type: String, | ||
| default: 'the ', | ||
| }, | ||
| clickable: { | ||
| type: Boolean, | ||
| default: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| getPolicyName (policy) { | ||
| return policy.metadata.type.replaceAll('-', ' ') | ||
| }, | ||
| getPolicyUrl (policy) { | ||
| return `/${policy.metadata.type}/${policy.metadata.active_from}` | ||
| }, | ||
| getPolicySeparator (idx) { | ||
| const count = this.policies.length | ||
| if (idx === 0) { | ||
| return ' ' | ||
| } else if (count === 2) { | ||
| return ` and ${this.article}` | ||
| } else if (idx === count - 1) { | ||
| return `, and ${this.article}` | ||
| } else { | ||
| return `, ${this.article}` | ||
| } | ||
| }, | ||
| }, | ||
| } | ||
| </script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| <template> | ||
| <div class="overlay"> | ||
| <v-card max-width="580"> | ||
| <v-card-title> | ||
| Updated policies | ||
| </v-card-title> | ||
| <v-card-text> | ||
| <p class="text-body-1"> | ||
| Please accept the updated | ||
| <PolicyList | ||
| :policies="policies" | ||
| article="" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| :clickable="false" | ||
| /> | ||
| to continue using Wikibase Cloud. | ||
| If you prefer not to keep your account, you can contact us to delete it. | ||
| </p> | ||
| <v-checkbox | ||
| v-model="accepted" | ||
| hide-details | ||
| class="mt-2" | ||
| :disabled="inFlight" | ||
| > | ||
| <template v-slot:label> | ||
| <div class="text-body-1"> | ||
| I agree to the | ||
| <PolicyList :policies="policies"/> | ||
| <span>.</span> | ||
| </div> | ||
| </template> | ||
| </v-checkbox> | ||
| </v-card-text> | ||
| <v-card-actions> | ||
| <v-btn | ||
| text | ||
| color="primary" | ||
| @click="onContactForm" | ||
| :disabled="inFlight" | ||
| > | ||
| Contact Form | ||
| </v-btn> | ||
| <v-btn | ||
| color="primary" | ||
| :disabled="!accepted || inFlight" | ||
| @click="onAccept" | ||
| > | ||
| Continue | ||
| </v-btn> | ||
| </v-card-actions> | ||
| </v-card> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import PolicyList from '../Components/PolicyList' | ||
|
|
||
| export default { | ||
| components: { | ||
| PolicyList, | ||
| }, | ||
| data () { | ||
| return { | ||
| accepted: false, | ||
| inFlight: false, | ||
| } | ||
| }, | ||
| computed: { | ||
| policies () { | ||
| return this.$store.getters.missingPolicies | ||
| }, | ||
| }, | ||
| methods: { | ||
| onContactForm () { | ||
| this.$router.push('/contact') | ||
| }, | ||
| async onAccept () { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| this.inFlight = true | ||
| const policyIds = Array.from( | ||
| this.policies, | ||
| policy => policy.metadata.policy_id, | ||
| ) | ||
| await this.$store.dispatch('acceptPolicies', policyIds) | ||
| this.inFlight = false | ||
| }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional:
|
||
| }, | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .overlay { | ||
| background: rgba(0, 0, 0, 0.25); | ||
| position: absolute; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| inset: 0; | ||
| z-index: 10; | ||
| overflow: auto; | ||
| } | ||
| </style> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really get this bit...
hasMissingPoliciesreturnsmissingPolicies?.length, which is a number (or worst caseundefined). Since this is used inv-if, is it less error-prone to return an explicit boolean (for example,(this.$store.getters.missingPolicies?.length ?? 0) > 0)?