Skip to content

Commit ab7efb0

Browse files
committed
Merge branch 'feature/documentos-oficiais' into dev/v7.7-alpha
2 parents 343a5b6 + d9c2e09 commit ab7efb0

File tree

12 files changed

+262
-30
lines changed

12 files changed

+262
-30
lines changed

scripts/deploy-ref.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## Script para deploy de uma referëncia qualquer (branch, tag ou PR) ##
2+
3+
exibir_uso_correto() {
4+
echo "Usar: $0 <versao> [opcao]"
5+
echo "Onde:"
6+
echo " <versao> indica a branch, a tag ou o PR a publicar."
7+
echo " no caso de branch ou tag, escreva o nome dela;"
8+
echo " no caso de PR, escreva pull/<numero_do_pr>"
9+
echo " Exemplos:"
10+
echo " $0 v7.6.0-minc14 => publicará a tag v7.6.0-minc14"
11+
echo " $0 $STABLE_BRANCH => publicará a branch $STABLE_BRANCH"
12+
echo " $0 pull/39 => publicará o PR#39"
13+
echo " [opcao] indica o que deve ser feito após a preparação do diretório"
14+
echo " se omitida, fará build da versão desejada, seguirá"
15+
echo " realizando o build, derrubando a versão corrente, e concluirá"
16+
echo " subindo a nova versão."
17+
echo " --build-only fará somente o build, sem mexer na instância em execução"
18+
echo " --clone-only fará somente a preparação do diretório e nem faz o build"
19+
}
20+
configurar_detalhes_minc() {
21+
mkdir $DEPLOY_DIR/docker-data
22+
ln -s $PRIVATE_FILES_PATH $DEPLOY_DIR/docker-data/private-files
23+
ln -s $PUBLIC_FILES_PATH $DEPLOY_DIR/docker-data/public-files
24+
cp -r $SPECS_PATH/. $DEPLOY_DIR
25+
}
26+
27+
# Verificações
28+
ENV_ERROR=0
29+
if [[ -z "$SPECS_PATH" ]]; then
30+
(( ENV_ERROR++ ))
31+
echo "#ENV_ERROR_$ENV_ERROR"
32+
echo " Este script requer a variável de ambiente \$SPECS_PATH contendo um diretório válido."
33+
echo " Esse diretório deve conter arquivos de especificações não publicados no repositório."
34+
fi
35+
if [[ ! -f "$SPECS_PATH/.env" ]]; then
36+
(( ENV_ERROR++ ))
37+
echo "#ENV_ERROR_$ENV_ERROR"
38+
echo " O arquivo '.env' deve estar no diretório especificado na variável de ambiente \$SPECS_PATH."
39+
echo " Esse arquivo deve conter as variáveis de ambiente necessárias para o funcionamento do sistema."
40+
fi
41+
if [ ! -d "$PRIVATE_FILES_PATH" ]; then
42+
(( ENV_ERROR++ ))
43+
echo "#ENV_ERROR_$ENV_ERROR"
44+
echo " Este script requer a variável de ambiente \$PRIVATE_FILES_PATH contendo um diretório válido."
45+
echo " Esse diretório será usado para persistir os arquivos privados do sistema."
46+
fi
47+
if [ ! -d "$PUBLIC_FILES_PATH" ]; then
48+
(( ENV_ERROR++ ))
49+
echo "#ENV_ERROR_$ENV_ERROR"
50+
echo " Este script requer a variável de ambiente \$PUBLIC_FILES_PATH contendo um diretório válido."
51+
echo " Esse diretório será usado para persistir os arquivos públicos do sistema."
52+
fi
53+
if [ -z "$SOURCE_REPO" ]; then
54+
(( ENV_ERROR++ ))
55+
echo "#ENV_ERROR_$ENV_ERROR"
56+
echo " Este script requer a variável de ambiente \$SOURCE_REPO definida."
57+
echo " Essa variável deve conter a URL do repositório de origem."
58+
fi
59+
if [ -z "$STABLE_BRANCH" ]; then
60+
(( ENV_ERROR++ ))
61+
echo "#ENV_ERROR_$ENV_ERROR"
62+
echo " Este script requer a variável de ambiente \$STABLE_BRANCH definida."
63+
echo " Essa variável deve conter o nome da branch estável considerada para atualizar PRs."
64+
fi
65+
if [ $ENV_ERROR -gt 0 ]; then
66+
exit 1
67+
fi
68+
if [[ $# -lt 1 || $# -gt 2 ]]; then
69+
echo "Erro: quantidade parâmetros incorreta."
70+
exibir_uso_correto
71+
exit 1
72+
else
73+
if [[ $# -ge 2 && ( $2 != '--build-only' && $2 != '--clone-only' ) ]]; then
74+
echo "Erro: segundo argumento é inválido."
75+
exibir_uso_correto
76+
exit 1
77+
fi
78+
fi
79+
80+
# Início das operações
81+
DEPLOY_DIR=/opt/mapas-deployed-`date +%Y%m%d%H%M`
82+
if [ ${1:0:5} = 'pull/' ]; then
83+
echo 'deploying PR#'${1:5:${#1}-5}
84+
git clone --recurse-submodules -b $STABLE_BRANCH $SOURCE_REPO $DEPLOY_DIR && cd $DEPLOY_DIR
85+
if [ $? -ne 0 ]; then exit $?; fi
86+
configurar_detalhes_minc
87+
git checkout -b teste-pr${1:5:${#1}-5}-atualizado && git fetch origin $1/head && git merge --no-ff --no-edit FETCH_HEAD
88+
if [ $? -ne 0 ]; then exit $?; fi
89+
echo 'Teste do PR#'${1:5:${#1}-5}' atualizado (commits:'`git rev-parse --short $STABLE_BRANCH`'+'`git rev-parse --short FETCH_HEAD`')' > version.txt
90+
else
91+
echo 'deploying branch/tag '$1
92+
git clone --recurse-submodules -b $1 $SOURCE_REPO $DEPLOY_DIR
93+
if [ $? -ne 0 ]; then exit $?; fi
94+
configurar_detalhes_minc
95+
fi
96+
cd $DEPLOY_DIR
97+
if [ -z $2 ]; then
98+
docker compose build
99+
if [ $? -ne 0 ]; then exit $?; fi
100+
docker stop $(docker ps -q)
101+
docker compose up -d
102+
echo 'Deployed tag "'$1'" on directory "'$DEPLOY_DIR'". It should be already running by now.'
103+
else
104+
if [ $2 = '--build-only' ]; then
105+
docker compose build
106+
echo 'Deployed tag "'$1'" on directory "'$DEPLOY_DIR'". Just built, will NOT run.'
107+
else
108+
if [ $2 = '--clone-only' ]; then
109+
echo 'Deployed tag "'$1'" on directory "'$DEPLOY_DIR'". Just source-code copied, not built neither run.'
110+
fi
111+
fi
112+
fi

scripts/publish-version.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## Script para gerar nova versão na branch de produção a partir de uma branch estável ##
2+
3+
exibir_uso_correto() {
4+
echo "Usar: $0 <versao> [versao_producao] [versao_candidata]"
5+
echo "Onde:"
6+
echo " <versao_producao> indentificador da versão a publicar."
7+
echo " Exemplo:"
8+
echo " $0 v7.6.0-minc14 => gerará versão identificada como v7.6.0-minc14"
9+
echo " <versao_candidata> indentificador da versão candidata a próxima publicação."
10+
echo " Exemplo:"
11+
echo " $0 v7.6.0-minc15-RC => gerará versão identificada como v7.6.0-minc15-RC"
12+
}
13+
14+
# Verificações
15+
ENV_ERROR=0
16+
if [[ -z "$COMMIT_MSG_NEW_VERSION" ]]; then
17+
(( ENV_ERROR++ ))
18+
echo "#ENV_ERROR_$ENV_ERROR"
19+
echo " Este script requer a variável de ambiente \$COMMIT_MSG_NEW_VERSION definida."
20+
echo " Essa variável deve conter a mensagem dos commits de atualização de versão."
21+
echo " Exemplo: 'Atualiza identificador de versão'"
22+
fi
23+
if [ -e "$STABLE_BRANCH/." ]; then
24+
(( ENV_ERROR++ ))
25+
echo "#ENV_ERROR_$ENV_ERROR"
26+
echo " Este script requer a variável de ambiente \$STABLE_BRANCH definida."
27+
echo " Essa variável deve conter o nome da branch estável que alimenta a branch de produção."
28+
echo " Exemplo: 'develop'"
29+
fi
30+
if [ -e "$PROD_BRANCH/." ]; then
31+
(( ENV_ERROR++ ))
32+
echo "#ENV_ERROR_$ENV_ERROR"
33+
echo " Este script requer a variável de ambiente \$PROD_BRANCH definida."
34+
echo " Essa variável deve conter o nome da branch de produção."
35+
echo " Exemplo: 'master'"
36+
fi
37+
if [ $ENV_ERROR -gt 0 ]; then
38+
exit 1
39+
fi
40+
if [[ $# -ne 2 ]]; then
41+
echo "Erro: quantidade parâmetros incorreta."
42+
exibir_uso_correto
43+
exit 1
44+
fi
45+
46+
git rev-parse --git-dir > /dev/null 2>&1;
47+
if [[ $? -ne 0 || ! -f "version.txt" ]];
48+
then
49+
echo "Este script precisa ser executado na raiz do repositório."
50+
echo "Pois é lá que está o arquivo 'version.txt' que precisa ser atualizado."
51+
exit 1
52+
fi
53+
54+
# Início das operações
55+
56+
# Posiciona-se no commit mais recente da branch estável
57+
58+
git switch $STABLE_BRANCH
59+
git pull
60+
61+
# Efetua ajustes da nova versão
62+
63+
git checkout -b release/$1
64+
echo $1 > version.txt
65+
git add version.txt
66+
git commit -m "$COMMIT_MSG_NEW_VERSION"
67+
68+
# Incorpora a branch estável à branch de produção
69+
70+
git switch $PROD_BRANCH
71+
git pull
72+
git merge --no-ff --no-edit -Xtheirs release/$1
73+
git push
74+
git tag $1
75+
git push origin $1
76+
77+
# Atualizar elementos relativos ao próximo release
78+
79+
git switch $STABLE_BRANCH
80+
git pull
81+
echo $2 > version.txt
82+
git add version.txt
83+
git commit -m "$COMMIT_MSG_NEW_VERSION"
84+
git push
85+

src/db-updates.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,20 @@ function __try($sql, $cb = null){
27162716
'requestEventRelation');");
27172717
},
27182718

2719+
'Normalização dos campos do tipo checkbox nas inscrições' => function() {
2720+
__exec("UPDATE registration_meta rm
2721+
SET value = '1'
2722+
FROM registration r
2723+
JOIN (SELECT opportunity_id, array_agg('field_' || rfc.id) AS fields
2724+
FROM registration_field_configuration rfc
2725+
WHERE rfc.field_type = 'checkbox'
2726+
GROUP BY opportunity_id
2727+
) AS towcf ON towcf.opportunity_id = r.opportunity_id
2728+
WHERE rm.object_id = r.id
2729+
AND rm.value != '1'
2730+
AND rm.key = ANY(towcf.fields);");
2731+
},
2732+
27192733
// SEMPRE ENCERRAR O ÚLTIMO ITEM COM VÍRGULA A FIM DE
27202734
// MINIMIZAR RISCO DE ERRO NA INSERÇÃO OU MERGE DE NOVOS ITENS
27212735

src/modules/Components/assets/js/components-base/API.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ globalThis.useEntitiesLists = Pinia.defineStore('entitiesLists', {
9090
globalThis.apiInstances = {};
9191

9292
class API {
93-
constructor(objectType, scope, fetchOptions) {
93+
constructor(objectType, scope = 'default', fetchOptions = undefined) {
9494
const instanceId = `${objectType}:${scope}`;
9595
if (apiInstances[instanceId]) {
9696
return apiInstances[instanceId];
@@ -99,7 +99,6 @@ class API {
9999
this.cache = useEntitiesCache();
100100
this.lists = useEntitiesLists();
101101
this.objectType = objectType;
102-
this.abortController = null;
103102
this.options = {
104103
cacheMode: 'force-cache',
105104
...fetchOptions
@@ -273,11 +272,9 @@ class API {
273272
return this.fetch('find', query, {list, raw, rawProcessor});
274273
}
275274

276-
async fetch(endpoint, query, {list, raw, rawProcessor, refresh}) {
275+
async fetch(endpoint, query, { list, raw, rawProcessor, refresh, signal }) {
277276
let url = this.createApiUrl(endpoint, query);
278-
this.abortController?.abort();
279-
this.abortController = new AbortController();
280-
return this.GET(url, {}, { signal: this.abortController.signal }).then(response => response.json().then(objs => {
277+
return this.GET(url, {}, { signal }).then(response => response.json().then(objs => {
281278
let result;
282279
if(raw) {
283280
rawProcessor = rawProcessor || Utils.entityRawProcessor;

src/modules/Components/components/mc-entities/script.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ app.component('mc-entities', {
44

55
data() {
66
return {
7+
abortController: null,
78
api: new API(this.type, this.scope || 'default'),
89
entities: [],
910
page: 1,
@@ -86,49 +87,53 @@ app.component('mc-entities', {
8687
}
8788

8889
},
89-
90+
9091
methods: {
9192
populateQuery(query) {
9293
if (this.select) {
9394
query['@select'] = this.select;
94-
}
95-
95+
}
96+
9697
if (this.ids) {
9798
query[this.API.$PK] = 'IN(' + this.ids.join(',') + ')'
9899
}
99100

100101
if (this.order) {
101102
query['@order'] = this.order;
102103
}
103-
104+
104105
if (this.limit) {
105106
query['@limit'] = this.limit;
106107
query['@page'] = this.page;
107108
}
108-
109+
109110
if (this.permissions) {
110111
query['@permissions'] = this.permissions;
111112
}
112113
},
113114

114115
getDataFromApi() {
115116
let query = {...this.query};
116-
117+
117118
this.$emit('loading', query);
118-
119+
119120
this.populateQuery(query);
120121

121122
const options = {list: this.entities, refresh: true};
122123

123124
if (this.limit && this.page) {
124125
query['@page'] = this.page;
125126
}
126-
127+
127128
if (this.rawProcessor) {
128129
options.raw = true;
129130
options.rawProcessor = this.rawProcessor;
130131
};
131132

133+
this.abortController?.abort();
134+
this.abortController = new AbortController();
135+
options.signal = this.abortController.signal;
136+
132137
const result = this.api.fetch(this.endpoint, query, options);
133138

134139
result.then((entities) => {
@@ -137,7 +142,7 @@ app.component('mc-entities', {
137142

138143
return result;
139144
},
140-
145+
141146
refresh(debounce) {
142147
if (this.entities.loading) {
143148
return;
@@ -146,18 +151,17 @@ app.component('mc-entities', {
146151
if (this.timeout) {
147152
clearTimeout(this.timeout)
148153
};
149-
154+
150155
this.entities.splice(0);
151156
this.timeout = setTimeout(() => {
152157
this.entities.loading = true;
153-
158+
154159
this.getDataFromApi()
155160
.then(() => {
156161
this.entities.loading = false;
157162
})
158163
}, debounce);
159164
},
160-
161165

162166
loadMore() {
163167
if (!this.limit) {

src/modules/Components/components/mc-modal/script.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ app.component('mc-modal', {
77
type: String,
88
default: ''
99
},
10+
subtitle: {
11+
type: String,
12+
default: null
13+
},
1014
classes: {
1115
type: [String, Array],
1216
default: '',

src/modules/Components/components/mc-modal/style.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
}
3434

3535
.modal__header {
36+
align-items: flex-start;
3637
display: flex;
38+
flex-direction: column;
3739
justify-content: space-between;
38-
align-items: center;
3940
padding: 1.5rem;
4041
top: 0;
4142
z-index: 1;
@@ -64,6 +65,8 @@
6465
height: 20px;
6566
padding: 0;
6667
cursor: pointer;
68+
position: absolute;
69+
right: 24px;
6770
}
6871

6972
@media (max-width: 800px)

src/modules/Components/components/mc-modal/template.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<template v-if="modalOpen">
1515
<div class="modal__header">
1616
<span v-if="title" class="modal__title">{{title}}</span>
17+
<h6 v-if="subtitle">{{subtitle}}</h6>
1718
<button v-if="closeButton" class="modal__close" @click="close()"> <mc-icon name="close"></mc-icon> </button>
1819
</div>
1920
<div class="modal__content">

0 commit comments

Comments
 (0)