Skip to content

Commit aa60575

Browse files
committedApr 14, 2021
[dashboard] Sort environment variables alphabetically
1 parent 2df9e70 commit aa60575

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎components/dashboard/src/settings/EnvironmentVariables.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,19 @@ function AddEnvVarModal(p: EnvVarModalProps) {
8080
</Modal>
8181
}
8282

83+
function sortEnvVars(a: UserEnvVarValue, b: UserEnvVarValue) {
84+
if (a.name === b.name) {
85+
return a.repositoryPattern > b.repositoryPattern ? 1 : -1;
86+
}
87+
return a.name > b.name ? 1 : -1;
88+
}
89+
8390
export default function EnvVars() {
8491
const [envVars, setEnvVars] = useState([] as UserEnvVarValue[]);
8592
const [currentEnvVar, setCurrentEnvVar] = useState({ name: '', value: '', repositoryPattern: '' } as UserEnvVarValue);
8693
const [isAddEnvVarModalVisible, setAddEnvVarModalVisible] = useState(false);
8794
const update = async () => {
88-
await getGitpodService().server.getAllEnvVars().then(r => setEnvVars(r));
95+
await getGitpodService().server.getAllEnvVars().then(r => setEnvVars(r.sort(sortEnvVars)));
8996
}
9097

9198
useEffect(() => {

0 commit comments

Comments
 (0)
Please sign in to comment.