Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Fix the issue that new version is not loaded after upgrade #4140

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
2 changes: 1 addition & 1 deletion shell-ui/index-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="preload" as="script" href="{{this}}" />
{{/each}}
<title>Document</title>
<script language="javascript">window.shellUIRemoteEntryUrl = "/shell/remoteEntry.js?" + Date.now();</script>
<script language="javascript">window.shellUIRemoteEntryUrl = "/shell/remoteEntry.js?version={{htmlWebpackPlugin.options.version}}"</script>
</head>
<body>
<div id="app"></div>
Expand Down
36 changes: 18 additions & 18 deletions shell-ui/src/initFederation/ConfigurationProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,30 +280,30 @@ export const ConfigurationProvider = ({
queryKey: `${ui.name}.${ui.kind}.${ui.version}-buildtime-WebFinger`,
refetchOnWindowFocus: false,
queryFn: () => {
return fetch(`${ui.url}/.well-known/micro-app-configuration`).then(
(r) => {
if (r.ok) {
return r.json();
} else {
return Promise.reject();
}
},
);
return fetch(
`${ui.url}/.well-known/micro-app-configuration?version=${ui.version}`,
).then((r) => {
if (r.ok) {
return r.json();
} else {
return Promise.reject();
}
});
},
},
{
queryKey: `${ui.name}.${ui.kind}.${ui.version}-runtime-WebFinger`,
refetchOnWindowFocus: false,
queryFn: () => {
return fetch(`${ui.url}/.well-known/runtime-app-configuration`).then(
(r) => {
if (r.ok) {
return r.json();
} else {
return Promise.reject();
}
},
);
return fetch(
`${ui.url}/.well-known/runtime-app-configuration?version=${ui.version}`,
).then((r) => {
if (r.ok) {
return r.json();
} else {
return Promise.reject();
}
});
},
},
]),
Expand Down
2 changes: 1 addition & 1 deletion shell-ui/src/initFederation/UIListProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const UIListProvider = ({
const { status, data } = useQuery(
'discoveredUIs',
() => {
return fetch(discoveryURL).then((r) => {
return fetch(discoveryURL, { cache: 'no-cache' }).then((r) => {
if (r.ok) {
return r.json();
} else {
Expand Down
5 changes: 4 additions & 1 deletion shell-ui/src/navbar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ export const useNavbarLinksToActions = (
},
};
const remoteEntryUrl = link.view.isFederated
? link.view.app.url + microAppConfiguration.spec.remoteEntryPath
? link.view.app.url +
microAppConfiguration.spec.remoteEntryPath +
'?version=' +
link.view.app.version
: '';
prefetch(remoteEntryUrl).catch((e) =>
console.error(`Failed to preload ${remoteEntryUrl}`, e),
Expand Down
2 changes: 2 additions & 0 deletions shell-ui/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const deps = require('./package.json').dependencies;
module.exports = {
entry: './src/index.tsx',
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'build'),
publicPath: '/shell/',
},
Expand Down Expand Up @@ -163,6 +164,7 @@ module.exports = {
},
}),
new HtmlWebPackPlugin({
version: new Date().getTime(),
template: '!!handlebars-loader!./index-template.html',
filename: './index.html',
excludeChunks: ['shell'],
Expand Down
5 changes: 4 additions & 1 deletion ui/src/containers/AlertProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import {
FederatedComponent,
} from '@scality/module-federation';
import { STATUS_HEALTH } from '../constants';
import { QueryObserverResult } from 'react-query';
export type Status = 'healthy' | 'warning' | 'critical';

const alertGlobal = {};
export const useAlerts = (filters: FilterLabels) => {
export const useAlerts = (
filters: FilterLabels,
): Omit<QueryObserverResult<Alert[]>, 'data'> & { alerts?: Alert[] } => {
return alertGlobal.hooks.useAlerts(filters);
};
export const useHighestSeverityAlerts = (filters: FilterLabels) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (env) => ({
metalk8s_ui: './src/index.ts',
},
output: {
filename: 'static/js/[name].js',
filename: 'static/js/[name].[contenthash].js',
path: path.resolve(__dirname, 'build'),
publicPath: '/',
},
Expand Down