-
Notifications
You must be signed in to change notification settings - Fork 64
Show Central version in modal #1099
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
Draft
matthew-white
wants to merge
7
commits into
master
Choose a base branch
from
version-modal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f47aa07
Show Central version in modal
matthew-white 846cb5f
Merge branch 'master' into version-modal
matthew-white e30b1a2
Make small changes to modal
matthew-white d07f0cc
Use centralVersion specified in client-config.json
matthew-white 47a475e
Move container option into individual tests
matthew-white f510bc9
Move currentDate into container and set it after each response
matthew-white 841e9a2
Change centralVersion from requestData resource to computed ref
matthew-white File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!-- | ||
Copyright 2024 ODK Central Developers | ||
See the NOTICE file at the top-level directory of this distribution and at | ||
https://github.com/getodk/central-frontend/blob/master/NOTICE. | ||
|
||
This file is part of ODK Central. It is subject to the license terms in | ||
the LICENSE file found in the top-level directory of this distribution and at | ||
https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
including this file, may be copied, modified, propagated, or distributed | ||
except according to the terms contained in the LICENSE file. | ||
--> | ||
<template> | ||
<modal id="central-version" :state="state" hideable size="large" backdrop | ||
@hide="$emit('hide')"> | ||
<template #title>{{ $t('title') }}</template> | ||
<template #body> | ||
<div class="modal-introduction"> | ||
<p>{{ $t('shortVersion', { version: centralVersion.currentVersion }) }}</p> | ||
<p>{{ $t('longVersion') }}</p> | ||
<pre><code><selectable wrap>{{ centralVersion.versionText }}</selectable></code></pre> | ||
</div> | ||
<div class="modal-actions"> | ||
<button type="button" class="btn btn-primary" @click="$emit('hide')"> | ||
{{ $t('action.close') }} | ||
</button> | ||
</div> | ||
</template> | ||
</modal> | ||
</template> | ||
|
||
<script setup> | ||
import Modal from './modal.vue'; | ||
import Selectable from './selectable.vue'; | ||
|
||
import useCentralVersion from '../composables/central-version'; | ||
|
||
defineOptions({ | ||
name: 'CentralVersion' | ||
}); | ||
defineProps({ | ||
state: Boolean | ||
}); | ||
defineEmits(['hide']); | ||
|
||
const centralVersion = useCentralVersion(); | ||
</script> | ||
|
||
<style lang="scss"> | ||
#central-version { | ||
.loading { min-height: 120px; } | ||
} | ||
</style> | ||
|
||
<i18n lang="json5"> | ||
{ | ||
"en": { | ||
// This is the title at the top of a pop-up. It refers to the version of ODK | ||
// Central that the user is using. | ||
"title": "Central Version", | ||
"shortVersion": "You are using ODK Central {version}.", | ||
"longVersion": "You can find more detailed version information below:" | ||
} | ||
} | ||
</i18n> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2024 ODK Central Developers | ||
See the NOTICE file at the top-level directory of this distribution and at | ||
https://github.com/getodk/central-frontend/blob/master/NOTICE. | ||
|
||
This file is part of ODK Central. It is subject to the license terms in | ||
the LICENSE file found in the top-level directory of this distribution and at | ||
https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
including this file, may be copied, modified, propagated, or distributed | ||
except according to the terms contained in the LICENSE file. | ||
*/ | ||
import { F } from 'ramda'; | ||
import { computed, watchEffect } from 'vue'; | ||
|
||
import useCallWait from './call-wait'; | ||
import { memoizeForContainer } from '../util/composable'; | ||
import { useRequestData } from '../request-data'; | ||
|
||
export default memoizeForContainer(({ i18n, alert, config }) => { | ||
const centralVersion = computed(() => { | ||
if (!config.dataExists) return null; | ||
const versionText = config.centralVersion; | ||
if (versionText == null) return null; | ||
return { | ||
versionText, | ||
currentVersion: versionText.match(/\(v(\d{4}[^-]*)/)[1] | ||
}; | ||
}); | ||
|
||
// Check for a change to /version.txt. | ||
const { createResource } = useRequestData(); | ||
const latestVersion = createResource('latestVersion'); | ||
const { callWait } = useCallWait(); | ||
// Alerts the user about a version change, then keep alerting them. One | ||
// benefit of this approach is that the user should see the alert even if | ||
// there is another alert (say, about session expiration). | ||
const alertAboutChange = () => { | ||
callWait( | ||
'centralVersion.alert', | ||
() => { alert.info(i18n.t('alert.versionChange')); }, | ||
(count) => (count === 0 ? 0 : 60000) | ||
); | ||
}; | ||
watchEffect(() => { | ||
if (centralVersion.value == null) return; | ||
callWait( | ||
'centralVersion.check', | ||
() => latestVersion.request({ url: '/version.txt', alert: false }) | ||
.then(() => { | ||
if (latestVersion.data === centralVersion.value.versionText) | ||
return false; | ||
alertAboutChange(); | ||
return true; | ||
}) | ||
.catch(F), | ||
() => 60000 | ||
); | ||
}); | ||
|
||
return centralVersion; | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.