woodpecker/web/src/compositions/usePipelineFeed.ts
Robert Kaussow 718ec6141c
close sidebar on outside click (#2325)
[record.webm](https://github.com/woodpecker-ci/woodpecker/assets/3391958/f797be2c-09a9-4699-be85-7d5925e146ed)

---------

Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
2023-09-07 22:28:36 +02:00

35 lines
924 B
TypeScript

import { computed, toRef } from 'vue';
import useUserConfig from '~/compositions/useUserConfig';
import { usePipelineStore } from '~/store/pipelines';
import useAuthentication from './useAuthentication';
const { userConfig, setUserConfig } = useUserConfig();
export default () => {
const pipelineStore = usePipelineStore();
const { isAuthenticated } = useAuthentication();
const isOpen = computed(() => userConfig.value.isPipelineFeedOpen && !!isAuthenticated);
function toggle() {
setUserConfig('isPipelineFeedOpen', !userConfig.value.isPipelineFeedOpen);
}
function close() {
setUserConfig('isPipelineFeedOpen', false);
}
const sortedPipelines = toRef(pipelineStore, 'pipelineFeed');
const activePipelines = toRef(pipelineStore, 'activePipelines');
return {
toggle,
close,
isOpen,
sortedPipelines,
activePipelines,
load: pipelineStore.loadPipelineFeed,
};
};