Skip to content
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: 5 additions & 1 deletion e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ interface InstanceConfig {
}

async function fetchInstanceConfig(): Promise<InstanceConfig> {
const resp = await fetch(`${apiUrl}/info/`);
const url = `${apiUrl}/info/`;
const resp = await fetch(url);
if (!resp.ok) {
throw new Error(`Failed to fetch instance config from ${url}: ${resp.status} ${resp.statusText}`);
}
const data = await resp.json();
return data.instance_config;
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/check-no-hardcoded-dandi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ for file in "$@"; do

# Check for DANDI: as identifier prefix in string/template literals
# Match patterns like `DANDI:${...}`, "DANDI:", 'DANDI:'
if grep -nE '("|'\''|`)\s*DANDI:' "$file" >/dev/null 2>&1; then
if grep -nE '("|'\''|`)[[:space:]]*DANDI:' "$file" >/dev/null 2>&1; then
echo "$file: found hardcoded 'DANDI:' identifier prefix — use instanceName from the instance store"
ERRORS=$((ERRORS + 1))
fi

# Check for lowercase dandi: used as citation key prefix (followed by digits or ${)
# Excludes schema URIs like dandi:OpenAccess, dandi:EmbargoedAccess
if grep -nE '("|'\''|`)\s*dandi:\$\{' "$file" >/dev/null 2>&1 || \
grep -nE '("|'\''|`)\s*dandi:[0-9]' "$file" >/dev/null 2>&1; then
if grep -nE '("|'\''|`)[[:space:]]*dandi:\$\{' "$file" >/dev/null 2>&1 || \
grep -nE '("|'\''|`)[[:space:]]*dandi:[0-9]' "$file" >/dev/null 2>&1; then
echo "$file: found hardcoded 'dandi:' identifier prefix — use instanceName.toLowerCase() from the instance store"
ERRORS=$((ERRORS + 1))
fi

# Check for "DANDI Archive" as publisher name in string literals
# Exclude HTML comments (<!-- ... -->)
if grep -nE "(\"|\`|').*DANDI Archive" "$file" | grep -vE '^\s*<!--' >/dev/null 2>&1; then
if grep -nE "(\"|\`|').*DANDI Archive" "$file" | grep -vE '^[[:space:]]*<!--' >/dev/null 2>&1; then
echo "$file: found hardcoded 'DANDI Archive' — use instanceName from the instance store"
ERRORS=$((ERRORS + 1))
fi
Expand Down
22 changes: 10 additions & 12 deletions web/src/components/DLP/HowToCiteTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -346,18 +346,15 @@ const formattedCitations = computed<Record<CitationFormat, string>>(() => {
cff: '',
};
}
const dandiset_version_identifier = dandisetVersionIdentifier.value;
const instance_name = instanceName.value;

return {
apa: cffToAPA(cffObject.value, instance_name),
mla: cffToMLA(cffObject.value, instance_name),
chicago: cffToChicago(cffObject.value, instance_name),
harvard: cffToHarvard(cffObject.value, instance_name),
vancouver: cffToVancouver(cffObject.value, instance_name),
ieee: cffToIEEE(cffObject.value, instance_name),
bibtex: cffToBibTeX(cffObject.value, dandiset_version_identifier, instance_name),
ris: cffToRIS(cffObject.value, dandiset_version_identifier, instance_name),
apa: cffToAPA(cffObject.value, instanceName.value),
mla: cffToMLA(cffObject.value, instanceName.value),
chicago: cffToChicago(cffObject.value, instanceName.value),
harvard: cffToHarvard(cffObject.value, instanceName.value),
vancouver: cffToVancouver(cffObject.value, instanceName.value),
ieee: cffToIEEE(cffObject.value, instanceName.value),
bibtex: cffToBibTeX(cffObject.value, dandisetVersionIdentifier.value, instanceName.value),
ris: cffToRIS(cffObject.value, dandisetVersionIdentifier.value, instanceName.value),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

imho it was better before - shorter variables made it easier to read... rationale is not listed among items -- do you see what it was ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

snake_case → camelCase

cff: cffToYAML(cffObject.value),
};
});
Expand Down Expand Up @@ -413,7 +410,8 @@ const dandiUrl = computed(() => {
}

const { identifier } = currentDandiset.value.dandiset;
return `https://dandiarchive.org/dandiset/${identifier}`;
const baseUrl = instanceStore.instanceUrl || window.location.origin;
return `${baseUrl}/dandiset/${identifier}`;
});

const methodsText = computed(() => {
Expand Down
5 changes: 5 additions & 0 deletions web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ import App from './App.vue'
// Composables
import { createApp } from 'vue'

import { useInstanceStore } from '@/stores/instance'

const app = createApp(App)

registerPlugins(app)
registerDirectives(app)

// Fetch instance config early so page titles and identifiers are available
useInstanceStore().fetchInstanceInfo();

app.mount('#app')
9 changes: 9 additions & 0 deletions web/src/stores/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface InstanceState {
instanceIdentifier: string | null;
instanceUrl: string | null;
loaded: boolean;
_fetchPromise: Promise<void> | null;
}

export const useInstanceStore = defineStore('instance', {
Expand All @@ -15,12 +16,20 @@ export const useInstanceStore = defineStore('instance', {
instanceIdentifier: null,
instanceUrl: null,
loaded: false,
_fetchPromise: null,
}),
actions: {
async fetchInstanceInfo() {
if (this.loaded) {
return;
}
if (this._fetchPromise) {
return this._fetchPromise;
}
this._fetchPromise = this._doFetch();
return this._fetchPromise;
},
async _doFetch() {
const info = await dandiRest.info();
this.instanceName = info.instance_config.instance_name;
this.instanceIdentifier = info.instance_config.instance_identifier;
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/DandisetLandingView/DownloadDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ const currentVersion = computed(() => store.version);
const cliMinimalVersion = ref<string>();
const cliRequiresPython = ref<string>();
onMounted(async () => {
await instanceStore.fetchInstanceInfo();
const info = await dandiRest.info();
cliMinimalVersion.value = info['cli-minimal-version'];
cliRequiresPython.value = info['cli-requires-python'];
await instanceStore.fetchInstanceInfo();
});

const selectedDownloadOption = ref('draft');
Expand Down
Loading