2023-04-24 03:18:24 -07:00
|
|
|
import type { WorkflowTitleStatus } from '@/Interface';
|
2023-11-28 03:15:08 -08:00
|
|
|
import { useSettingsStore } from '@/stores/settings.store';
|
2023-10-03 11:49:04 -07:00
|
|
|
|
2023-04-21 06:48:07 -07:00
|
|
|
export function useTitleChange() {
|
2023-10-02 08:33:43 -07:00
|
|
|
const prependBeta = (title: string) => {
|
|
|
|
const settingsStore = useSettingsStore();
|
2023-10-03 11:49:04 -07:00
|
|
|
const { releaseChannel } = settingsStore.settings;
|
|
|
|
return releaseChannel === 'stable' ? title : `[${releaseChannel.toUpperCase()}] ${title}`;
|
2023-10-02 08:33:43 -07:00
|
|
|
};
|
|
|
|
|
2023-05-15 09:41:13 -07:00
|
|
|
const titleSet = (workflow: string, status: WorkflowTitleStatus) => {
|
|
|
|
let icon = '⚠️';
|
|
|
|
if (status === 'EXECUTING') {
|
|
|
|
icon = '🔄';
|
|
|
|
} else if (status === 'IDLE') {
|
|
|
|
icon = '▶️';
|
|
|
|
}
|
|
|
|
|
2023-10-02 08:33:43 -07:00
|
|
|
window.document.title = prependBeta(`n8n - ${icon} ${workflow}`);
|
2023-05-15 09:41:13 -07:00
|
|
|
};
|
2023-04-21 06:48:07 -07:00
|
|
|
|
2023-05-15 09:41:13 -07:00
|
|
|
const titleReset = () => {
|
2023-10-02 08:33:43 -07:00
|
|
|
window.document.title = prependBeta('n8n - Workflow Automation');
|
2023-05-15 09:41:13 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
titleSet,
|
|
|
|
titleReset,
|
2023-04-21 06:48:07 -07:00
|
|
|
};
|
|
|
|
}
|