n8n/packages/editor-ui/src/composables/useTitleChange.ts
2023-11-28 12:15:08 +01:00

31 lines
808 B
TypeScript

import type { WorkflowTitleStatus } from '@/Interface';
import { useSettingsStore } from '@/stores/settings.store';
export function useTitleChange() {
const prependBeta = (title: string) => {
const settingsStore = useSettingsStore();
const { releaseChannel } = settingsStore.settings;
return releaseChannel === 'stable' ? title : `[${releaseChannel.toUpperCase()}] ${title}`;
};
const titleSet = (workflow: string, status: WorkflowTitleStatus) => {
let icon = '⚠️';
if (status === 'EXECUTING') {
icon = '🔄';
} else if (status === 'IDLE') {
icon = '▶️';
}
window.document.title = prependBeta(`n8n - ${icon} ${workflow}`);
};
const titleReset = () => {
window.document.title = prependBeta('n8n - Workflow Automation');
};
return {
titleSet,
titleReset,
};
}